debug::ActivePacketSource source;
PassiveInputTest target;
- ppi::connect(source.output,target.input);
+ ppi::connect(source,target);
ppi::init();
BOOST_CHECK_EQUAL( & target.input.peer(), & source.output );
debug::PassivePacketSource source;
debug::ActivePacketSink target;
- ppi::connect(source.output,target.input);
+ ppi::connect(source,target);
ppi::init();
senf::Packet p (senf::DataPacket::create());
debug::PassivePacketSource source;
debug::ActivePacketSink target;
- ppi::connect(source.output,target.input);
+ ppi::connect(source,target);
ppi::init();
BOOST_CHECK_EQUAL( & target.input.peer(), & source.output );
debug::ActivePacketSource source;
debug::PassivePacketSink target;
- ppi::connect(source.output,target.input);
+ ppi::connect(source,target);
ppi::init();
BOOST_CHECK_EQUAL( & source.output.peer(), & target.input );
debug::ActivePacketSource source;
debug::PassivePacketSink sink;
- ppi::connect(source.output, sink.input);
+ ppi::connect(source, sink);
ppi::init();
senf::PacketData::byte data[] = { 0x13u, 0x24u, 0x35u };
debug::PassivePacketSource source;
debug::ActivePacketSink sink;
- ppi::connect(source.output, sink.input);
+ ppi::connect(source, sink);
ppi::init();
senf::PacketData::byte data[] = { 0x13u, 0x24u, 0x35u };
};
/** \brief
+
+ \fixme Implement error/EOF handling
*/
class IOEvent
: public EventImplementation<IOEventInfo>
--- /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 IOEvent.test unit tests */
+
+//#include "IOEvent.test.hh"
+//#include "IOEvent.test.ih"
+
+// Custom includes
+#include "IOEvent.hh"
+
+#include <boost/test/auto_unit_test.hpp>
+#include <boost/test/test_tools.hpp>
+
+#define prefix_
+///////////////////////////////cc.p////////////////////////////////////////
+
+BOOST_AUTO_UNIT_TEST(ioEvent)
+{
+ // Tested in SocketReader.test.cc and SocketWriter.test.cc
+}
+
+///////////////////////////////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:
TestModule tester;
debug::PassivePacketSink sink;
- ppi::connect(tester.output, sink.input);
+ ppi::connect(tester, sink);
ppi::init();
tester.event.trigger();
--- /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 ModuleManager.test unit tests */
+
+//#include "ModuleManager.test.hh"
+//#include "ModuleManager.test.ih"
+
+// Custom includes
+#include "ModuleManager.hh"
+
+#include <boost/test/auto_unit_test.hpp>
+#include <boost/test/test_tools.hpp>
+
+#define prefix_
+///////////////////////////////cc.p////////////////////////////////////////
+
+BOOST_AUTO_UNIT_TEST(moduleManager)
+{
+ // Tested in Module.test.cc
+}
+
+///////////////////////////////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:
--- /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 Queueing.test unit tests */
+
+//#include "Queueing.test.hh"
+//#include "Queueing.test.ih"
+
+// Custom includes
+#include "Queueing.hh"
+#include "Module.hh"
+#include "Connectors.hh"
+#include "DebugModules.hh"
+#include "Packets/Packets.hh"
+#include "Setup.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;
+
+namespace {
+ class QueueTester : public module::Module
+ {
+ SENF_PPI_MODULE(QueueTester);
+ public:
+ connector::PassiveInput input;
+ connector::ActiveOutput output;
+
+ QueueTester() {
+ route(input, output);
+ input.qdisc(ppi::ThresholdQueueing(2,1));
+ input.onRequest(&QueueTester::nop);
+ }
+
+ void nop() {}
+
+ void forward() {
+ if (input && output)
+ output(input());
+ }
+
+ };
+}
+
+BOOST_AUTO_UNIT_TEST(thresholdQueueing)
+{
+ debug::ActivePacketSource source;
+ QueueTester tester;
+ debug::PassivePacketSink sink;
+
+ ppi::connect(source, tester);
+ ppi::connect(tester, sink);
+ ppi::init();
+
+ senf::Packet p (senf::DataPacket::create());
+ BOOST_CHECK( source );
+ source.submit(p);
+ BOOST_CHECK( source );
+ source.submit(p);
+ BOOST_CHECK( ! source );
+ BOOST_CHECK_EQUAL( tester.input.queueSize(), 2u );
+ tester.forward();
+ BOOST_CHECK_EQUAL( tester.input.queueSize(), 1u );
+ BOOST_CHECK( source );
+ tester.forward();
+ BOOST_CHECK_EQUAL( tester.input.queueSize(), 0u );
+ BOOST_CHECK( source );
+}
+
+///////////////////////////////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:
debug::ActivePacketSink activeSink;
RouteTester tester;
- ppi::connect(passiveSource.output, tester.activeIn);
- ppi::connect(activeSource.output, tester.passiveIn);
- ppi::connect(tester.activeOut, passiveSink.input);
- ppi::connect(tester.passiveOut, activeSink.input);
+ ppi::connect(passiveSource, tester.activeIn);
+ ppi::connect(activeSource, tester.passiveIn);
+ ppi::connect(tester.activeOut, passiveSink);
+ ppi::connect(tester.passiveOut, activeSink);
ppi::init();
/** \file
\brief Setup inline non-template implementation */
+//#include "Setup.ih"
+
// Custom includes
#include "Connectors.hh"
#include "ModuleManager.hh"
--- /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 Setup inline template implementation */
+
+//#include "Setup.ih"
+
+// Custom includes
+
+#define prefix_ inline
+///////////////////////////////cti.p///////////////////////////////////////
+
+template <class M, class C>
+prefix_ void
+senf::ppi::connect(M & source, C & target,
+ typename boost::enable_if< boost::is_base_of<module::Module, M> >::type *,
+ typename boost::enable_if< boost::is_base_of<connector::Connector, C> >::type *)
+{
+ connect(source.output, target);
+}
+
+template <class C, class M>
+prefix_ void
+senf::ppi::connect(C & source, M & target,
+ typename boost::enable_if< boost::is_base_of<connector::Connector, C> >::type *,
+ typename boost::enable_if< boost::is_base_of<module::Module, M> >::type *)
+{
+ connect(source, target.input);
+}
+
+template <class M1, class M2>
+prefix_ void
+senf::ppi::connect(M1 & source, M2 & target,
+ typename boost::enable_if< boost::is_base_of<module::Module, M1> >::type *,
+ typename boost::enable_if< boost::is_base_of<module::Module, M2> >::type *)
+{
+ connect(source.output, target.input);
+}
+
+///////////////////////////////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:
namespace senf {
namespace ppi {
-
+
void connect(connector::ActiveOutput & source, connector::PassiveInput & target);
void connect(connector::PassiveOutput & source, connector::ActiveInput & target);
+
+ template <class M, class C>
+ void connect(M & source, C & target,
+ typename boost::enable_if< boost::is_base_of<module::Module, M> >::type * = 0,
+ typename boost::enable_if< boost::is_base_of<connector::Connector, C> >::type * = 0);
+
+ template <class C, class M>
+ void connect(C & source, M & target,
+ typename boost::enable_if< boost::is_base_of<connector::Connector, C> >::type * = 0,
+ typename boost::enable_if< boost::is_base_of<module::Module, M> >::type * = 0);
+ template <class M1, class M2>
+ void connect(M1 & source, M2 & target,
+ typename boost::enable_if< boost::is_base_of<module::Module, M1> >::type * = 0,
+ typename boost::enable_if< boost::is_base_of<module::Module, M2> >::type * = 0);
+
void run();
void init();
///////////////////////////////hh.e////////////////////////////////////////
#include "Setup.cci"
//#include "Setup.ct"
-//#include "Setup.cti"
+#include "Setup.cti"
#endif
\f
inputSocket.blocking(false);
module::ActiveSocketReader<> udpReader(inputSocket);
debug::PassivePacketSink sink;
- ppi::connect(udpReader.output, sink.input);
+ ppi::connect(udpReader, sink);
std::string data ("TEST");
senf::UDPv4ClientSocketHandle outputSocket;
outputSocket.writeto(senf::INet4SocketAddress("localhost:44344"),data);
- senf::Scheduler::instance().timeout(1000, &timeout);
+ senf::Scheduler::instance().timeout(100, &timeout);
senf::ppi::run();
BOOST_REQUIRE( ! sink.empty() );
senf::INet4SocketAddress("localhost:44344"));
module::PassiveSocketWriter<> udpWriter(outputSocket);
debug::ActivePacketSource source;
- ppi::connect(source.output, udpWriter.input);
+ ppi::connect(source, udpWriter);
std::string data ("TEST");
senf::Packet p (senf::DataPacket::create(data));
senf::INet4SocketAddress("localhost:44344"));
module::ActiveSocketWriter<> udpWriter(outputSocket);
debug::PassivePacketSource source;
- ppi::connect(source.output, udpWriter.input);
+ ppi::connect(source, udpWriter);
std::string data ("TEST");
senf::Packet p (senf::DataPacket::create(data));