PPI: Add optional template arg for packet type to connectors
[senf.git] / Examples / RateStuffer / ratestuffer.cc
index 5217801..c9dbd89 100644 (file)
@@ -1,8 +1,8 @@
 // $Id$
 //
 // Copyright (C) 2007
-// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
-// Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
+// Fraunhofer Institute for Open Communication Systems (FOKUS) 
+// Competence Center NETwork research (NET), St. Augustin, GERMANY 
 //     Stefan Bund <g0dil@berlios.de>
 //
 // This program is free software; you can redistribute it and/or modify
 //#include "ppitest.ih"
 
 // Custom includes
-#include "../../Socket/Protocols/INet/UDPSocketHandle.hh"
-#include "../../Socket/Protocols/INet/ConnectedUDPSocketHandle.hh"
-#include "../../Socket/Protocols/INet/INetAddressing.hh"
-#include "../../PPI/SocketReader.hh"
-#include "../../PPI/SocketWriter.hh"
-#include "../../PPI/Module.hh"
-#include "../../PPI/IntervalTimer.hh"
-#include "../../PPI/Joins.hh"
-#include "../../PPI/ThrottleBarrier.hh"
-#include "../../PPI/PassiveQueue.hh"
-#include "../../PPI/Queueing.hh"
-#include "../../PPI/CloneSource.hh"
-#include "../../PPI/Setup.hh"
+#include <senf/Socket/Protocols/INet.hh>
+#include <senf/PPI.hh>
 
 //#include "ppitest.mpp"
 #define prefix_
@@ -58,8 +47,8 @@ class RateFilter
     SENF_PPI_MODULE(RateFilter);
 public:
 
-    connector::ActiveInput input;
-    connector::ActiveOutput output;
+    connector::ActiveInput<> input;
+    connector::ActiveOutput<> output;
 
     RateFilter(senf::ClockService::clock_type interval);
 
@@ -74,7 +63,7 @@ RateFilter::RateFilter(senf::ClockService::clock_type interval)
 {
     route(input,timer);
     route(timer,output);
-    registerEvent(&RateFilter::timeout, timer);
+    registerEvent(timer, &RateFilter::timeout);
 }
 
 void RateFilter::timeout()
@@ -93,8 +82,8 @@ class RateStuffer
     RateFilter              rateFilter;
 
 public:
-    connector::PassiveInput & input;
-    connector::ActiveOutput & output;
+    connector::PassiveInput<> & input;
+    connector::ActiveOutput<> & output;
 
     RateStuffer(senf::ClockService::clock_type interval, 
                 senf::Packet packet,
@@ -128,28 +117,28 @@ public:
 //                   +----------------------------------------------------+
 //                   | stuffer                                            |
 //                   |                                                    |
-// [ udpReader ] O-->:---> [ queue ] -->O [      ]                        |
-//                   |                    [ join ] -->O [ rateFilter] O-->:O--> [ udpWriter ]
+// [ udpSource ] O-->:---> [ queue ] -->O [      ]                        |
+//                   |                    [ join ] -->O [ rateFilter] O-->:O--> [ udpSink ]
 //                   | [ generator ] -->O [      ]                        |
 //                   |                                                    |
 //                   +----------------------------------------------------+
 
 int main(int argc, char * argv[])
 {
-    senf::UDPv4ClientSocketHandle inputSocket;
-    inputSocket.bind(senf::INet4SocketAddress("0.0.0.0:44344"));
+    senf::UDPv4ClientSocketHandle inputSocket(
+        senf::INet4SocketAddress("0.0.0.0:44344"));
 
     senf::ConnectedUDPv4ClientSocketHandle outputSocket(
         senf::INet4SocketAddress("localhost:44345"));
 
-    module::ActiveSocketReader<>  udpReader  ( inputSocket );
-    RateStuffer                   stuffer    ( 1000000000ul, 
-                                               senf::DataPacket::create(std::string("<idle>\n")),
-                                               2u, 1u );
-    module::PassiveSocketWriter<> udpWriter  ( outputSocket );
+    module::ActiveSocketSource<>  udpSource ( inputSocket );
+    RateStuffer                   stuffer   ( 1000000000ul, 
+                                              senf::DataPacket::create(std::string("<idle>\n")),
+                                              2u, 1u );
+    module::PassiveSocketSink<>   udpSink   ( outputSocket );
 
-    ppi::connect( udpReader, stuffer   );
-    ppi::connect( stuffer,   udpWriter );
+    ppi::connect( udpSource, stuffer   );
+    ppi::connect( stuffer,   udpSink );
 
     ppi::run();