#define HH_SocketReader_ 1
// Custom includes
-#include "Packets/Packet.hh"
-#include "Packets/DataPacket.hh"
+#include "../Packets/Packets.hh"
+#include "../Socket/ClientSocketHandle.hh"
+#include "../Socket/SocketPolicy.hh"
+#include "../Socket/ReadWritePolicy.hh"
+#include "../Socket/FramingPolicy.hh"
#include "Module.hh"
-#include "Connector.hh"
+#include "Connectors.hh"
+#include "IOEvent.hh"
//#include "SocketReader.mpp"
///////////////////////////////hh.p////////////////////////////////////////
public:
typedef senf::ClientSocketHandle<
senf::MakeSocketPolicy< senf::ReadablePolicy,
- senf::DatagramFramingPolicy > > Handle;
+ senf::DatagramFramingPolicy >::policy > Handle;
///< Handle type supported by this reader
- Packet::ptr 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.
/** \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 Reader.
-
- The \a Reader must fulfill the following interface:
+ the \a Reader. The default reader is senf::ppi::PacketReader <> 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::PacketReader:
+ \code
+ senf::ppi::module::ActiveSocketReader< senf::ppi::PacketReader<senf::EthernetPacket> > reader;
+ \endcode
+ declares a \a reader module reading senf::EthrtnetPacket's.
+
+ A \a Reader must fulfill the following interface:
\code
- class SomeReader
- {
- public:
- typedef unspecified_type Handle; // type of handle requested
- SomeReader(); // default constructible
- Packet::ptr operator()(Handle handle); // extraction function
- };
+ class SomeReader
+ {
+ public:
+ typedef unspecified_type Handle; // type of handle requested
+ SomeReader(); // default constructible
+ Packet operator()(Handle handle); // extraction function
+ };
\endcode
+ Whenever the FileHandle object is ready for reading, the \a Reader's \c operator() is called
+ to read a packet.
+
+ \ingroup io_modules
*/
template <class Reader=PacketReader<> >
- class ActiveSocketReader : public Module
+ class ActiveSocketReader
+ : public Module
{
+ SENF_PPI_MODULE(ActiveSocketReader);
+
public:
typedef typename Reader::Handle Handle; ///< Handle type requested by the reader
/**< Data will be read from \a handle and be parsed by \a
Reader.
\param[in] handle Handle to read data from */
+
+ private:
+ void read();
+
+ Handle handle_;
+ IOEvent event_;
+ Reader reader_;
};
}}}
///////////////////////////////hh.e////////////////////////////////////////
//#include "SocketReader.cci"
-//#include "SocketReader.ct"
+#include "SocketReader.ct"
//#include "SocketReader.cti"
#endif