From: g0dil Date: Thu, 22 Jan 2009 12:19:24 +0000 (+0000) Subject: PPI: Rename ActiveSplitter to ActiveDuplicatorPPI: Add / fix documentation X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=bf762ee0cef226cad371646bfdec8b286866d84c;p=senf.git PPI: Rename ActiveSplitter to ActiveDuplicatorPPI: Add / fix documentation git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1071 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/PPI/AnnotationRouter.hh b/PPI/AnnotationRouter.hh index 19b8332..1051ae1 100644 --- a/PPI/AnnotationRouter.hh +++ b/PPI/AnnotationRouter.hh @@ -75,7 +75,7 @@ namespace module { mac address and allows to pass a senf::MACAddress value as routing key directly: \code - senf::ppi::module::AnnotationRouter router; + senf::ppi::module::AnnotationRouter router; senf::ppi::connect(router, target1, senf::MACAddress::from_string("00:1a:2b:04:06:08")); \endcode diff --git a/PPI/Doxyfile b/PPI/Doxyfile index e679a57..cf2dd5f 100644 --- a/PPI/Doxyfile +++ b/PPI/Doxyfile @@ -2,9 +2,9 @@ PROJECT_NAME = libPPI GENERATE_TAGFILE = doc/PPI.tag -RECURSIVE = Yes +RECURSIVE = No SHOW_DIRECTORIES = Yes -EXCLUDE = NetEmu +INPUT = . detail TAGFILES = \ "$(TOPDIR)/Scheduler/doc/Scheduler.tag" \ diff --git a/PPI/Splitters.cc b/PPI/Duplicators.cc similarity index 85% rename from PPI/Splitters.cc rename to PPI/Duplicators.cc index 8e3cce3..f62679d 100644 --- a/PPI/Splitters.cc +++ b/PPI/Duplicators.cc @@ -21,19 +21,19 @@ // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /** \file - \brief Splitters non-inline non-template implementation */ + \brief Duplicators non-inline non-template implementation */ -#include "Splitters.hh" -//#include "Splitters.ih" +#include "Duplicators.hh" +//#include "Duplicators.ih" // Custom includes -//#include "Splitters.mpp" +//#include "Duplicators.mpp" #define prefix_ ///////////////////////////////cc.p//////////////////////////////////////// prefix_ senf::ppi::connector::ActiveOutput<> & -senf::ppi::module::ActiveSplitter::newOutput() +senf::ppi::module::ActiveDuplicator::newOutput() { outputs_.push_back(new connector::ActiveOutput<>()); connector::ActiveOutput<> & output (outputs_.back()); @@ -43,7 +43,7 @@ senf::ppi::module::ActiveSplitter::newOutput() return output; } -prefix_ void senf::ppi::module::ActiveSplitter::request() +prefix_ void senf::ppi::module::ActiveDuplicator::request() { Packet p (input()); Outputs::iterator i (outputs_.begin()); @@ -54,7 +54,7 @@ prefix_ void senf::ppi::module::ActiveSplitter::request() ///////////////////////////////cc.e//////////////////////////////////////// #undef prefix_ -//#include "Splitters.mpp" +//#include "Duplicators.mpp" // Local Variables: diff --git a/PPI/Splitters.cci b/PPI/Duplicators.cci similarity index 85% rename from PPI/Splitters.cci rename to PPI/Duplicators.cci index 7d47333..f57c2f6 100644 --- a/PPI/Splitters.cci +++ b/PPI/Duplicators.cci @@ -21,9 +21,9 @@ // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /** \file - \brief Splitters inline non-template implementation */ + \brief Duplicators inline non-template implementation */ -//#include "Splitters.ih" +//#include "Duplicators.ih" // Custom includes @@ -31,12 +31,12 @@ ///////////////////////////////cci.p/////////////////////////////////////// /////////////////////////////////////////////////////////////////////////// -// senf::ppi::module::ActiveSplitter +// senf::ppi::module::ActiveDuplicator -prefix_ senf::ppi::module::ActiveSplitter::ActiveSplitter() +prefix_ senf::ppi::module::ActiveDuplicator::ActiveDuplicator() { noroute(input); - input.onRequest(&ActiveSplitter::request); + input.onRequest(&ActiveDuplicator::request); } ///////////////////////////////cci.e/////////////////////////////////////// diff --git a/PPI/Splitters.cti b/PPI/Duplicators.cti similarity index 88% rename from PPI/Splitters.cti rename to PPI/Duplicators.cti index d96f3ec..fb9e74f 100644 --- a/PPI/Splitters.cti +++ b/PPI/Duplicators.cti @@ -21,9 +21,9 @@ // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /** \file - \brief Splitters inline template implementation */ + \brief Duplicators inline template implementation */ -//#include "Splitters.ih" +//#include "Duplicators.ih" // Custom includes #include "Setup.hh" @@ -33,14 +33,14 @@ template prefix_ senf::ppi::connector::GenericActiveOutput & -senf::ppi::connect(module::ActiveSplitter & source, Target & target) +senf::ppi::connect(module::ActiveDuplicator & source, Target & target) { return source.connect(target); } template prefix_ senf::ppi::connector::GenericActiveOutput & -senf::ppi::module::ActiveSplitter::connect(Target & target) +senf::ppi::module::ActiveDuplicator::connect(Target & target) { connector::GenericActiveOutput & output (newOutput()); ppi::connect(output, target); diff --git a/PPI/Splitters.hh b/PPI/Duplicators.hh similarity index 63% rename from PPI/Splitters.hh rename to PPI/Duplicators.hh index 670296c..f5ea389 100644 --- a/PPI/Splitters.hh +++ b/PPI/Duplicators.hh @@ -21,10 +21,10 @@ // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /** \file - \brief Splitters public header */ + \brief Duplicators public header */ -#ifndef HH_SENF_PPI_Splitters_ -#define HH_SENF_PPI_Splitters_ 1 +#ifndef HH_SENF_PPI_Duplicators_ +#define HH_SENF_PPI_Duplicators_ 1 // Custom includes #include @@ -32,7 +32,7 @@ #include "Connectors.hh" #include "Module.hh" -//#include "Splitters.mpp" +//#include "Duplicators.mpp" ///////////////////////////////hh.p//////////////////////////////////////// namespace senf { @@ -41,20 +41,37 @@ namespace ppi { #ifndef DOXYGEN template - connector::GenericActiveOutput & connect(module::ActiveSplitter & source, Target & target); + connector::GenericActiveOutput & connect(module::ActiveDuplicator & source, Target & target); #endif namespace module { - class ActiveSplitter + /** \brief Copy every incoming packet to each output + + ActiveDuplicator will take every received packet and push it out to each connected output. + + Since ActiveDuplicator allows any number of incoming packet streams, the input connectors + are dynamically managed. A special senf::ppi::connect() overload is used to dynamically + create the needed input connectors. This hides this extra functionality from the user. + \code + senf::ppi::module::ActiveDuplicator dup; + + senf::ppi::connect(sourceModule, dup); + senf::ppi::connect(dup, targetModule1); + senf::ppi::connect(dup, targetModule2.some_input); + \endcode + + \ingroup routing_modules + */ + class ActiveDuplicator : public Module { - SENF_PPI_MODULE(ActiveSplitter); + SENF_PPI_MODULE(ActiveDuplicator); public: connector::PassiveInput<> input; - ActiveSplitter(); + ActiveDuplicator(); private: connector::ActiveOutput<> & newOutput(); @@ -77,9 +94,9 @@ namespace module { ///////////////////////////////hh.e//////////////////////////////////////// -#include "Splitters.cci" -//#include "Splitters.ct" -#include "Splitters.cti" +#include "Duplicators.cci" +//#include "Duplicators.ct" +#include "Duplicators.cti" #endif diff --git a/PPI/Splitters.test.cc b/PPI/Duplicators.test.cc similarity index 85% rename from PPI/Splitters.test.cc rename to PPI/Duplicators.test.cc index 9d55191..4cfd740 100644 --- a/PPI/Splitters.test.cc +++ b/PPI/Duplicators.test.cc @@ -21,13 +21,13 @@ // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /** \file - \brief Splitters.test unit tests */ + \brief Duplicators.test unit tests */ -//#include "Splitters.test.hh" -//#include "Splitters.test.ih" +//#include "Duplicators.test.hh" +//#include "Duplicators.test.ih" // Custom includes -#include "Splitters.hh" +#include "Duplicators.hh" #include "DebugModules.hh" #include "Setup.hh" #include "../Packets/Packets.hh" @@ -43,16 +43,16 @@ namespace connector = ppi::connector; namespace module = ppi::module; namespace debug = module::debug; -BOOST_AUTO_UNIT_TEST(activeSplitter) +BOOST_AUTO_UNIT_TEST(activeDuplicator) { debug::ActiveSource source; - module::ActiveSplitter splitter; + module::ActiveDuplicator duplicator; debug::PassiveSink sink1; debug::PassiveSink sink2; - ppi::connect(source, splitter); - ppi::connect(splitter, sink1); - ppi::connect(splitter, sink2); + ppi::connect(source, duplicator); + ppi::connect(duplicator, sink1); + ppi::connect(duplicator, sink2); ppi::init(); senf::Packet p (senf::DataPacket::create()); diff --git a/PPI/Module.hh b/PPI/Module.hh index 97f1c11..b2b3ecd 100644 --- a/PPI/Module.hh +++ b/PPI/Module.hh @@ -61,8 +61,6 @@ namespace module { \li \ref io_modules receive external data or forward packets out of the PPI \li \ref routing_modules forward packets within the network \li \ref adapter_modules are used to connect incompatible connectors to each other - - \todo Implement Spliters: PassiveSplitter, PrioritySplitter, CloneSplitter */ /** \defgroup io_modules Source/Sink Modules diff --git a/PPI/MonitorModule.hh b/PPI/MonitorModule.hh index 30c8ff1..d9ca8ae 100644 --- a/PPI/MonitorModule.hh +++ b/PPI/MonitorModule.hh @@ -37,6 +37,40 @@ namespace senf { namespace ppi { namespace module { + /** \brief Base class providing simple monitor module support + + A monitor module is a module which needs information about traversing packets but does not + really act on the packets. Because of this, it is \e optional to connect the output: If the + output is not connected, the packets will be silently dropped. + + This allows to add monitor modules either into an existing chain or add them using an + ActiveDuplicator. + + To write a monitor module, derive from senf::ppi::module::MonitorModule instead of + senf::ppi::module and implement v_handlePacket(): + + \code + class CountPackets + : public senf::ppi::module::MonitorModule<> + { + SENF_PPI_MODULE(CountPackets); + public: + SomeMonitor() : counter_ (0u) {} + + private: + virtual void v_handlePacket(Packet const & p) + { ++ counter_; } + + unsigned counter_; + }; + \endcode + + You may of course add events (or even further connectors besides \c input and \c output + provided by MonitorModule) to the module. + + \tparam PacketType type of packet expected on input and sent on output. This is also the + type of the v_handlePacket() argument. + */ template class MonitorModule : public Module { @@ -47,7 +81,7 @@ namespace module { protected: MonitorModule(); - virtual void v_handlePacket(PacketType const & p) = 0; + virtual void v_handlePacket(PacketType const & p) = 0; ///< Called for each packet private: void request(); diff --git a/PPI/predecl.hh b/PPI/predecl.hh index af96ceb..81094eb 100644 --- a/PPI/predecl.hh +++ b/PPI/predecl.hh @@ -72,7 +72,7 @@ namespace ppi { } class PassiveJoin; class PriorityJoin; - class ActiveSplitter; + class ActiveDuplicator; } namespace connector {