BSDAddressingPolicy.hh

Go to the documentation of this file.
00001 // $Id: BSDAddressingPolicy.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 
00030 #ifndef HH_SENF_Socket_Protocols_BSDAddressingPolicy_
00031 #define HH_SENF_Socket_Protocols_BSDAddressingPolicy_ 1
00032 
00033 // Custom includes
00034 #include <senf/Socket/SocketHandle.hh>
00035 #include <senf/Socket/FileHandle.hh>
00036 #include <senf/Socket/CommunicationPolicy.hh>
00037 #include "BSDSocketAddress.hh"
00038 
00039 //#include "BSDAddressingPolicy.mpp"
00040 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00041 
00042 namespace senf {
00043 
00045     //\{
00046 
00051     struct BSDAddressingPolicyMixinBase
00052     {
00053         static void do_local(FileHandle const & handle, struct sockaddr * addr, socklen_t * len);
00054         static void do_peer(FileHandle const & handle, struct sockaddr * addr, socklen_t * len);
00055         static void do_bind(FileHandle const & handle, struct sockaddr const * addr, socklen_t len);
00056         static void do_connect(FileHandle const & handle, struct sockaddr const * addr, socklen_t len);
00057     };
00058 
00083     template <class Address>
00084     struct BSDAddressingPolicyMixin
00085         : private BSDAddressingPolicyMixinBase
00086     {
00087 #       ifndef DOXYGEN
00088         template <class SPolicy>
00089         static void peer(SocketHandle<SPolicy> const & handle, Address & addr,
00090                          typename IfCommunicationPolicyIs<SPolicy,ConnectedCommunicationPolicy>::type * = 0);
00091 #       else
00092         template <class SPolicy>
00093         static void peer(SocketHandle<SPolicy> const & handle, Address & addr);
00095 
00100 #       endif
00101         static void local(FileHandle const & handle, Address & addr);
00103 
00106 #       ifndef DOXYGEN
00107         template <class SPolicy>
00108         static void connect(SocketHandle<SPolicy> const & handle, Address const & addr,
00109                             typename IfCommunicationPolicyIs<SPolicy,ConnectedCommunicationPolicy>::type * = 0);
00110 #       else
00111         template <class SPolicy>
00112         static void connect(SocketHandle<SPolicy> const & handle, Address const & addr);
00114 
00120 #       endif
00121         static void bind(FileHandle const & handle, Address const & addr);
00123 
00125     };
00126 
00127     //\}
00128 
00129     struct BSDAddressingPolicy
00130         : public AddressingPolicyBase,
00131           private BSDAddressingPolicyMixin<GenericBSDSocketAddress>
00132     {
00133         typedef GenericBSDSocketAddress Address;
00134 
00135         using BSDAddressingPolicyMixin<GenericBSDSocketAddress>::peer;
00136         using BSDAddressingPolicyMixin<GenericBSDSocketAddress>::local;
00137         using BSDAddressingPolicyMixin<GenericBSDSocketAddress>::connect;
00138         using BSDAddressingPolicyMixin<GenericBSDSocketAddress>::bind;
00139     };
00140 
00141 }
00142 
00143 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00144 //#include "BSDAddressingPolicy.cci"
00145 //#include "BSDAddressingPolicy.ct"
00146 #include "BSDAddressingPolicy.cti"
00147 //#include "BSDAddressingPolicy.mpp"
00148 #endif
00149 
00150 
00151 // Local Variables:
00152 // mode: c++
00153 // fill-column: 100
00154 // c-file-style: "senf"
00155 // indent-tabs-mode: nil
00156 // ispell-local-dictionary: "american"
00157 // compile-command: "scons -u ../test"
00158 // comment-column: 40
00159 // End: