X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=PPI%2FSocketSource.hh;h=3c78d5851fc9b74b1dc29a7b9d4245cb7d8a848a;hb=b8ca4a544cce3e6023bb56b712a03d6362f2bb79;hp=e0b6b7e417e38762b416c0ad84de122912a0e931;hpb=19457dfb4c2d5df32f7dcdcb911bd26963ba91b2;p=senf.git diff --git a/PPI/SocketSource.hh b/PPI/SocketSource.hh index e0b6b7e..3c78d58 100644 --- a/PPI/SocketSource.hh +++ b/PPI/SocketSource.hh @@ -1,8 +1,8 @@ // $Id$ // -// Copyright (C) 2007 -// Fraunhofer Institute for Open Communication Systems (FOKUS) -// Competence Center NETwork research (NET), St. Augustin, GERMANY +// Copyright (C) 2007 +// Fraunhofer Institute for Open Communication Systems (FOKUS) +// Competence Center NETwork research (NET), St. Augustin, GERMANY // Stefan Bund // // This program is free software; you can redistribute it and/or modify @@ -23,8 +23,8 @@ /** \file \brief SocketSource public header */ -#ifndef HH_SocketSource_ -#define HH_SocketSource_ 1 +#ifndef HH_SENF_PPI_SocketSource_ +#define HH_SENF_PPI_SocketSource_ 1 // Custom includes #include "../Packets/Packets.hh" @@ -53,6 +53,7 @@ namespace ppi { class DgramReader { public: + typedef Packet PacketType; typedef senf::ClientSocketHandle< senf::MakeSocketPolicy< senf::ReadablePolicy, senf::DatagramFramingPolicy >::policy > Handle; @@ -90,11 +91,12 @@ namespace module { { public: typedef unspecified_type Handle; // type of handle requested + typedef unspecified_type PacketType // type of packet returned SomeReader(); // EITHER default constructible SomeReader(SomeReader const & other); // OR copy constructible - Packet operator()(Handle handle); // extraction function + PacketType operator()(Handle handle); // extraction function }; \endcode Whenever the FileHandle object is ready for reading, the \a Reader's \c operator() is called @@ -111,9 +113,16 @@ namespace module { public: typedef typename Reader::Handle Handle; ///< Handle type requested by the reader - connector::ActiveOutput output; ///< Output connector to which the data received is written + connector::ActiveOutput output; + ///< Output connector to which the data received is written - ActiveSocketSource(Handle handle); ///< Create new reader for the given handle + 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 /**< Data will be read from \a handle and be parsed by \a Reader. \pre Requires \a Reader to be default constructible @@ -126,6 +135,10 @@ namespace module { \param[in] handle Handle to read data from */ 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. */ private: void read();