Merged revisions 570-572,574-575,578-579,581-595,598-611 via svnmerge from
[senf.git] / Socket / ClientSocketHandle.hh
index 368e3cd..6150e28 100644 (file)
@@ -1,9 +1,9 @@
 // $Id$
 //
 // Copyright (C) 2006
-// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
-// Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
-//     Stefan Bund <stefan.bund@fokus.fraunhofer.de>
+// Fraunhofer Institute for Open Communication Systems (FOKUS) 
+// Competence Center NETwork research (NET), St. Augustin, GERMANY 
+//     Stefan Bund <g0dil@berlios.de>
 //
 // This program is free software; you can redistribute it and/or modify
 // it under the terms of the GNU General Public License as published by
@@ -30,6 +30,8 @@
 // Custom includes
 #include <boost/call_traits.hpp>
 #include <boost/range.hpp>
+#include <boost/utility.hpp>
+#include <boost/type_traits.hpp>
 #include "SocketHandle.hh"
 
 //#include "ClientSocketHandle.mpp"
@@ -46,20 +48,21 @@ namespace senf {
 
         This class provides the client side policy interface of the socket
         abstraction. ClientSocketHandle defines the complete policy interface. It does not implement
-        any functionality itself however. All calls are forward to the following policy classes:
+        any functionality itself however. The following table shows, to which policy members each
+        group of ClientSocketHandle members is forwardd. The last collumn shows, on which other
+        policies this member-group depends <em>in the default policy classes</em>. If you define
+        your own policy classes, the dependencies are up to you.
 
         <table class="senf">
-        <tr><th>ClientSocketHandle member</th> <th>Policy member</th></tr>
-        <tr><td>read()</td>       <td>ReadPolicy::read (\ref senf::ReadPolicyBase)</td></tr>
-        <tr><td>readfrom()</td>   <td>ReadPolicy::readfrom (\ref senf::ReadPolicyBase)</td></tr>
-        <tr><td>write()</td>      <td>WritePolicy::write (\ref senf::WritePolicyBase)</td></tr>
-        <tr><td>writeto()</td>    <td>WritePolicy::writeto (\ref senf::WritePolicyBase)</td></tr>
-        <tr><td>connect()</td>    <td>AddressingPolicy::connect (\ref senf::AddressingPolicyBase)</td></tr>
-        <tr><td>bind()</td>       <td>AddressingPolicy::bind (\ref senf::AddressingPolicyBase)</td></tr>
-        <tr><td>peer()</td>       <td>AddressingPolicy::peer (\ref senf::AddressingPolicyBase)</td></tr>
-        <tr><td>local()</td>      <td>AddressingPolicy::local (\ref senf::AddressingPolicyBase)</td></tr>
-        <tr><td>rcvbuf()</td>     <td>BufferingPolicy::sndbuf (\ref senf::BufferingPolicyBase)</td></tr>
-        <tr><td>sndbuf()</td>     <td>BufferingPolicy::rcvbuf (\ref senf::BufferingPolicyBase)</td></tr>
+        <tr><th>ClientSocketHandle member</th> <th>Policy member</th> <th>Other policies</th></tr>
+        <tr><td>read()</td>       <td>ReadPolicy::read (\ref senf::ReadPolicyBase)</td>                  <td></td></tr>
+        <tr><td>readfrom()</td>   <td>ReadPolicy::readfrom (\ref senf::ReadPolicyBase)</td>              <td>UnconnectedCommunicationPolicy</td></tr>
+        <tr><td>write()</td>      <td>WritePolicy::write (\ref senf::WritePolicyBase)</td>               <td>ConnectedCommunicationPolicy</td></tr>
+        <tr><td>writeto()</td>    <td>WritePolicy::writeto (\ref senf::WritePolicyBase)</td>             <td>UnconnectedCommunicationPolicy</td></tr>
+        <tr><td>connect()</td>    <td>AddressingPolicy::connect (\ref senf::AddressingPolicyBase)</td>   <td></td></tr>
+        <tr><td>bind()</td>       <td>AddressingPolicy::bind (\ref senf::AddressingPolicyBase)</td>      <td></td></tr>
+        <tr><td>peer()</td>       <td>AddressingPolicy::peer (\ref senf::AddressingPolicyBase)</td>      <td></td></tr>
+        <tr><td>local()</td>      <td>AddressingPolicy::local (\ref senf::AddressingPolicyBase)</td>     <td></td></tr>
         </table>
 
         It is important to note, that not all members are always accessible. Which are depends on
@@ -79,13 +82,6 @@ namespace senf {
         typelist of Poclicy classes which can be accessed. You use protocol<ProtocolClass>() to
         access a protocol class. \c Policies can of course be underspecified or even empty.
 
-        \idea add more flexible read/write members for a) boost::arrays and arrays of other types b)
-        std::vector (which uses contiguous memory ..) c) other random-access containers (we should
-        use some configurable trait class to identify containers with contiguous storage). Probably
-        we should just use a generic Boost.Range interface. Here we again come to the point: make
-        all except the most basic members be non-member algorithms ? this would make the
-        configuration of such extenden members more flexible.
-
         \see \ref policy_group \n
              \ref protocol_group
       */
@@ -116,19 +112,31 @@ namespace senf {
         ///\name Structors and default members
         ///@{
 
-        // no default constructor
+        // default default constructor
         // default copy constructor
         // default copy assignment
         // default destructor
 
+        // here to implement
+        ClientSocketHandle();
+
         // conversion constructors
+#       ifndef DOXYGEN
         template <class OtherPolicy>
         ClientSocketHandle(ClientSocketHandle<OtherPolicy> other,
                            typename SocketHandle<Policy>::template IsCompatible<OtherPolicy>::type * = 0);
+#       else
+        ClientSocketHandle(ClientSocketHandle<OtherPolicy> other);
+#       endif
 
+#       ifndef DOXYGEN
         template <class OtherPolicy>
         typename SocketHandle<Policy>::template IsCompatible<OtherPolicy>::type const &
         operator=(ClientSocketHandle<OtherPolicy> other);
+#       else
+        template <class OtherPolicy>
+        OtherPolicy const & operator=(ClientSocketHandle<OtherPolicy> other);
+#       endif        
 
         ///@}
         ///////////////////////////////////////////////////////////////////////////
@@ -169,6 +177,11 @@ namespace senf {
         */
         std::string  read         (unsigned limit=0);
         template <class ForwardWritableRange>
+#       ifndef DOXYGEN
+        typename boost::range_iterator<ForwardWritableRange>::type
+                     read         (ForwardWritableRange const & range,
+                                   typename boost::disable_if< boost::is_convertible<ForwardWritableRange,unsigned> >::type * = 0);
+#       else
         typename boost::range_iterator<ForwardWritableRange>::type
                      read         (ForwardWritableRange const & range);
                                         ///< Read data into range
@@ -178,17 +191,26 @@ namespace senf {
                                              range. read returns a past-the-end iterator after the
                                              last character read. This iterator will point to
                                              somewhere within the input range.
-                                             \param[in/out] range Range to store data in 
+                                             \param[in,out] range Range to store data in 
                                              \returns past-the-end iterator pointer to after the
                                                  last read character 
-                                             \see \ref read() */
+                                             \see \ref read() \n
+                                                  <a href="http://www.boost.org/libs/range/index.html">Boost.Range</a> */
+#       endif
+#       ifndef DOXYGEN
+        template <class ForwardWritableRange>
+        typename boost::range_iterator<ForwardWritableRange>::type
+                     read         (ForwardWritableRange & range,
+                                   typename boost::disable_if< boost::is_convertible<ForwardWritableRange,unsigned> >::type * = 0);
+#       else
         template <class ForwardWritableRange>
         typename boost::range_iterator<ForwardWritableRange>::type
                      read         (ForwardWritableRange & range);
                                         ///< Read data into range
-                                        /**< \see 
-                                             read(ForwardWritableRange const &) \n
-                                             read() */
+                                        /**< \see read(ForwardWritableRange const &) \n
+                                                  read() \n
+                                                  <a href="http://www.boost.org/libs/range/index.html">Boost.Range</a>  */
+#       endif
         template <class Sequence>
         void         read         (Sequence & container, unsigned limit);
                                         ///< Read data into container
@@ -238,19 +260,20 @@ namespace senf {
                                              range. read returns a past-the-end iterator after the
                                              last character read. This iterator will point to
                                              somewhere within the input range.
-                                             \param[in/out] range Range to store data in 
+                                             \param[in,out] range Range to store data in 
                                              \param[out] from peers address from which the data was
                                                  received
                                              \returns past-the-end iterator pointer to after the
                                                  last read character 
-                                             \see \ref readfrom() */
+                                             \see \ref readfrom() \n
+                                                  <a href="http://www.boost.org/libs/range/index.html">Boost.Range</a>  */
         template <class ForwardWritableRange>
         typename boost::range_iterator<ForwardWritableRange>::type
                      readfrom     (ForwardWritableRange & range, Address & from);
                                         ///< Read data into range
-                                        /**< \see 
-                                             readfrom(ForwardWritableRange const&,Address&) \n
-                                             readfrom() */
+                                        /**< \see readfrom(ForwardWritableRange const&,Address&) \n
+                                                  readfrom()  \n
+                                                  <a href="http://www.boost.org/libs/range/index.html">Boost.Range</a> */
         template <class Sequence>
         void         readfrom     (Sequence & container, Address & from, unsigned limit);
                                         ///< Read data into container
@@ -265,14 +288,15 @@ namespace senf {
                                              \see \ref readfrom() */
         char *       readfrom     (char * start, char * end, Address & from);
                                         ///< Read data into memory buffer
-                                        /**< This variant will read data into the memory area at \c
-                                           buffer of size \c size. This is the most performant
-                                           version of readfrom().
-                                           \param[in] buffer address of buffer to store data at
-                                           \param[in] size size of buffer
-                                           \param[out] from peer address
-                                           \returns Number of bytes read
-                                           \see \ref readfrom() */
+                                        /**< This variant will read data into the memory area from
+                                             \a start to before \a end. This is guaranteed to be the
+                                             most efficient version  of readfrom().
+                                             \param[in] start address of buffer to store data at
+                                             \param[in] end address one past the end of the buffer
+                                             \param[out] from peers address from which the data was
+                                                 received
+                                             \returns pointer past the end of the data read
+                                             \see \ref read() */
 
 
         /** \brief Write data to socket
@@ -303,7 +327,8 @@ namespace senf {
                                         /**< \param[in] start beginning of area to write
                                              \param[in] end past-the-end pointer to area to write
                                              \returns past-the-end pointer after last byte written
-                                             \see \ref write() */
+                                             \see \ref write() \n
+                                                  <a href="http://www.boost.org/libs/range/index.html">Boost.Range</a>  */
 
         /** \brief Write data to unconnected socket
 
@@ -332,7 +357,8 @@ namespace senf {
                                              \param[in] start address of buffer to write
                                              \param[in] end past-the-end pointer after data to write
                                              \returns past-the-end iterator after last byte written
-                                             \see \ref writeto() */
+                                             \see \ref writeto() \n
+                                                  <a href="http://www.boost.org/libs/range/index.html">Boost.Range</a>  */
 
         ///////////////////////////////////////////////////////////////////////////
         ///\name Addressing
@@ -394,24 +420,6 @@ namespace senf {
 
         ///@}
 
-        ///////////////////////////////////////////////////////////////////////////
-        ///\name Buffering
-        ///@{
-
-        unsigned     rcvbuf      ();    ///< Check size of receive buffer
-                                        /**< \returns size of receive buffer in bytes */
-        void         rcvbuf      (unsigned size);
-                                        ///< Set size of receive buffer
-                                        /**< \param[in] size size of receive buffer in bytes */
-
-        unsigned     sndbuf      ();    ///< Check size of send buffer
-                                        /**< \returns size of send buffer in bytes */
-        void         sndbuf      (unsigned size);
-                                        ///< Set size of send buffer
-                                        /**< \param[in] size size of send buffer in bytes */
-
-        ///@}
-
         static ClientSocketHandle cast_static(FileHandle handle);
         static ClientSocketHandle cast_dynamic(FileHandle handle);
 
@@ -446,4 +454,6 @@ namespace senf {
 // c-file-style: "senf"
 // indent-tabs-mode: nil
 // ispell-local-dictionary: "american"
+// compile-command: "scons -u test"
+// comment-column: 40
 // End: