switch to new MPL based Fraunhofer FOKUS Public License
[senf.git] / senf / Socket / ProtocolClientSocketHandle.hh
1 // $Id$
2 //
3 // Copyright (C) 2006
4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 //
6 // The contents of this file are subject to the Fraunhofer FOKUS Public License
7 // Version 1.0 (the "License"); you may not use this file except in compliance
8 // with the License. You may obtain a copy of the License at 
9 // http://senf.berlios.de/license.html
10 //
11 // The Fraunhofer FOKUS Public License Version 1.0 is based on, 
12 // but modifies the Mozilla Public License Version 1.1.
13 // See the full license text for the amendments.
14 //
15 // Software distributed under the License is distributed on an "AS IS" basis, 
16 // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 
17 // for the specific language governing rights and limitations under the License.
18 //
19 // The Original Code is Fraunhofer FOKUS code.
20 //
21 // The Initial Developer of the Original Code is Fraunhofer-Gesellschaft e.V. 
22 // (registered association), Hansastraße 27 c, 80686 Munich, Germany.
23 // All Rights Reserved.
24 //
25 // Contributor(s):
26 //   Stefan Bund <g0dil@berlios.de>
27
28 /** \file
29     \brief ProtocolClientSocketHandle public header
30  */
31
32 #ifndef HH_SENF_Socket_ProtocolClientSocketHandle_
33 #define HH_SENF_Socket_ProtocolClientSocketHandle_ 1
34
35 // Custom includes
36 #include "ClientSocketHandle.hh"
37 #include <senf/config.hh>
38 #include <senf/Utils/Tags.hh>
39
40 #include "ProtocolClientSocketHandle.mpp"
41 //-/////////////////////////////////////////////////////////////////////////////////////////////////
42
43 namespace senf {
44
45     /// \addtogroup handle_group
46     //\{
47
48     template <class Protocol> class ProtocolServerSocketHandle;
49
50     /** \brief Protocol specific socket handle (client interface)
51
52         The ProtocolClientSocketHandle is the client interface leaf class of the handle
53         hierarchy. This is the class to instantiate to open a new socket. This is also the \e only
54         class, which can be used to open a client socket.
55
56         The \a Protocol template argument defines the protocol of the socket. This protocol provides
57         the protocol interface of the socket as well as the complete socket policy of this protocol.
58
59         The ProtocolClientSocketHandle adds the protocol interface as an additional interface to the
60         socket handle. This interface is only accessible via the protocol class. All socket
61         functionality not available through the policy interface (see ClientSocketHandle) is
62         accessible via the protocol() member.
63
64         \see \ref protocol_group
65       */
66     template <class SocketProtocol>
67     class ProtocolClientSocketHandle
68         : public ClientSocketHandle<typename SocketProtocol::Policy>
69     {
70     public:
71         //-////////////////////////////////////////////////////////////////////////
72         // Types
73
74         typedef SocketProtocol Protocol; ///< The sockets protocol
75
76         //-////////////////////////////////////////////////////////////////////////
77         ///\name Structors and default members
78         //\{
79
80         /** \brief Create new client socket
81
82             This constructor is one of the possible constructors. The exact Signature of the
83             constructor (or constructors) is defined by the \c init_client() member (or members) of
84             the \a Protocol class. ProtocolClientSocketHandle defines a number of constructors
85             taking up to 9 arguments which just forward to a corresponding \a Protocol\c
86             ::init_client() member. See the documentation of the respective Protocol class for a
87             detailed documentation of that protocols constructors.
88          */
89         ProtocolClientSocketHandle();
90
91 #       define BOOST_PP_ITERATION_PARAMS_1 (4, (1, 9, SENF_ABSOLUTE_INCLUDE_PATH(Socket/ProtocolClientSocketHandle.mpp), 1))
92 #       include BOOST_PP_ITERATE()
93
94         /** \brief Create uninitialized socket variable
95
96             This special constructor is called when passing \c senf::noinit as only argument to
97             the constructor. This will create an in-\ref valid() socket handle which can however
98             be assigned later with another socket instance.
99
100             \implementation The socket handle will have no \c body allocated.
101          */
102         ProtocolClientSocketHandle(senf::NoInit_t);
103
104         //\}
105         //-////////////////////////////////////////////////////////////////////////
106
107         Protocol & protocol();          ///< Access the protocol interface
108                                         /**< The returned protocol class reference gives access to
109                                              the complete protocol interface as defined by that
110                                              class. See the respective protocol class documentation.
111                                              \returns \a Protocol class reference */
112
113         static ProtocolClientSocketHandle cast_static(FileHandle handle);
114         static ProtocolClientSocketHandle cast_dynamic(FileHandle handle);
115
116         void state(SocketStateMap & map, unsigned lod=0);
117         std::string dumpState(unsigned lod=0);
118
119     protected:
120         ProtocolClientSocketHandle(FileHandle other, bool isChecked);
121
122     private:
123         friend class ProtocolServerSocketHandle<Protocol>;
124     };
125
126     //\}
127 }
128
129 //-/////////////////////////////////////////////////////////////////////////////////////////////////
130 //#include "ProtocolClientSocketHandle.cci"
131 //#include "ProtocolClientSocketHandle.ct"
132 #include "ProtocolClientSocketHandle.cti"
133 #include "ProtocolClientSocketHandle.mpp"
134 #endif
135
136 \f
137 // Local Variables:
138 // mode: c++
139 // fill-column: 100
140 // c-file-style: "senf"
141 // indent-tabs-mode: nil
142 // ispell-local-dictionary: "american"
143 // compile-command: "scons -u test"
144 // comment-column: 40
145 // End: