Changed to colour every module ending with Source or Sink red
[senf.git] / senf / PPI / SocketSource.hh
index ceb5bc8..c41e314 100644 (file)
 #define HH_SENF_PPI_SocketSource_ 1
 
 // Custom includes
-#include "../Packets/Packets.hh"
-#include "../Socket/ClientSocketHandle.hh"
-#include "../Socket/SocketPolicy.hh"
-#include "../Socket/ReadWritePolicy.hh"
-#include "../Socket/FramingPolicy.hh"
+#include <senf/Packets/Packets.hh>
+#include <senf/Socket/ClientSocketHandle.hh>
+#include <senf/Socket/SocketPolicy.hh>
+#include <senf/Socket/ReadWritePolicy.hh>
+#include <senf/Socket/FramingPolicy.hh>
 #include "Module.hh"
 #include "Connectors.hh"
 #include "IOEvent.hh"
@@ -46,7 +46,7 @@ namespace ppi {
 
         This read helper will read a datagram from a datagram socket. This datagram will then be
         interpreted as a packet of type \a Packet as defined in the packet library. \a Packet
-        defaults to DataPacket (type DataPacketType), which will place the data uninterpreted 
+        defaults to DataPacket (type DataPacketType), which will place the data uninterpreted
         into a packet data structure.
      */
     template <class Packet=DataPacket, unsigned MaxSize=0u>
@@ -105,7 +105,7 @@ namespace module {
         \ingroup io_modules
      */
     template <class Reader=DgramReader<> >
-    class ActiveSocketSource 
+    class ActiveSocketSource
         : public Module
     {
         SENF_PPI_MODULE(ActiveSocketSource);
@@ -113,9 +113,9 @@ namespace module {
     public:
         typedef typename Reader::Handle Handle; ///< Handle type requested by the reader
 
-        connector::ActiveOutput<typename Reader::PacketType> output; 
+        connector::ActiveOutput<typename Reader::PacketType> output;
                                         ///< Output connector to which the data received is written
-        
+
         ActiveSocketSource();           ///< Create non-connected reader
                                         /**< The reader will be disabled until a socket is set
                                              \pre Requires \a Reader to be default constructible */
@@ -139,13 +139,48 @@ namespace module {
         void handle(Handle handle);     ///< Set handle
                                         /**< Assigning an empty or in-valid() handle will disable
                                              the module until a new, valid handle is assigned. */
-        
     private:
+        Handle handle_;
+        IOEvent event_;
+        Reader reader_;
+
         void read();
-        
+    };
+
+
+    template <class Reader=DgramReader<> >
+    class ActiveBurstSocketSource
+        : public Module
+    {
+        SENF_PPI_MODULE(ActiveBurstSocketSource);
+
+    public:
+        typedef typename Reader::Handle Handle; ///< Handle type requested by the reader
+
+        connector::ActiveOutput<typename Reader::PacketType> output;
+                                        ///< Output connector to which the data received is written
+
+        ActiveBurstSocketSource(unsigned max_burst);
+        explicit ActiveBurstSocketSource(Reader reader, unsigned max_burst);
+        explicit ActiveBurstSocketSource(Handle handle, unsigned max_burst);
+        ActiveBurstSocketSource(Handle handle, Reader reader, unsigned max_burst);
+
+        Reader & reader();              ///< Access Reader helper
+        Handle handle();                ///< Access handle
+        void handle(Handle handle);     ///< Set handle
+                                        /**< Assigning an empty or in-valid() handle will disable
+                                             the module until a new, valid handle is assigned. */
+
+        unsigned maxBurst() const;
+        void maxBurst(unsigned max_burst);
+
+    private:
         Handle handle_;
         IOEvent event_;
         Reader reader_;
+        unsigned maxBurst_;
+
+        void read();
     };
 
 }}}