switch to new MPL based Fraunhofer FOKUS Public License
[senf.git] / senf / Socket / ProtocolServerSocketHandle.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 ProtocolServerSocketHandle public header
30  */
31
32 #ifndef HH_SENF_Socket_ProtocolServerSocketHandle_
33 #define HH_SENF_Socket_ProtocolServerSocketHandle_ 1
34
35 // Custom includes
36 #include "ServerSocketHandle.hh"
37 #include <senf/config.hh>
38 #include <senf/Utils/Tags.hh>
39
40 #include "ProtocolServerSocketHandle.mpp"
41 //-/////////////////////////////////////////////////////////////////////////////////////////////////
42
43 namespace senf {
44
45     /// \addtogroup handle_group
46     //\{
47
48     template <class Protocol> class ProtocolClientSocketHandle;
49
50     /** \brief Protocol specific socket handle (server interface)
51
52         The ProtocolServerSocketHandle is the server 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 server 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 ProtocolServerSocketHandle 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 ServerSocketHandle) is
62         accessible via the protocol() member.
63
64         A ProtocolServerSocketHandle is only meaningful for connection oriented addressable
65         protocols (CommunicationPolicy is ConnectedCommunicationPolicy and AddressingPolicy is not
66         NoAddressingPolicy).
67
68         \see \ref protocol_group
69       */
70     template <class SocketProtocol>
71     class ProtocolServerSocketHandle
72         : public ServerSocketHandle<typename SocketProtocol::Policy>
73     {
74     public:
75         //-////////////////////////////////////////////////////////////////////////
76         // Types
77
78         typedef SocketProtocol Protocol; ///< The socket protocol
79
80         //-////////////////////////////////////////////////////////////////////////
81         ///\name Structors and default members
82         //\{
83
84         /** \brief Create new server socket
85
86             This constructor is one of the possible constructors. The exact Signature of the
87             constructor (or constructors) is defined by the \c init_server() member (or members) of
88             the \a Protocol class. ProtocolClientSocketHandle defines a number of constructors
89             taking up to 9 arguments which just forward to a corresponding \a Protocol\c
90             ::init_server() member. See the documentation of the respective Protocol class for a
91             detailed documentation of that protocols constructors.
92          */
93
94         ProtocolServerSocketHandle();
95
96 #       define BOOST_PP_ITERATION_PARAMS_1 (4, (1, 9, SENF_ABSOLUTE_INCLUDE_PATH(Socket/ProtocolServerSocketHandle.mpp), 1))
97 #       include BOOST_PP_ITERATE()
98
99         /** \brief Create uninitialized socket variable
100
101             This special constructor is called when passing
102             ProtocolServerSocketHandle::Uninitialized as only argument to the constructor. This will
103             create an in-\ref valid() socket handle which can however be assigned later with another
104             socket instance.
105
106             \implementation The socket handle will have no \c body allocated.
107          */
108         ProtocolServerSocketHandle(senf::NoInit_t);
109         //\}
110         //-////////////////////////////////////////////////////////////////////////
111
112         Protocol & protocol();          ///< Access the protocol interface
113                                         /**< The returned protocol class reference gives access to
114                                            the complete protocol interface as defined by that
115                                            class. See the respective protocol class documentation.
116                                            \returns \a Protocol class reference */
117
118         ProtocolClientSocketHandle<SocketProtocol> accept();
119
120         static ProtocolServerSocketHandle cast_static(FileHandle handle);
121         static ProtocolServerSocketHandle cast_dynamic(FileHandle handle);
122
123         void state(SocketStateMap & map, unsigned lod=0);
124         std::string dumpState(unsigned lod=0);
125
126     protected:
127         ProtocolServerSocketHandle(FileHandle other, bool isChecked);
128
129     private:
130
131     };
132
133     //\}
134 }
135
136 //-/////////////////////////////////////////////////////////////////////////////////////////////////
137 //#include "ProtocolServerSocketHandle.cci"
138 //#include "ProtocolServerSocketHandle.ct"
139 #include "ProtocolServerSocketHandle.cti"
140 #endif
141
142 \f
143 // Local Variables:
144 // mode: c++
145 // fill-column: 100
146 // c-file-style: "senf"
147 // indent-tabs-mode: nil
148 // ispell-local-dictionary: "american"
149 // compile-command: "scons -u test"
150 // comment-column: 40
151 // End: