Search:

SENF Extensible Network Framework

  • Home
  • Download
  • Wiki
  • BerliOS
  • ChangeLog
  • Browse SVN
  • Bug Tracker
  • Overview
  • Examples
  • HowTos
  • Glossary
  • PPI
  • Packets
  • Scheduler
  • Socket
  • Utils
  • Console
  • Daemon
  • Logger
  • Termlib
  • Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Classes
  • Files
  • Directories
  • File List
  • File Members

MultiConnectorMixin.hh

Go to the documentation of this file.
00001 // $Id: MultiConnectorMixin.hh 1754 2010-12-09 15:45:42Z tho $
00002 //
00003 // Copyright (C) 2009
00004 // Fraunhofer (FOKUS)
00005 // Competence Center NETwork research (NET), St. Augustin, GERMANY
00006 //     Stefan Bund <g0dil@berlios.de>
00007 //
00008 // This program is free software; you can redistribute it and/or modify
00009 // it under the terms of the GNU General Public License as published by
00010 // the Free Software Foundation; either version 2 of the License, or
00011 // (at your option) any later version.
00012 //
00013 // This program is distributed in the hope that it will be useful,
00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016 // GNU General Public License for more details.
00017 //
00018 // You should have received a copy of the GNU General Public License
00019 // along with this program; if not, write to the
00020 // Free Software Foundation, Inc.,
00021 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00022 
00026 #ifndef HH_SENF_PPI_MultiConnectorMixin_
00027 #define HH_SENF_PPI_MultiConnectorMixin_ 1
00028 
00029 // Custom includes
00030 #include <senf/config.hh>
00031 #include <boost/ptr_container/ptr_map.hpp>
00032 #include <boost/ptr_container/ptr_vector.hpp>
00033 #include <boost/mpl/if.hpp>
00034 
00035 #ifndef SENF_MULTI_CONNECTOR_MAX_ARGS
00036 #define SENF_MULTI_CONNECTOR_MAX_ARGS 3
00037 #endif
00038 
00039 #include "MultiConnectorMixin.mpp"
00040 #include "MultiConnectorMixin.ih"
00041 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00042 
00043 namespace senf {
00044 namespace ppi {
00045 
00046 #ifdef DOXYGEN
00047 
00048     // For exposition only.
00049     // Other implementations with 0..SENF_MULTI_CONNECTOR_MAX_ARGS arguments accordingly
00050     // The real implementation includes a boost::enable_if condition in the return value, which is
00051     // used to only enable the correct overload: The first overload, if the MultiConnector is an
00052     // output, otherwise the second overload.
00053 
00060     template <class MultiConnectorSource, class Target, class A1>
00061     MultiConnectorSource::ConnectorType & connect(
00062         MultiConnectorSource & source, A1 const & a1, Target & target);
00063 
00070     template <class Source, class MultiConnectorTarget, class A1>
00071     MultiConnectorTarget::ConnectorType & connect(
00072         Source & source, MultiConnectorTarget & target, A1 const & a1);
00073 
00074     template <class MultiConnectorSource, class MultiConnectorTarget, class A1, class A2>
00075     std::pair<MultiConnectorSource::ConnectorType &, MultiConnectorTarget::ConnectorType &>
00076     connect(
00077         MultiConnectorSource & source, MultiConnectorTarget & target, A1 const & a1, A2 const & a2);
00078 
00079 #else
00080 
00081     // Include 'senf::ppi namespace member declarations' from MultiConnectorMixin.mpp
00082 #   define BOOST_PP_ITERATION_PARAMS_1 (4, ( \
00083             0, \
00084             SENF_MULTI_CONNECTOR_MAX_ARGS, \
00085             SENF_ABSOLUTE_INCLUDE_PATH(PPI/MultiConnectorMixin.mpp), \
00086             2 ))
00087 #   include BOOST_PP_ITERATE()
00088 
00089 #endif
00090 
00091 namespace module {
00092 
00093     namespace detail { class MultiConnectorMixinAccess; }
00094 
00250     template <class Self_,
00251               class ConnectorType_,
00252               class KeyType_=void,
00253               class ContainerType_=typename detail::MultiConnectorDefaultContainer<
00254                                                KeyType_,ConnectorType_>::type>
00255     class MultiConnectorMixin
00256         : private detail::MultiConnectorSelectBase<ConnectorType_>::type
00257     {
00258     public:
00259         typedef ConnectorType_ ConnectorType; 
00260 
00261     protected:
00262         typedef ContainerType_ ContainerType; 
00263 
00264         ContainerType_ & connectors();        
00265         ContainerType_ const & connectors() const; 
00266 
00267         void connectorDestroy(ConnectorType const &);
00268 
00269     private:
00270 
00271 #ifndef DOXYGEN
00272 
00273         // Include 'MultiConnectorMixin member declaration' from MultiConnectorMixin.mpp
00274 #       define BOOST_PP_ITERATION_PARAMS_1 (4, ( \
00275             0, \
00276             SENF_MULTI_CONNECTOR_MAX_ARGS, \
00277             SENF_ABSOLUTE_INCLUDE_PATH(PPI/MultiConnectorMixin.mpp), \
00278             1 ))
00279 #       include BOOST_PP_ITERATE()
00280 
00281 #endif
00282 
00283         void disconnected(ConnectorType_ const & c);
00284 
00285         friend class detail::MultiConnectorMixinAccess;
00286         friend class detail::MultiConnectorWrapper<Self_,ConnectorType_>;
00287 
00288         ContainerType_ connectors_;
00289     };
00290 
00291 #ifndef DOXYGEN
00292 
00293     template <class Self_,
00294               class ConnectorType_,
00295               class ContainerType_>
00296     class MultiConnectorMixin<Self_,ConnectorType_,void,ContainerType_>
00297         : private detail::MultiConnectorSelectBase<ConnectorType_>::type
00298     {
00299     public:
00300         typedef ConnectorType_ ConnectorType;
00301 
00302     protected:
00303         typedef ContainerType_ ContainerType;
00304 
00305         ContainerType_ & connectors();
00306         ContainerType_ const & connectors() const;
00307 
00308         void connectorDestroy(ConnectorType const &);
00309 
00310     private:
00311 
00312         // Include 'MultiConnectorMixin member declaration' from MultiConnectorMixin.mpp
00313 #       define BOOST_PP_ITERATION_PARAMS_1 (4, ( \
00314             0, \
00315             SENF_MULTI_CONNECTOR_MAX_ARGS, \
00316             SENF_ABSOLUTE_INCLUDE_PATH(PPI/MultiConnectorMixin.mpp), \
00317             1 ))
00318 #       include BOOST_PP_ITERATE()
00319 
00320         void disconnected(ConnectorType_ const & c);
00321 
00322         friend class detail::MultiConnectorMixinAccess;
00323         friend class detail::MultiConnectorWrapper<Self_,ConnectorType_>;
00324 
00325         ContainerType_ connectors_;
00326     };
00327 
00328     template <class Self_,
00329               class ConnectorType_>
00330     class MultiConnectorMixin<Self_,ConnectorType_,void,void>
00331         : private detail::MultiConnectorSelectBase<ConnectorType_>::type
00332     {
00333     public:
00334         typedef ConnectorType_ ConnectorType;
00335 
00336     private:
00337 
00338         // Include 'MultiConnectorMixin member declaration' from MultiConnectorMixin.mpp
00339 #       define BOOST_PP_ITERATION_PARAMS_1 (4, ( \
00340             0, \
00341             SENF_MULTI_CONNECTOR_MAX_ARGS, \
00342             SENF_ABSOLUTE_INCLUDE_PATH(PPI/MultiConnectorMixin.mpp), \
00343             1 ))
00344 #       include BOOST_PP_ITERATE()
00345 
00346         void disconnected(ConnectorType_ const & c);
00347 
00348         friend class detail::MultiConnectorMixinAccess;
00349         friend class detail::MultiConnectorWrapper<Self_,ConnectorType_>;
00350     };
00351 
00352 #endif
00353 
00354 }}}
00355 
00356 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00357 //#include "MultiConnectorMixin.cci"
00358 #include "MultiConnectorMixin.ct"
00359 #include "MultiConnectorMixin.cti"
00360 #endif
00361 
00362 
00363 // Local Variables:
00364 // mode: c++
00365 // fill-column: 100
00366 // comment-column: 40
00367 // c-file-style: "senf"
00368 // indent-tabs-mode: nil
00369 // ispell-local-dictionary: "american"
00370 // compile-command: "scons -u test"
00371 // End:

Contact: senf-dev@lists.berlios.de | © 2006-2010 Fraunhofer Institute for Open Communication Systems, Network Research