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 Joins non-inline non-template implementation */
31 #include <boost/bind.hpp>
32 #include <boost/lambda/lambda.hpp>
33 #include <boost/lambda/bind.hpp>
35 //#include "Joins.mpp"
37 ///////////////////////////////cc.p////////////////////////////////////////
39 ///////////////////////////////////////////////////////////////////////////
40 // senf::ppi::module::PassiveJoin
42 ////////////////////////////////////////
45 prefix_ void senf::ppi::module::PassiveJoin::connectorSetup(connector::PassiveInput<> & conn)
48 conn.onRequest(boost::bind(&PassiveJoin::request,this,boost::ref(conn)));
51 prefix_ void senf::ppi::module::PassiveJoin::request(connector::GenericPassiveInput & input)
56 prefix_ void senf::ppi::module::PassiveJoin::onThrottle()
58 using boost::lambda::_1;
59 using boost::lambda::bind;
60 std::for_each(connectors().begin(), connectors().end(),
61 bind(&connector::GenericPassiveInput::throttle, _1));
64 prefix_ void senf::ppi::module::PassiveJoin::onUnthrottle()
66 using boost::lambda::_1;
67 using boost::lambda::bind;
68 std::for_each(connectors().begin(), connectors().end(),
69 bind(&connector::GenericPassiveInput::unthrottle, _1));
72 ///////////////////////////////////////////////////////////////////////////
73 // senf::ppi::module::PriorityJoin
75 ////////////////////////////////////////
79 senf::ppi::module::PriorityJoin::connectorSetup(PriorityJoin::ConnectorType & conn,
83 conn.onThrottle(&PriorityJoin::onThrottle);
84 conn.onUnthrottle(&PriorityJoin::onUnthrottle);
87 priority = connectors().size() + priority;
91 if (priority >= int(connectors().size())-1)
94 connectors().insert(connectors().begin()+priority, connectors().pop_back().release());
97 prefix_ void senf::ppi::module::PriorityJoin::request()
99 using boost::lambda::_1;
100 using boost::lambda::bind;
101 PriorityJoin::ContainerType::iterator i (
102 std::find_if(connectors().begin(), connectors().end(),
103 ! bind(&connector::GenericActiveInput::throttled, _1)));
104 if (i != connectors().end())
108 prefix_ void senf::ppi::module::PriorityJoin::onThrottle()
110 if (std::find_if(connectors().begin(), connectors().end(),
111 ! bind(&connector::GenericActiveInput::throttled, _1)) == connectors().end())
115 prefix_ void senf::ppi::module::PriorityJoin::onUnthrottle()
120 ///////////////////////////////cc.e////////////////////////////////////////
122 //#include "Joins.mpp"
128 // comment-column: 40
129 // c-file-style: "senf"
130 // indent-tabs-mode: nil
131 // ispell-local-dictionary: "american"
132 // compile-command: "scons -u test"