X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=senf%2FPPI%2FSocketSource.hh;h=185aadefc6d187f1cb595d23412bd548c8742467;hb=93d9568d448749dc187e7622b733a4a3caa319df;hp=ceb5bc83475e02cd76dd9694df8187e055345cba;hpb=601d1f509f5bb24df167a4dd5a20da67a0af9af8;p=senf.git diff --git a/senf/PPI/SocketSource.hh b/senf/PPI/SocketSource.hh index ceb5bc8..185aade 100644 --- a/senf/PPI/SocketSource.hh +++ b/senf/PPI/SocketSource.hh @@ -27,17 +27,17 @@ #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 +#include +#include +#include +#include #include "Module.hh" #include "Connectors.hh" #include "IOEvent.hh" //#include "SocketSource.mpp" -///////////////////////////////hh.p//////////////////////////////////////// +//-///////////////////////////////////////////////////////////////////////////////////////////////// namespace senf { namespace ppi { @@ -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 @@ -59,7 +59,7 @@ namespace ppi { senf::DatagramFramingPolicy >::policy > Handle; ///< Handle type supported by this reader - Packet operator()(Handle handle); + Packet operator()(Handle & handle); ///< Read packet from \a handle /**< Read a datagram from \a handle and interpret is as packet of type \c Packet. @@ -105,7 +105,7 @@ namespace module { \ingroup io_modules */ template > - class ActiveSocketSource + class ActiveSocketSource : public Module { SENF_PPI_MODULE(ActiveSocketSource); @@ -113,21 +113,22 @@ namespace module { public: typedef typename Reader::Handle Handle; ///< Handle type requested by the reader - connector::ActiveOutput output; + connector::ActiveOutput 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 */ explicit ActiveSocketSource(Reader reader); ///< Create non-connected reader /**< The reader will be disabled until a socket is set \pre Requires \a Reader to be copy constructible */ - explicit ActiveSocketSource(Handle handle); ///< Create new reader for the given handle + explicit ActiveSocketSource(Handle const & handle); + ///< Create new reader for the given handle /**< Data will be read from \a handle and be parsed by \a Reader. \pre Requires \a Reader to be default constructible \param[in] handle Handle to read data from */ - ActiveSocketSource(Handle handle, Reader reader); + ActiveSocketSource(Handle const & handle, Reader reader); ///< Create new reader for the given handle /**< Data will be read from \a handle and be parsed by \a Reader. @@ -136,21 +137,58 @@ namespace module { Reader & reader(); ///< Access Reader helper Handle handle(); ///< Access handle - void handle(Handle handle); ///< Set handle + void handle(Handle const & 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 ActiveBurstSocketSource + : public Module + { + SENF_PPI_MODULE(ActiveBurstSocketSource); + + public: + typedef typename Reader::Handle Handle; ///< Handle type requested by the reader + + connector::ActiveOutput output; + ///< Output connector to which the data received is written + + ActiveBurstSocketSource(unsigned max_burst=0); + explicit ActiveBurstSocketSource(Reader reader, unsigned max_burst=0); + explicit ActiveBurstSocketSource(Handle const & handle, unsigned max_burst=0); + ActiveBurstSocketSource(Handle const & handle, Reader reader, unsigned max_burst=0); + + Reader & reader(); ///< Access Reader helper + Handle handle(); ///< Access handle + void handle(Handle const & 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(); }; }}} -///////////////////////////////hh.e//////////////////////////////////////// +//-///////////////////////////////////////////////////////////////////////////////////////////////// //#include "SocketSource.cci" #include "SocketSource.ct" #include "SocketSource.cti"