PPI: Started real Connectors.test.cc implementation
g0dil [Thu, 9 Aug 2007 15:28:53 +0000 (15:28 +0000)]
PPI: Add RateStuffer image to documentation

git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@387 270642c3-0616-0410-b53a-bc976706d245

PPI/Connectors.cci
PPI/Connectors.hh
PPI/Connectors.test.cc
PPI/Mainpage.dox
PPI/SConscript
PPI/ratestuffer.dia [new file with mode: 0644]

index 8d24f26..4b51a58 100644 (file)
@@ -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<ActiveInput&>(Connector::peer());
+    return dynamic_cast<PassiveInput&>(Connector::peer());
 }
 
 prefix_ void senf::ppi::connector::ActiveOutput::connect(PassiveInput & target)
index 553ff96..6ca4aa5 100644 (file)
@@ -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);
     };
index acf957f..694697b 100644 (file)
@@ -28,6 +28,8 @@
 
 // Custom includes
 #include "Connectors.hh"
+#include "DebugModules.hh"
+#include "Setup.hh"
 
 #include <boost/test/auto_unit_test.hpp>
 #include <boost/test/test_tools.hpp>
 #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_
index 5bac781..861decf 100644 (file)
 
     \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.
index 199c62d..cfc0e69 100644 (file)
@@ -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 (file)
index 0000000..5da96a0
Binary files /dev/null and b/PPI/ratestuffer.dia differ