From: g0dil Date: Thu, 9 Aug 2007 15:28:53 +0000 (+0000) Subject: PPI: Started real Connectors.test.cc implementation X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=b356790e396900fd46a677b39f4e182822bb5c1f;p=senf.git PPI: Started real Connectors.test.cc implementation PPI: Add RateStuffer image to documentation git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@387 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/PPI/Connectors.cci b/PPI/Connectors.cci index 8d24f26..4b51a58 100644 --- a/PPI/Connectors.cci +++ b/PPI/Connectors.cci @@ -215,9 +215,9 @@ prefix_ void senf::ppi::connector::ActiveInput::request() /////////////////////////////////////////////////////////////////////////// // senf::ppi::connector::ActiveOutput -prefix_ senf::ppi::connector::ActiveInput & senf::ppi::connector::ActiveOutput::peer() +prefix_ senf::ppi::connector::PassiveInput & senf::ppi::connector::ActiveOutput::peer() { - return dynamic_cast(Connector::peer()); + return dynamic_cast(Connector::peer()); } prefix_ void senf::ppi::connector::ActiveOutput::connect(PassiveInput & target) diff --git a/PPI/Connectors.hh b/PPI/Connectors.hh index 553ff96..6ca4aa5 100644 --- a/PPI/Connectors.hh +++ b/PPI/Connectors.hh @@ -125,9 +125,6 @@ namespace connector { void throttle(); ///< Set native throttling void unthrottle(); ///< Revoke native throttling - void notifyThrottle(); ///< Forward a throttling notification to this connector - void notifyUnthrottle(); ///< Forward an unthrottling notification to this connector - ActiveConnector & peer(); protected: @@ -136,9 +133,13 @@ namespace connector { void emit(); private: + void notifyThrottle(); ///< Forward a throttling notification to this connector + void notifyUnthrottle(); ///< Forward an unthrottling notification to this connector typedef detail::Callback<>::type Callback; Callback callback_; + + friend class ActiveConnector; }; /** \brief Active connector baseclass @@ -348,7 +349,7 @@ namespace connector { : public ActiveConnector, public OutputConnector { public: - ActiveInput & peer(); + PassiveInput & peer(); void connect(PassiveInput & target); }; diff --git a/PPI/Connectors.test.cc b/PPI/Connectors.test.cc index acf957f..694697b 100644 --- a/PPI/Connectors.test.cc +++ b/PPI/Connectors.test.cc @@ -28,6 +28,8 @@ // Custom includes #include "Connectors.hh" +#include "DebugModules.hh" +#include "Setup.hh" #include #include @@ -35,8 +37,49 @@ #define prefix_ ///////////////////////////////cc.p//////////////////////////////////////// -BOOST_AUTO_UNIT_TEST(connectors) -{} +namespace debug = senf::ppi::module::debug; +namespace ppi = senf::ppi; + +// For each type of connector we use the corresponding debug module. Additionally, we always need +// the corresponding connected module since otherwise the connectors cannot be connected anywhere +// and will be unusable. + +BOOST_AUTO_UNIT_TEST(connector) +{ + // It doesn't matter, which type of connectors we use here since they are all based on + // Connector. + + debug::ActivePacketSource source; + debug::PassivePacketSink target; + + ppi::connect(source.output,target.input); + + BOOST_CHECK_EQUAL( & source.output.module(), & source ); + BOOST_CHECK_EQUAL( & target.input.module(), & target ); + BOOST_CHECK_EQUAL( & source.output.peer(), & target.input ); + BOOST_CHECK_EQUAL( & target.input.peer(), & source.output ); +} + +BOOST_AUTO_UNIT_TEST(passiveConnector) +{ + debug::ActivePacketSource source; + debug::PassivePacketSink target; + + ppi::connect(source.output,target.input); + + // onRequest is implicitly tested within the PassivePacketSink implementation which is tested + // in DebugModules.test.cc + +#if 0 + target.input.throttle(); + BOOST_CHECK( target.input.throttled() ); + BOOST_CHECK( target.input.nativeThrottled() ); + + target.input.unthrottle(); + BOOST_CHECK( ! target.input.throttled() ); + BOOST_CHECK( ! target.input.nativeThrottled() ); +#endif +} ///////////////////////////////cc.e//////////////////////////////////////// #undef prefix_ diff --git a/PPI/Mainpage.dox b/PPI/Mainpage.dox index 5bac781..861decf 100644 --- a/PPI/Mainpage.dox +++ b/PPI/Mainpage.dox @@ -165,6 +165,8 @@ \section connections Connections + \image html ratestuffer.png Simple RateStuffer + To make use of the modules, they have to be instantiated and connections have to be created between the I/O connectors. It is possible to connect any pair of input/output connectors as long as one of them is active and the other is passive. diff --git a/PPI/SConscript b/PPI/SConscript index 199c62d..cfc0e69 100644 --- a/PPI/SConscript +++ b/PPI/SConscript @@ -17,4 +17,5 @@ SENFSCons.Lib(env, SENFSCons.Doxygen(env, extra_sources=[ env.Dia2Png('scenario.dia'), env.Dia2Png('classes.dia'), + env.Dia2Png('ratestuffer.dia'), ]) diff --git a/PPI/ratestuffer.dia b/PPI/ratestuffer.dia new file mode 100644 index 0000000..5da96a0 Binary files /dev/null and b/PPI/ratestuffer.dia differ