Add doclib/fix-links.py to temporarily fix/remove bad doxygen links
[senf.git] / PPI / SocketWriter.hh
index 7c14c23..118273d 100644 (file)
 #define HH_SocketWriter_ 1
 
 // Custom includes
-#include "Packets/Packet.hh"
+#include "../Packets/Packets.hh"
+#include "../Socket/ClientSocketHandle.hh"
+#include "../Socket/SocketPolicy.hh"
+#include "../Socket/ReadWritePolicy.hh"
+#include "../Socket/FramingPolicy.hh"
+#include "../Socket/CommunicationPolicy.hh"
 #include "Module.hh"
-#include "Connector.hh"
+#include "Connectors.hh"
 
 //#include "SocketWriter.mpp"
 ///////////////////////////////hh.p////////////////////////////////////////
@@ -37,17 +42,18 @@ namespace ppi {
 
     /** \brief Write helper for module::ActiveSocketWriter / module::PassiveSocketWriter
         
-        This write helper will write the packets completely as datagrmas to the given socket.
+        This write helper will write the packets completely as datagrams to the given socket.
      */
     class PacketWriter
     {
     public:
         typedef senf::ClientSocketHandle<
             senf::MakeSocketPolicy< senf::WriteablePolicy,
-                                    senf::DatagramFramingPolicy > > Handle;
+                                    senf::DatagramFramingPolicy,
+                                    senf::ConnectedCommunicationPolicy>::policy > Handle;
                                         ///< Handle type supported by this writer
         
-        void operator()(Handle handle, Packet::ptr packet);
+        void operator()(Handle handle, Packet packet);
                                         ///< Write \a packet to \a handle
                                         /**< Write the complete \a packet as a datagram to \a
                                              handle.
@@ -67,28 +73,42 @@ namespace module {
         output module is active. This requires the file handle to be able to signal its readiness to
         accept more data via the Scheduler.
 
-        The \a Writer must fulfill the following interface:
+        The default \a Writer is senf::ppi::PacketWriter which will write out the complete packet to
+        the file handle.
+
+        A \a Writer must fulfill the following interface:
         \code
           class SomeWriter
           {
           public:
               typedef unspecified Handle;                          // type of handle requested
               SomeWriter();                                        // default constructible
-              void operator()(Handle handle, Packet::ptr packet);  // insertion function
+              void operator()(Handle handle, Packet packet);       // insertion function
           };
         \endcode
+        Whenever a packet is received for sending, the \a Writer's \c operator() is called.
+
+        \ingroup io_modules
      */
     template <class Writer=PacketWriter>
     class ActiveSocketWriter : public Module
     {
+        SENF_PPI_MODULE(ActiveSocketWriter);
+
     public:
-        typedef typename Writer:Handle Handle; ///< Handle type requested by writer
+        typedef typename Writer::Handle Handle; ///< Handle type requested by writer
 
         connector::ActiveInput input; ///< Input connector from which data is received
         
         ActiveSocketWriter(Handle handle); ///< Create new writer for the given handle
                                         /**< Data will be written to \a handle using \a Writer.
                                              \param[in] handle Handle to write data to */
+    private:
+        void write();
+
+        Handle handle_;
+        IOEvent event_;
+        Writer writer_;
     };
 
     /** \brief Output module writing data to arbitrary FileHandle
@@ -99,6 +119,9 @@ namespace module {
         mechanism. Either this is desired (like for a UDP socket) or some additional bandwidth
         shaping needs to be used.
 
+        The default \a Writer is senf::ppi::PacketWriter which will write out the complete packet to
+        the file handle.
+
         The \a Writer must fulfill the following interface:
         \code
           class SomeWriter
@@ -106,29 +129,40 @@ namespace module {
           public:
               typedef unspecified Handle;                          // type of handle requested
               SomeWriter();                                        // default constructible
-              void operator()(Handle handle, Packet::ptr packet);  // insertion function
+              void operator()(Handle handle, Packet packet);       // insertion function
           };
         \endcode
+        Whenever a packet is received for sending, the \a Writer's \c operator() is called.
+
+        \ingroup io_modules
      */
     template <class Writer=PacketWriter>
     class PassiveSocketWriter : public Module
     {
+        SENF_PPI_MODULE(PassiveSocketWriter);
+
     public:
-        typedef typename Writer:Handle Handle; ///< Handle type requested by writer
+        typedef typename Writer::Handle Handle; ///< Handle type requested by writer
 
         connector::PassiveInput input; ///< Input connector from which data is received
         
-        ActiveSocketWriter(Handle handle); ///< Create new writer for the given handle
+        PassiveSocketWriter(Handle handle); ///< Create new writer for the given handle
                                         /**< Data will be written to \a handle using \a Writer.
                                              \param[in] handle Handle to write data to */
+
+    private:
+        void write();
+
+        Handle handle_;
+        Writer writer_;
     };
 
 }}}
 
 
 ///////////////////////////////hh.e////////////////////////////////////////
-//#include "SocketWriter.cci"
-//#include "SocketWriter.ct"
+#include "SocketWriter.cci"
+#include "SocketWriter.ct"
 //#include "SocketWriter.cti"
 #endif
 
@@ -140,4 +174,5 @@ namespace module {
 // indent-tabs-mode: nil
 // ispell-local-dictionary: "american"
 // compile-command: "scons -u test"
+// comment-column: 40
 // End: