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 SENF_ASSERT( module_ && ! peer_ && target.module_ && ! target.peer_ );
44 if (! (packetTypeID() == typeid(void) ||
45 target.packetTypeID() == typeid(void) ||
46 packetTypeID() == target.packetTypeID()) )
47 throw IncompatibleConnectorsException()
48 << ": " << prettyName(packetTypeID())
49 << " [in module " << prettyName(typeid(*module_)) << "] "
50 << ", " << prettyName(target.packetTypeID())
51 << " [in module " << prettyName(typeid(*target.module_)) << "]";
56 if (! initializationScheduled())
57 enqueueInitializable();
58 if (! peer().initializationScheduled())
59 peer().enqueueInitializable();
62 prefix_ void senf::ppi::connector::Connector::disconnect()
65 Connector & peer (*peer_);
69 if (! initializationScheduled())
70 enqueueInitializable();
71 if (! peer.initializationScheduled())
72 peer.enqueueInitializable();
75 prefix_ std::type_info const & senf::ppi::connector::Connector::packetTypeID()
80 ///////////////////////////////////////////////////////////////////////////
81 // senf::ppi::connector::PassiveConnector
83 ////////////////////////////////////////
86 prefix_ void senf::ppi::connector::PassiveConnector::v_init()
88 Routes::const_iterator i (routes_.begin());
89 Routes::const_iterator const i_end (routes_.end());
90 for (; i != i_end; ++i)
91 if ((*i)->throttled())
94 remoteThrottled_ = false;
101 prefix_ void senf::ppi::connector::PassiveConnector::v_unthrottleEvent()
104 prefix_ void senf::ppi::connector::PassiveConnector::notifyUnthrottle()
106 if (throttled() && !nativeThrottled_) {
107 Routes::const_iterator i (routes_.begin());
108 Routes::const_iterator const i_end (routes_.end());
109 for (; i != i_end; ++i)
110 if ((*i)->throttled())
113 remoteThrottled_ = false;
118 remoteThrottled_ = false;
121 ///////////////////////////////////////////////////////////////////////////
122 // senf::ppi::connector::ActiveConnector
124 ////////////////////////////////////////
127 prefix_ void senf::ppi::connector::ActiveConnector::v_init()
133 prefix_ void senf::ppi::connector::ActiveConnector::notifyThrottle()
137 if (throttleCallback_)
139 NotifyRoutes::const_iterator i (notifyRoutes_.begin());
140 NotifyRoutes::const_iterator const i_end (notifyRoutes_.end());
141 for (; i != i_end; ++i)
142 (*i)->notifyThrottle();
146 prefix_ void senf::ppi::connector::ActiveConnector::notifyUnthrottle()
150 if (unthrottleCallback_)
151 unthrottleCallback_();
152 NotifyRoutes::const_iterator i (notifyRoutes_.begin());
153 NotifyRoutes::const_iterator const i_end (notifyRoutes_.end());
154 for (; i != i_end; ++i)
155 (*i)->notifyUnthrottle();
159 prefix_ void senf::ppi::connector::ActiveConnector::registerRoute(ForwardingRoute & route)
161 notifyRoutes_.push_back(&route);
164 ///////////////////////////////////////////////////////////////////////////
165 // senf::ppi::connector::InputConnector
167 prefix_ senf::Packet senf::ppi::connector::InputConnector::operator()()
180 ////////////////////////////////////////
183 prefix_ void senf::ppi::connector::InputConnector::v_requestEvent()
186 prefix_ void senf::ppi::connector::InputConnector::v_enqueueEvent()
189 prefix_ void senf::ppi::connector::InputConnector::v_dequeueEvent()
192 ///////////////////////////////////////////////////////////////////////////
193 // senf::ppi::connector::GenericActiveInput
195 ////////////////////////////////////////
198 prefix_ void senf::ppi::connector::GenericActiveInput::v_requestEvent()
203 ///////////////////////////////////////////////////////////////////////////
204 // senf::ppi::connector::GenericPassiveInput
206 ////////////////////////////////////////
209 prefix_ void senf::ppi::connector::GenericPassiveInput::v_enqueueEvent()
212 qdisc_->update(*this, QueueingDiscipline::ENQUEUE);
215 prefix_ void senf::ppi::connector::GenericPassiveInput::v_dequeueEvent()
217 qdisc_->update(*this, QueueingDiscipline::DEQUEUE);
220 prefix_ void senf::ppi::connector::GenericPassiveInput::v_unthrottleEvent()
222 size_type n (queueSize());
225 size_type nn (queueSize());
232 ///////////////////////////////cc.e////////////////////////////////////////
234 //#include "Connectors.mpp"
240 // comment-column: 40
241 // c-file-style: "senf"
242 // indent-tabs-mode: nil
243 // ispell-local-dictionary: "american"
244 // compile-command: "scons -u test"