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 KeyType_, class ContainerType_>
41 prefix_ ContainerType_ const &
42 senf::ppi::module::MultiConnectorMixin<Self_,ConnectorType_,KeyType_,ContainerType_>::
49 template <class Self_, class ConnectorType_, class ContainerType_>
50 prefix_ ContainerType_ &
51 senf::ppi::module::MultiConnectorMixin<Self_,ConnectorType_,void,ContainerType_>::connectors()
58 // Only for exposition
59 // Other implementations with 0..SENF_MULTI_CONNECTOR_MAX_ARGS arguments accordingly
61 template <class Self_, class ConnectorType_, class KeyType_, class ContainerType_>
63 prefix_ ConnectorType_ &
64 senf::ppi::module::MultiConnectorMixin<Self_,ConnectorType_,KeyType_,ContainerType_>::
65 newConnector(A1 const & a1)
67 std::auto_ptr<ConnectorType_> conn (new ConnectorType_);
68 KeyType_ key (static_cast<Self_*>(this)->connectorSetup(*conn, a1));
69 return * connectors_.insert(key, conn).first->second;
72 template <class Self_, class ConnectorType_, class ContainerType_>
74 prefix_ ConnectorType_ &
75 senf::ppi::module::MultiConnectorMixin<Self_,ConnectorType_,void,ContainerType_>::
76 newConnector(A1 const & a1)
78 connectors_.push_back(new ConnectorType_);
79 ConnectorType_ & conn (connectors_.back());
80 try { static_cast<Self_*>(this)->connectorSetup(conn , a1); }
81 catch (...) { connectors_.pop_back(); throw; }
85 template <class Source, class Target , class A1>
86 typename boost::enable_if<
87 boost::is_base_of<senf::ppi::connector::OutputConnector, typename Source::ConnectorType>,
88 typename Source::ConnectorType & >::type
89 senf::ppi::connect(Source & source, Target & target , A1 const & a1)
91 connect(source.newConnector(a1), target);
94 template <class Source, class Target , class A1>
95 typename boost::enable_if<
96 boost::is_base_of<senf::ppi::connector::InputConnector, typename Target::ConnectorType>,
97 typename Target::ConnectorType & >::type
98 senf::ppi::connect(Source & source, Target & target , A1 const & a1)
100 connect(source, target.newConnector(a1));
105 // Include 'Implementation' from MultiConnectorMixin.mpp
106 #define BOOST_PP_ITERATION_PARAMS_1 (4, ( \
108 SENF_MULTI_CONNECTOR_MAX_ARGS, \
109 SENF_ABSOLUTE_INCLUDE_PATH(PPI/MultiConnectorMixin.mpp), \
111 #include BOOST_PP_ITERATE()
113 // Include 'senf::ppi::detail implementation' from MultiConnectorMixin.mpp
114 #define BOOST_PP_ITERATION_PARAMS_1 (4, ( \
116 2*SENF_MULTI_CONNECTOR_MAX_ARGS, \
117 SENF_ABSOLUTE_INCLUDE_PATH(PPI/MultiConnectorMixin.mpp), \
119 #include BOOST_PP_ITERATE()
123 ///////////////////////////////cti.e///////////////////////////////////////
130 // comment-column: 40
131 // c-file-style: "senf"
132 // indent-tabs-mode: nil
133 // ispell-local-dictionary: "american"
134 // compile-command: "scons -u test"