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 Connectors non-inline non-template implementation */
26 #include "Connectors.hh"
27 #include "Connectors.ih"
32 #include "ModuleManager.hh"
34 //#include "Connectors.mpp"
36 ///////////////////////////////cc.p////////////////////////////////////////
38 ///////////////////////////////////////////////////////////////////////////
39 // senf::ppi::connector::Connector
41 prefix_ void senf::ppi::connector::Connector::connect(Connector & target)
43 // The connector is not registered -> route() or noroute() statement missing
44 SENF_ASSERT( module_ &&
45 "senf::ppi::connector::Connector::connect(): (source) "
46 "Missing route() or noroute()" );
47 // The connector is already connected
48 SENF_ASSERT( ! peer_ &&
49 "senf::ppi::connector::Connector::connect(): (source) "
50 "duplicate connection" );
51 // The target connector is not registered -> route() or noroute() statement missing
52 SENF_ASSERT( target.module_ &&
53 "senf::ppi::connector::Connector::connect(): (target) "
54 "Missing route() or noroute()" );
55 // The target connector is already connected
56 SENF_ASSERT( ! target.peer_ &&
57 "senf::ppi::connector::Connector::connect(): (target) "
58 "duplicate connection" );
59 if (! (packetTypeID() == typeid(void) ||
60 target.packetTypeID() == typeid(void) ||
61 packetTypeID() == target.packetTypeID()) )
62 throw IncompatibleConnectorsException()
63 << ": " << prettyName(packetTypeID())
64 << " [in module " << prettyName(typeid(*module_)) << "] "
65 << ", " << prettyName(target.packetTypeID())
66 << " [in module " << prettyName(typeid(*target.module_)) << "]";
71 if (! initializationScheduled())
72 enqueueInitializable();
73 if (! peer().initializationScheduled())
74 peer().enqueueInitializable();
77 prefix_ void senf::ppi::connector::Connector::disconnect()
79 // Cannot disconnected a non-connected connector
81 "senf::ppi::connector::Connector::disconnect(): Not connected" );
82 Connector & peer (*peer_);
86 if (! initializationScheduled())
87 enqueueInitializable();
88 if (! peer.initializationScheduled())
89 peer.enqueueInitializable();
92 prefix_ std::type_info const & senf::ppi::connector::Connector::packetTypeID()
97 ///////////////////////////////////////////////////////////////////////////
98 // senf::ppi::connector::PassiveConnector
100 ////////////////////////////////////////
103 prefix_ void senf::ppi::connector::PassiveConnector::v_init()
105 Routes::const_iterator i (routes_.begin());
106 Routes::const_iterator const i_end (routes_.end());
107 for (; i != i_end; ++i)
108 if ((*i)->throttled())
111 remoteThrottled_ = false;
118 prefix_ void senf::ppi::connector::PassiveConnector::v_unthrottleEvent()
121 prefix_ void senf::ppi::connector::PassiveConnector::notifyUnthrottle()
123 if (throttled() && !nativeThrottled_) {
124 Routes::const_iterator i (routes_.begin());
125 Routes::const_iterator const i_end (routes_.end());
126 for (; i != i_end; ++i)
127 if ((*i)->throttled())
130 remoteThrottled_ = false;
135 remoteThrottled_ = false;
138 ///////////////////////////////////////////////////////////////////////////
139 // senf::ppi::connector::ActiveConnector
141 ////////////////////////////////////////
144 prefix_ void senf::ppi::connector::ActiveConnector::v_init()
150 prefix_ void senf::ppi::connector::ActiveConnector::notifyThrottle()
154 if (throttleCallback_)
156 NotifyRoutes::const_iterator i (notifyRoutes_.begin());
157 NotifyRoutes::const_iterator const i_end (notifyRoutes_.end());
158 for (; i != i_end; ++i)
159 (*i)->notifyThrottle();
163 prefix_ void senf::ppi::connector::ActiveConnector::notifyUnthrottle()
167 if (unthrottleCallback_)
168 unthrottleCallback_();
169 NotifyRoutes::const_iterator i (notifyRoutes_.begin());
170 NotifyRoutes::const_iterator const i_end (notifyRoutes_.end());
171 for (; i != i_end; ++i)
172 (*i)->notifyUnthrottle();
176 prefix_ void senf::ppi::connector::ActiveConnector::registerRoute(ForwardingRoute & route)
178 notifyRoutes_.push_back(&route);
181 ///////////////////////////////////////////////////////////////////////////
182 // senf::ppi::connector::InputConnector
184 prefix_ senf::Packet senf::ppi::connector::InputConnector::operator()()
197 ////////////////////////////////////////
200 prefix_ void senf::ppi::connector::InputConnector::v_requestEvent()
203 prefix_ void senf::ppi::connector::InputConnector::v_enqueueEvent()
206 prefix_ void senf::ppi::connector::InputConnector::v_dequeueEvent()
209 ///////////////////////////////////////////////////////////////////////////
210 // senf::ppi::connector::GenericActiveInput
212 ////////////////////////////////////////
215 prefix_ void senf::ppi::connector::GenericActiveInput::v_requestEvent()
220 ///////////////////////////////////////////////////////////////////////////
221 // senf::ppi::connector::GenericPassiveInput
223 ////////////////////////////////////////
226 prefix_ void senf::ppi::connector::GenericPassiveInput::v_enqueueEvent()
229 qdisc_->update(*this, QueueingDiscipline::ENQUEUE);
232 prefix_ void senf::ppi::connector::GenericPassiveInput::v_dequeueEvent()
234 qdisc_->update(*this, QueueingDiscipline::DEQUEUE);
237 prefix_ void senf::ppi::connector::GenericPassiveInput::v_unthrottleEvent()
239 size_type n (queueSize());
242 size_type nn (queueSize());
249 ///////////////////////////////cc.e////////////////////////////////////////
251 //#include "Connectors.mpp"
257 // comment-column: 40
258 // c-file-style: "senf"
259 // indent-tabs-mode: nil
260 // ispell-local-dictionary: "american"
261 // compile-command: "scons -u test"