4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 // Stefan Bund <g0dil@berlios.de>
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the
20 // Free Software Foundation, Inc.,
21 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 \brief MultiConnectorMixin inline template implementation */
26 //#include "MultiConnectorMixin.ih"
30 #define prefix_ inline
31 ///////////////////////////////cti.p///////////////////////////////////////
33 template <class Self_, class ConnectorType_, class KeyType_, class ContainerType_>
34 prefix_ ContainerType_ &
35 senf::ppi::module::MultiConnectorMixin<Self_,ConnectorType_,KeyType_,ContainerType_>::connectors()
40 template <class Self_, class ConnectorType_, class ContainerType_>
41 prefix_ ContainerType_ &
42 senf::ppi::module::MultiConnectorMixin<Self_,ConnectorType_,void,ContainerType_>::connectors()
49 // Only for exposition
50 // Other implementations with 0..SENF_MULTI_CONNECTOR_MAX_ARGS arguments accordingly
52 template <class Self_, class ConnectorType_, class KeyType_, class ContainerType_>
54 prefix_ ConnectorType_ &
55 senf::ppi::module::MultiConnectorMixin<Self_,ConnectorType_,KeyType_,ContainerType_>::
56 newConnector(A1 const & a1)
58 std::auto_ptr<ConnectorType_> conn (new ConnectorType_);
59 KeyType_ key (static_cast<Self_*>(this)->connectorSetup(*conn, a1));
60 return * connectors_.insert(key, conn).first->second;
63 template <class Self_, class ConnectorType_, class ContainerType_>
65 prefix_ ConnectorType_ &
66 senf::ppi::module::MultiConnectorMixin<Self_,ConnectorType_,void,ContainerType_>::
67 newConnector(A1 const & a1)
69 connectors_.push_back(new ConnectorType_);
70 ConnectorType_ & conn (connectors_.back());
71 try { static_cast<Self_*>(this)->connectorSetup(conn , a1); }
72 catch (...) { connectors_.pop_back(); throw; }
76 template <class Source, class Target , class A1>
77 typename boost::enable_if<
78 boost::is_base_of<senf::ppi::connector::OutputConnector, typename Source::ConnectorType>,
79 typename Source::ConnectorType & >::type
80 senf::ppi::connect(Source & source, Target & target , A1 const & a1)
82 connect(source.newConnector(a1), target);
85 template <class Source, class Target , class A1>
86 typename boost::enable_if<
87 boost::is_base_of<senf::ppi::connector::InputConnector, typename Target::ConnectorType>,
88 typename Target::ConnectorType & >::type
89 senf::ppi::connect(Source & source, Target & target , A1 const & a1)
91 connect(source, target.newConnector(a1));
96 // Include 'Implementation' from MultiConnectorMixin.mpp
97 #define BOOST_PP_ITERATION_PARAMS_1 (4, ( \
99 SENF_MULTI_CONNECTOR_MAX_ARGS, \
100 SENF_ABSOLUTE_INCLUDE_PATH(PPI/MultiConnectorMixin.mpp), \
102 #include BOOST_PP_ITERATE()
104 ///////////////////////////////cti.e///////////////////////////////////////
111 // comment-column: 40
112 // c-file-style: "senf"
113 // indent-tabs-mode: nil
114 // ispell-local-dictionary: "american"
115 // compile-command: "scons -u test"