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 // The connector is already connected
46 SENF_ASSERT( ! peer_ );
47 // The target connector is not registered -> route() or noroute() statement missing
48 SENF_ASSERT( target.module_ );
49 // The target connector is already connected
50 SENF_ASSERT( ! target.peer_ );
51 if (! (packetTypeID() == typeid(void) ||
52 target.packetTypeID() == typeid(void) ||
53 packetTypeID() == target.packetTypeID()) )
54 throw IncompatibleConnectorsException()
55 << ": " << prettyName(packetTypeID())
56 << " [in module " << prettyName(typeid(*module_)) << "] "
57 << ", " << prettyName(target.packetTypeID())
58 << " [in module " << prettyName(typeid(*target.module_)) << "]";
63 if (! initializationScheduled())
64 enqueueInitializable();
65 if (! peer().initializationScheduled())
66 peer().enqueueInitializable();
69 prefix_ void senf::ppi::connector::Connector::disconnect()
71 // Cannot disconnected a non-connected connector
73 Connector & peer (*peer_);
77 if (! initializationScheduled())
78 enqueueInitializable();
79 if (! peer.initializationScheduled())
80 peer.enqueueInitializable();
83 prefix_ std::type_info const & senf::ppi::connector::Connector::packetTypeID()
88 ///////////////////////////////////////////////////////////////////////////
89 // senf::ppi::connector::PassiveConnector
91 ////////////////////////////////////////
94 prefix_ void senf::ppi::connector::PassiveConnector::v_init()
96 Routes::const_iterator i (routes_.begin());
97 Routes::const_iterator const i_end (routes_.end());
98 for (; i != i_end; ++i)
99 if ((*i)->throttled())
102 remoteThrottled_ = false;
109 prefix_ void senf::ppi::connector::PassiveConnector::v_unthrottleEvent()
112 prefix_ void senf::ppi::connector::PassiveConnector::notifyUnthrottle()
114 if (throttled() && !nativeThrottled_) {
115 Routes::const_iterator i (routes_.begin());
116 Routes::const_iterator const i_end (routes_.end());
117 for (; i != i_end; ++i)
118 if ((*i)->throttled())
121 remoteThrottled_ = false;
126 remoteThrottled_ = false;
129 ///////////////////////////////////////////////////////////////////////////
130 // senf::ppi::connector::ActiveConnector
132 ////////////////////////////////////////
135 prefix_ void senf::ppi::connector::ActiveConnector::v_init()
141 prefix_ void senf::ppi::connector::ActiveConnector::notifyThrottle()
145 if (throttleCallback_)
147 NotifyRoutes::const_iterator i (notifyRoutes_.begin());
148 NotifyRoutes::const_iterator const i_end (notifyRoutes_.end());
149 for (; i != i_end; ++i)
150 (*i)->notifyThrottle();
154 prefix_ void senf::ppi::connector::ActiveConnector::notifyUnthrottle()
158 if (unthrottleCallback_)
159 unthrottleCallback_();
160 NotifyRoutes::const_iterator i (notifyRoutes_.begin());
161 NotifyRoutes::const_iterator const i_end (notifyRoutes_.end());
162 for (; i != i_end; ++i)
163 (*i)->notifyUnthrottle();
167 prefix_ void senf::ppi::connector::ActiveConnector::registerRoute(ForwardingRoute & route)
169 notifyRoutes_.push_back(&route);
172 ///////////////////////////////////////////////////////////////////////////
173 // senf::ppi::connector::InputConnector
175 prefix_ senf::Packet senf::ppi::connector::InputConnector::operator()()
188 ////////////////////////////////////////
191 prefix_ void senf::ppi::connector::InputConnector::v_requestEvent()
194 prefix_ void senf::ppi::connector::InputConnector::v_enqueueEvent()
197 prefix_ void senf::ppi::connector::InputConnector::v_dequeueEvent()
200 ///////////////////////////////////////////////////////////////////////////
201 // senf::ppi::connector::GenericActiveInput
203 ////////////////////////////////////////
206 prefix_ void senf::ppi::connector::GenericActiveInput::v_requestEvent()
211 ///////////////////////////////////////////////////////////////////////////
212 // senf::ppi::connector::GenericPassiveInput
214 ////////////////////////////////////////
217 prefix_ void senf::ppi::connector::GenericPassiveInput::v_enqueueEvent()
220 qdisc_->update(*this, QueueingDiscipline::ENQUEUE);
223 prefix_ void senf::ppi::connector::GenericPassiveInput::v_dequeueEvent()
225 qdisc_->update(*this, QueueingDiscipline::DEQUEUE);
228 prefix_ void senf::ppi::connector::GenericPassiveInput::v_unthrottleEvent()
230 size_type n (queueSize());
233 size_type nn (queueSize());
240 ///////////////////////////////cc.e////////////////////////////////////////
242 //#include "Connectors.mpp"
248 // comment-column: 40
249 // c-file-style: "senf"
250 // indent-tabs-mode: nil
251 // ispell-local-dictionary: "american"
252 // compile-command: "scons -u test"