X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Socket%2FReadWritePolicy.hh;h=24d5cea6bf246a5e8c1bf9bd37d13ee35c8e9902;hb=b89e3166f7680755683dccee5e48cb3a820185c0;hp=00ab590dd3e0250ba624ad39cb54e0670b02cae7;hpb=85ab07d100a382467a42e19d741d403a7a96c951;p=senf.git diff --git a/Socket/ReadWritePolicy.hh b/Socket/ReadWritePolicy.hh index 00ab590..24d5cea 100644 --- a/Socket/ReadWritePolicy.hh +++ b/Socket/ReadWritePolicy.hh @@ -1,9 +1,9 @@ // $Id$ // // Copyright (C) 2006 -// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS) -// Kompetenzzentrum fuer Satelitenkommunikation (SatCom) -// Stefan Bund +// 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 // it under the terms of the GNU General Public License as published by @@ -26,8 +26,8 @@ \todo ReadWritePolicy.test.cc */ -#ifndef HH_ReadWritePolicy_ -#define HH_ReadWritePolicy_ 1 +#ifndef HH_SENF_Socket_ReadWritePolicy_ +#define HH_SENF_Socket_ReadWritePolicy_ 1 // Custom includes #include "SocketPolicy.hh" @@ -48,7 +48,7 @@ namespace senf { /** \brief ReadPolicy for readable sockets This policy provides support for readable sockets via the standard UNIX read/recvfrom system - cals. The concreate semantics of the read calls depend on the framing policy of the socket. + calls. The concrete semantics of the read calls depend on the framing policy of the socket. */ struct ReadablePolicy : public ReadPolicyBase { @@ -58,20 +58,27 @@ namespace senf { \param[in] buffer address of buffer to write data to \param[in] size size of buffer \returns number of bytes read */ - template - static unsigned readfrom(ClientSocketHandle handle, char * buffer, unsigned size, - typename Policy::AddressingPolicy::Address & address, - typename IfCommunicationPolicyIs::type * = 0); +# ifndef DOXYGEN + template + static unsigned readfrom(ClientSocketHandle handle, char * buffer, unsigned size, + typename SPolicy::AddressingPolicy::Address & address, + typename IfCommunicationPolicyIs< + SPolicy,UnconnectedCommunicationPolicy>::type * = 0); +# else + template + static unsigned readfrom(ClientSocketHandle handle, char * buffer, unsigned size, + typename Policy::AddressingPolicy::Address & address); ///< read data from socket returning peer address /**< \param[in] handle socket handle to read from \param[in] buffer address of buffer to write data to \param[in] size size of buffer \param[out] address peer address \returns number of bytes read */ +# endif private: static unsigned do_readfrom(FileHandle handle, char * buffer, unsigned size, - struct ::sockaddr * addr, socklen_t len); + struct ::sockaddr * addr, socklen_t * len); }; /** \brief ReadPolicy for unreadable sockets @@ -86,13 +93,19 @@ namespace senf { /** \brief WritePolicy for writeable sockets This policy provides support for writable sockets via the standard UNIX write/sendto system - cals. The concreate semantics of the write calls depend on the framing policy of the socket. + calls. The concrete semantics of the write calls depend on the framing policy of the socket. */ struct WriteablePolicy : public WritePolicyBase { - template - static unsigned write(ClientSocketHandle handle, char const * buffer, unsigned size, - typename IfCommunicationPolicyIs::type * = 0); +# ifndef DOXYGEN + template + static unsigned write(ClientSocketHandle handle, char const * buffer, unsigned size, + typename IfCommunicationPolicyIs< + SPolicy,ConnectedCommunicationPolicy>::type * = 0); +# else + template + static unsigned write(ClientSocketHandle handle, char const * buffer, + unsigned size); ///< write data to socket /**< This member is only enabled if the socket uses connected communication. Otherwise the communication @@ -103,11 +116,20 @@ namespace senf { \param[in] buffer address of buffer to send \param[in] size number of bytes to write \returns number of bytes written */ - template - static unsigned writeto(ClientSocketHandle handle, - typename boost::call_traits::param_type addr, +# endif +# ifndef DOXYGEN + template + static unsigned writeto(ClientSocketHandle handle, + typename boost::call_traits< + typename SPolicy::AddressingPolicy::Address>::param_type addr, char const * buffer, unsigned size, - typename IfCommunicationPolicyIs::type * = 0); + typename IfCommunicationPolicyIs< + SPolicy,UnconnectedCommunicationPolicy>::type * = 0); +# else + template + static unsigned writeto(ClientSocketHandle handle, + typename Policy::AddressingPolicy::Address const & addr, + char const * buffer, unsigned size); ///< write data to socket sending to given peer /**< This member is only enabled if the socket uses unconnected communication. Otherwise no target may be @@ -116,14 +138,15 @@ namespace senf { \param[in] handle socket handle to write data to \param[in] buffer address of buffer to send \param[in] size number of bytes to write - \param[in] address peer to send data to + \param[in] addr peer to send data to \returns number of bytes written */ +# endif private: static unsigned do_write(FileHandle handle, char const * buffer, unsigned size); static unsigned do_writeto(FileHandle handle, char const * buffer, unsigned size, - struct sockaddr * addr, socklen_t len); + struct sockaddr const * addr, socklen_t len); }; /** \brief WritePolicy for unwriteable sockets @@ -153,4 +176,6 @@ namespace senf { // c-file-style: "senf" // indent-tabs-mode: nil // ispell-local-dictionary: "american" +// compile-command: "scons -u test" +// comment-column: 40 // End: