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 (ModuleManager::instance().running())
60 prefix_ std::type_info const & senf::ppi::connector::Connector::packetTypeID()
65 ///////////////////////////////////////////////////////////////////////////
66 // senf::ppi::connector::PassiveConnector
68 ////////////////////////////////////////
71 prefix_ void senf::ppi::connector::PassiveConnector::v_init()
73 Routes::const_iterator i (routes_.begin());
74 Routes::const_iterator const i_end (routes_.end());
75 for (; i != i_end; ++i)
76 if ((*i)->throttled())
79 remoteThrottled_ = false;
86 prefix_ void senf::ppi::connector::PassiveConnector::v_unthrottleEvent()
89 prefix_ void senf::ppi::connector::PassiveConnector::notifyUnthrottle()
91 if (throttled() && !nativeThrottled_) {
92 Routes::const_iterator i (routes_.begin());
93 Routes::const_iterator const i_end (routes_.end());
94 for (; i != i_end; ++i)
95 if ((*i)->throttled())
98 remoteThrottled_ = false;
103 remoteThrottled_ = false;
106 ///////////////////////////////////////////////////////////////////////////
107 // senf::ppi::connector::ActiveConnector
109 ////////////////////////////////////////
112 prefix_ void senf::ppi::connector::ActiveConnector::v_init()
118 prefix_ void senf::ppi::connector::ActiveConnector::notifyThrottle()
122 if (throttleCallback_)
124 NotifyRoutes::const_iterator i (notifyRoutes_.begin());
125 NotifyRoutes::const_iterator const i_end (notifyRoutes_.end());
126 for (; i != i_end; ++i)
127 (*i)->notifyThrottle();
131 prefix_ void senf::ppi::connector::ActiveConnector::notifyUnthrottle()
135 if (unthrottleCallback_)
136 unthrottleCallback_();
137 NotifyRoutes::const_iterator i (notifyRoutes_.begin());
138 NotifyRoutes::const_iterator const i_end (notifyRoutes_.end());
139 for (; i != i_end; ++i)
140 (*i)->notifyUnthrottle();
144 prefix_ void senf::ppi::connector::ActiveConnector::registerRoute(ForwardingRoute & route)
146 notifyRoutes_.push_back(&route);
149 ///////////////////////////////////////////////////////////////////////////
150 // senf::ppi::connector::InputConnector
152 prefix_ senf::Packet senf::ppi::connector::InputConnector::operator()()
165 ////////////////////////////////////////
168 prefix_ void senf::ppi::connector::InputConnector::v_requestEvent()
171 prefix_ void senf::ppi::connector::InputConnector::v_enqueueEvent()
174 prefix_ void senf::ppi::connector::InputConnector::v_dequeueEvent()
177 ///////////////////////////////////////////////////////////////////////////
178 // senf::ppi::connector::GenericActiveInput
180 ////////////////////////////////////////
183 prefix_ void senf::ppi::connector::GenericActiveInput::v_requestEvent()
188 ///////////////////////////////////////////////////////////////////////////
189 // senf::ppi::connector::GenericPassiveInput
191 ////////////////////////////////////////
194 prefix_ void senf::ppi::connector::GenericPassiveInput::v_enqueueEvent()
197 qdisc_->update(*this, QueueingDiscipline::ENQUEUE);
200 prefix_ void senf::ppi::connector::GenericPassiveInput::v_dequeueEvent()
202 qdisc_->update(*this, QueueingDiscipline::DEQUEUE);
205 prefix_ void senf::ppi::connector::GenericPassiveInput::v_unthrottleEvent()
207 size_type n (queueSize());
210 size_type nn (queueSize());
217 ///////////////////////////////cc.e////////////////////////////////////////
219 //#include "Connectors.mpp"
225 // comment-column: 40
226 // c-file-style: "senf"
227 // indent-tabs-mode: nil
228 // ispell-local-dictionary: "american"
229 // compile-command: "scons -u test"