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_ senf::ppi::connector::PassiveInput<> & senf::ppi::module::PassiveJoin::newInput()
47 inputs_.push_back(new connector::PassiveInput<>());
48 connector::PassiveInput<> & input (inputs_.back());
51 input.onRequest(boost::bind(&PassiveJoin::request,this,boost::ref(input)));
56 prefix_ void senf::ppi::module::PassiveJoin::request(connector::GenericPassiveInput & input)
61 prefix_ void senf::ppi::module::PassiveJoin::onThrottle()
63 using boost::lambda::_1;
64 using boost::lambda::bind;
65 std::for_each(inputs_.begin(), inputs_.end(),
66 bind(&connector::GenericPassiveInput::throttle, _1));
69 prefix_ void senf::ppi::module::PassiveJoin::onUnthrottle()
71 using boost::lambda::_1;
72 using boost::lambda::bind;
73 std::for_each(inputs_.begin(), inputs_.end(),
74 bind(&connector::GenericPassiveInput::unthrottle, _1));
77 ///////////////////////////////////////////////////////////////////////////
78 // senf::ppi::module::PriorityJoin
80 ////////////////////////////////////////
83 prefix_ senf::ppi::connector::ActiveInput<> &
84 senf::ppi::module::PriorityJoin::newInput(int priority)
86 if (priority > int(inputs_.size()))
87 priority = inputs_.size();
88 else if (priority < 0) {
89 priority = inputs_.size() + priority + 1;
94 connector::ActiveInput<> & input (
95 *inputs_.insert(inputs_.begin()+priority, new connector::ActiveInput<>()));
98 input.onThrottle(&PriorityJoin::onThrottle);
99 input.onUnthrottle(&PriorityJoin::onUnthrottle);
104 prefix_ void senf::ppi::module::PriorityJoin::request()
106 using boost::lambda::_1;
107 using boost::lambda::bind;
108 Inputs::iterator i (std::find_if(inputs_.begin(), inputs_.end(),
109 ! bind(&connector::GenericActiveInput::throttled, _1)));
110 if (i != inputs_.end())
114 prefix_ void senf::ppi::module::PriorityJoin::onThrottle()
116 if (std::find_if(inputs_.begin(), inputs_.end(),
117 ! bind(&connector::GenericActiveInput::throttled, _1)) == inputs_.end())
121 prefix_ void senf::ppi::module::PriorityJoin::onUnthrottle()
126 ///////////////////////////////cc.e////////////////////////////////////////
128 //#include "Joins.mpp"
134 // comment-column: 40
135 // c-file-style: "senf"
136 // indent-tabs-mode: nil
137 // ispell-local-dictionary: "american"
138 // compile-command: "scons -u test"