X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=PPI%2FSocketSource.hh;h=f3bb6b49e05d9fcf21872f89e4fcdb9ce3f84687;hb=66293acca094b2f29e26e70208691db4af274efb;hp=92c0cda891c566690a863be15e622acefebd71b5;hpb=a479735a65e334af538b895f182f8efd36a541c5;p=senf.git diff --git a/PPI/SocketSource.hh b/PPI/SocketSource.hh index 92c0cda..f3bb6b4 100644 --- a/PPI/SocketSource.hh +++ b/PPI/SocketSource.hh @@ -1,6 +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 // // This program is free software; you can redistribute it and/or modify @@ -40,15 +42,15 @@ namespace senf { namespace ppi { - /** \brief Read helper for module::ActiveSocketSource + /** \brief Reader for module::ActiveSocketSource 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 \ref DataPacket, which will place the data uninterpreted into a packet data - structure. + defaults to DataPacket (type DataPacketType), which will place the data uninterpreted + into a packet data structure. */ template - class PacketSource + class DgramReader { public: typedef senf::ClientSocketHandle< @@ -74,51 +76,63 @@ namespace module { /** \brief Input module reading data from an arbitrary FileHandle This input module will read data from a FileHandle object and parse the data according to - the \a Source. The default reader is senf::ppi::PacketSource <> which reads the data into a + the \a Reader. The default reader is senf::ppi::DgramReader <> which reads the data into a senf::DataPacket. To parse the data according to some other packet type, pass that packet - type to senf::ppi::PacketSource: + type to senf::ppi::DgramReader: \code - senf::ppi::module::ActiveSocketSource< senf::ppi::PacketSource > reader; + senf::ppi::module::ActiveSocketSource< senf::ppi::DgramReader > source; \endcode - declares a \a reader module reading senf::EthrtnetPacket's. + declares a \a reader module reading senf::EthernetPacket's - A \a Source must fulfill the following interface: + A \a Reader must fulfill the following interface: \code - class SomeSource + class SomeReader { public: - typedef unspecified_type Handle; // type of handle requested - SomeSource(); // default constructible - Packet operator()(Handle handle); // extraction function + typedef unspecified_type Handle; // type of handle requested + + SomeReader(); // EITHER default constructible + SomeReader(SomeReader const & other); // OR copy constructible + + Packet operator()(Handle handle); // extraction function }; \endcode - Whenever the FileHandle object is ready for reading, the \a Source's \c operator() is called + Whenever the FileHandle object is ready for reading, the \a Reader's \c operator() is called to read a packet. \ingroup io_modules */ - template > + template > class ActiveSocketSource : public Module { SENF_PPI_MODULE(ActiveSocketSource); public: - typedef typename Source::Handle Handle; ///< Handle type requested by the reader + 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 /**< Data will be read from \a handle and be parsed by \a - Source. + Reader. + \pre Requires \a Reader to be default constructible + \param[in] handle Handle to read data from */ + ActiveSocketSource(Handle handle, Reader reader); + ///< 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 copy constructible \param[in] handle Handle to read data from */ + Reader & reader(); ///< Access Reader helper + private: void read(); Handle handle_; IOEvent event_; - Source reader_; + Reader reader_; }; }}} @@ -126,7 +140,7 @@ namespace module { ///////////////////////////////hh.e//////////////////////////////////////// //#include "SocketSource.cci" #include "SocketSource.ct" -//#include "SocketSource.cti" +#include "SocketSource.cti" #endif