Search:

SENF Extensible Network Framework

  • Home
  • Download
  • Wiki
  • BerliOS
  • ChangeLog
  • Browse SVN
  • Bug Tracker
  • Overview
  • Examples
  • HowTos
  • Glossary
  • PPI
  • Packets
  • Scheduler
  • Socket
  • Utils
  • Console
  • Daemon
  • Logger
  • Termlib
  • Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Classes
  • Files
  • Directories
  • File List
  • File Members

ReadWritePolicy.hh

Go to the documentation of this file.
00001 // $Id: ReadWritePolicy.hh 1742 2010-11-04 14:51:56Z g0dil $
00002 //
00003 // Copyright (C) 2006
00004 // Fraunhofer (FOKUS)
00005 // Competence Center NETwork research (NET), St. Augustin, GERMANY
00006 //     Stefan Bund <g0dil@berlios.de>
00007 //
00008 // This program is free software; you can redistribute it and/or modify
00009 // it under the terms of the GNU General Public License as published by
00010 // the Free Software Foundation; either version 2 of the License, or
00011 // (at your option) any later version.
00012 //
00013 // This program is distributed in the hope that it will be useful,
00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016 // GNU General Public License for more details.
00017 //
00018 // You should have received a copy of the GNU General Public License
00019 // along with this program; if not, write to the
00020 // Free Software Foundation, Inc.,
00021 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00022 
00029 #ifndef HH_SENF_Socket_ReadWritePolicy_
00030 #define HH_SENF_Socket_ReadWritePolicy_ 1
00031 
00032 // Custom includes
00033 #include "SocketPolicy.hh"
00034 #include "ClientSocketHandle.hh"
00035 #include "CommunicationPolicy.hh"
00036 
00037 //#include "ReadWritePolicy.mpp"
00038 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00039 
00040 
00041 struct sockaddr;
00042 
00043 namespace senf {
00044 
00046     //\{
00047 
00053     struct ReadablePolicy : public ReadPolicyBase
00054     {
00055         static unsigned read(FileHandle & handle, char * buffer, unsigned size);
00057 
00061 #       ifndef DOXYGEN
00062         template <class SPolicy>
00063         static unsigned readfrom(ClientSocketHandle<SPolicy> & handle, char * buffer, unsigned size,
00064                                  typename SPolicy::AddressingPolicy::Address & address,
00065                                  typename IfCommunicationPolicyIs<
00066                                      SPolicy,UnconnectedCommunicationPolicy>::type * = 0);
00067 #       else
00068         template <class SPolicy>
00069         static unsigned readfrom(ClientSocketHandle<SPolicy> & handle, char * buffer, unsigned size,
00070                                  typename Policy::AddressingPolicy::Address & address);
00072 
00077 #       endif
00078 
00079     private:
00080         static unsigned do_readfrom(FileHandle & handle, char * buffer, unsigned size,
00081                                     struct ::sockaddr * addr, socklen_t * len);
00082     };
00083 
00090     struct NotReadablePolicy : public ReadPolicyBase
00091     {};
00092 
00098     struct WriteablePolicy : public WritePolicyBase
00099     {
00100 #       ifndef DOXYGEN
00101         template <class SPolicy>
00102         static unsigned write(ClientSocketHandle<SPolicy> & handle, char const * buffer, unsigned size,
00103                               typename IfCommunicationPolicyIs<
00104                                   SPolicy,ConnectedCommunicationPolicy>::type * = 0);
00105 #       else
00106         template <class SPolicy>
00107         static unsigned write(ClientSocketHandle<SPolicy> & handle, char const * buffer,
00108                               unsigned size);
00110 
00119 #       endif
00120 #       ifndef DOXYGEN
00121         template <class SPolicy>
00122         static unsigned writeto(ClientSocketHandle<SPolicy> & handle,
00123                                 typename boost::call_traits<
00124                                     typename SPolicy::AddressingPolicy::Address>::param_type addr,
00125                                 char const * buffer, unsigned size,
00126                                 typename IfCommunicationPolicyIs<
00127                                     SPolicy,UnconnectedCommunicationPolicy>::type * = 0);
00128 #       else
00129         template <class SPolicy>
00130         static unsigned writeto(ClientSocketHandle<SPolicy> & handle,
00131                                 typename Policy::AddressingPolicy::Address const & addr,
00132                                 char const * buffer, unsigned size);
00134 
00144 #       endif
00145 
00146     private:
00147         static unsigned do_write(FileHandle & handle, char const * buffer, unsigned size);
00148         static unsigned do_writeto(FileHandle & handle, char const * buffer, unsigned size,
00149                                    struct sockaddr const * addr, socklen_t len);
00150     };
00151 
00158     struct NotWriteablePolicy : public WritePolicyBase
00159     {};
00160 
00161     //\}
00162 
00163 }
00164 
00165 
00166 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00167 //#include "ReadWritePolicy.cci"
00168 //#include "ReadWritePolicy.ct"
00169 #include "ReadWritePolicy.cti"
00170 #endif
00171 
00172 
00173 // Local Variables:
00174 // mode: c++
00175 // fill-column: 100
00176 // c-file-style: "senf"
00177 // indent-tabs-mode: nil
00178 // ispell-local-dictionary: "american"
00179 // compile-command: "scons -u test"
00180 // comment-column: 40
00181 // End:

Contact: senf-dev@lists.berlios.de | © 2006-2010 Fraunhofer Institute for Open Communication Systems, Network Research