--- /dev/null
+// $Id$
+//
+// Copyright (C) 2007
+// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
+// Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
+// Stefan Bund <g0dil@berlios.de>
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the
+// Free Software Foundation, Inc.,
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+/** \file
+ \brief PassiveQueue non-inline non-template implementation */
+
+#include "PassiveQueue.hh"
+//#include "PassiveQueue.ih"
+
+// Custom includes
+
+//#include "PassiveQueue.mpp"
+#define prefix_
+///////////////////////////////cc.p////////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////////////
+// senf::ppi::module::PassiveQueue
+
+////////////////////////////////////////
+// private members
+
+prefix_ void senf::ppi::module::PassiveQueue::init()
+{
+ output.throttle();
+}
+
+prefix_ void senf::ppi::module::PassiveQueue::onInput()
+{
+ output.unthrottle();
+}
+
+prefix_ void senf::ppi::module::PassiveQueue::onOutput()
+{
+ if (input)
+ output(input());
+ if (!input)
+ output.throttle();
+}
+
+///////////////////////////////cc.e////////////////////////////////////////
+#undef prefix_
+//#include "PassiveQueue.mpp"
+
+\f
+// Local Variables:
+// mode: c++
+// fill-column: 100
+// comment-column: 40
+// c-file-style: "senf"
+// indent-tabs-mode: nil
+// ispell-local-dictionary: "american"
+// compile-command: "scons -u test"
+// End:
--- /dev/null
+// $Id$
+//
+// Copyright (C) 2007
+// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
+// Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
+// Stefan Bund <g0dil@berlios.de>
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the
+// Free Software Foundation, Inc.,
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+/** \file
+ \brief PassiveQueue inline non-template implementation */
+
+// Custom includes
+
+#define prefix_ inline
+///////////////////////////////cci.p///////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////////////
+// senf::ppi::module::PassiveQueue
+
+prefix_ senf::ppi::module::PassiveQueue::PassiveQueue()
+{
+ route(input,output);
+ input.onRequest(&PassiveQueue::onInput);
+ output.onRequest(&PassiveQueue::onOutput);
+}
+
+///////////////////////////////cci.e///////////////////////////////////////
+#undef prefix_
+
+\f
+// Local Variables:
+// mode: c++
+// fill-column: 100
+// comment-column: 40
+// c-file-style: "senf"
+// indent-tabs-mode: nil
+// ispell-local-dictionary: "american"
+// compile-command: "scons -u test"
+// End:
--- /dev/null
+// $Id$
+//
+// Copyright (C) 2007
+// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
+// Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
+// Stefan Bund <g0dil@berlios.de>
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the
+// Free Software Foundation, Inc.,
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+/** \file
+ \brief PassiveQueue inline template implementation */
+
+//#include "PassiveQueue.ih"
+
+// Custom includes
+
+#define prefix_ inline
+///////////////////////////////cti.p///////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////////////
+// senf::ppi::module::PassiveQueue
+
+template <class QDiscipline>
+prefix_ void senf::ppi::module::PassiveQueue::qdisc(QDiscipline const & disc)
+{
+ input.qdisc(disc);
+}
+
+///////////////////////////////cti.e///////////////////////////////////////
+#undef prefix_
+
+\f
+// Local Variables:
+// mode: c++
+// fill-column: 100
+// comment-column: 40
+// c-file-style: "senf"
+// indent-tabs-mode: nil
+// ispell-local-dictionary: "american"
+// compile-command: "scons -u test"
+// End:
#define HH_PassiveQueue_ 1
// Custom includes
+#include "Connectors.hh"
+#include "Module.hh"
+#include "predecl.hh"
//#include "PassiveQueue.mpp"
///////////////////////////////hh.p////////////////////////////////////////
forward throttling notifications are sent out whenever the queue is empty.
*/
class PassiveQueue
+ : public module::Module
{
+ SENF_PPI_MODULE(PassiveQueue);
public:
connector::PassiveInput input;
connector::PassiveOutput output;
PassiveQueue();
- void qdisc(QueueingDiscipline const & disc); ///< Change the queueing discipline
- /**< This call changes the queueing discipline of the queue. This call is just forwarded to
- the \a input connector.
-
- \see connector::PassiveInput::qdisc() */
+ template <class QDiscipline>
+ void qdisc(QDiscipline const & disc); ///< Change the queueing discipline
+ /**< This call changes the queueing discipline of the
+ queue. This call is just forwarded to the \a input
+ connector.
+
+ \see connector::PassiveInput::qdisc() */
+
+ private:
+ void init();
+
+ void onInput();
+ void onOutput();
};
}}}
///////////////////////////////hh.e////////////////////////////////////////
-//#include "PassiveQueue.cci"
+#include "PassiveQueue.cci"
//#include "PassiveQueue.ct"
-//#include "PassiveQueue.cti"
+#include "PassiveQueue.cti"
#endif
\f
--- /dev/null
+// $Id$
+//
+// Copyright (C) 2007
+// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
+// Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
+// Stefan Bund <g0dil@berlios.de>
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the
+// Free Software Foundation, Inc.,
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+/** \file
+ \brief PassiveQueue.test unit tests */
+
+//#include "PassiveQueue.test.hh"
+//#include "PassiveQueue.test.ih"
+
+// Custom includes
+#include "PassiveQueue.hh"
+#include "DebugModules.hh"
+#include "Setup.hh"
+#include "Packets/Packets.hh"
+
+#include <boost/test/auto_unit_test.hpp>
+#include <boost/test/test_tools.hpp>
+
+#define prefix_
+///////////////////////////////cc.p////////////////////////////////////////
+
+namespace ppi = senf::ppi;
+namespace connector = ppi::connector;
+namespace module = ppi::module;
+namespace debug = module::debug;
+
+BOOST_AUTO_UNIT_TEST(passiveQueue)
+{
+ debug::ActivePacketSource source;
+ module::PassiveQueue queue;
+ debug::ActivePacketSink sink;
+
+ ppi::connect(source,queue);
+ ppi::connect(queue,sink);
+ ppi::init();
+
+ senf::Packet p (senf::DataPacket::create());
+
+ BOOST_CHECK( ! sink );
+ source.submit(p);
+ BOOST_CHECK( sink );
+ BOOST_CHECK( ! source );
+ BOOST_CHECK_EQUAL( queue.input.queueSize(), 1u );
+ BOOST_CHECK( sink.request() == p );
+ BOOST_CHECK( source );
+ BOOST_CHECK( ! sink );
+}
+
+///////////////////////////////cc.e////////////////////////////////////////
+#undef prefix_
+
+\f
+// Local Variables:
+// mode: c++
+// fill-column: 100
+// comment-column: 40
+// c-file-style: "senf"
+// indent-tabs-mode: nil
+// ispell-local-dictionary: "american"
+// compile-command: "scons -u test"
+// End: