d0a358fa1a7d2610282e3164aa423e55794e8180
[senf.git] / Socket / ProtocolServerSocketHandle.hh
1 // $Id$
2 //
3 // Copyright (C) 2006
4 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
5 // Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
6 //     Stefan Bund <stefan.bund@fokus.fraunhofer.de>
7 //
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
12 //
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 // GNU General Public License for more details.
17 //
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the
20 // Free Software Foundation, Inc.,
21 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22
23 /** \file
24     \brief ProtocolServerSocketHandle public header
25  */
26
27 #ifndef HH_ProtocolServerSocketHandle_
28 #define HH_ProtocolServerSocketHandle_ 1
29
30 // Custom includes
31 #include "ServerSocketHandle.hh"
32
33 #include "ProtocolServerSocketHandle.mpp"
34 ///////////////////////////////hh.p////////////////////////////////////////
35
36 namespace senf {
37
38     /// \addtogroup handle_group
39     /// @{
40
41     template <class Protocol> class ProtocolClientSocketHandle;
42
43     /** \brief Protocol specific socket handle (server interface)
44
45         The ProtocolServerSocketHandle is the server interface leaf class of the handle
46         hierarchy. This is the class to instantiate to open a new socket. This is also the \e only
47         class, which can be used to open a server socket.
48
49         The \a Protocol template argument defines the protocol of the socket. This protocol provides
50         the protocol interface of the socket as well as the complete socket policy of this protocol.
51
52         The ProtocolServerSocketHandle adds the protocol interface as an additional interface to the
53         socket handle. This interface is only accessible via the protocol class. All socket
54         functionality not available through the policy interface (see ServerSocketHandle) is
55         accessible via the protocol() member.
56
57         A ProtocolServerSocketHandle is only meaningful for connection oriented addressable
58         protocols (CommunicationPolicy is ConnectedCommunicationPolicy and AddressingPolicy is not
59         NoAddressingPolicy).
60
61         \see \ref protocol_group
62       */
63     template <class SocketProtocol>
64     class ProtocolServerSocketHandle
65         : public ServerSocketHandle<typename SocketProtocol::Policy>
66     {
67     public:
68         ///////////////////////////////////////////////////////////////////////////
69         // Types
70
71         typedef SocketProtocol Protocol; ///< The socket protocol
72         enum UninitializedType { Uninitialized }; ///< Flag to call 'uninitialized' constructor
73
74         ///////////////////////////////////////////////////////////////////////////
75         ///\name Structors and default members
76         ///@{
77
78         /** \brief Create new server socket
79
80             This constructor is one of the possible constructors. The exact Signature of the
81             constructor (or constructors) is defined by the \c init_server() member (or members) of
82             the \a Protocol class. ProtocolClientSocketHandle defines a number of constructors
83             taking up to 9 arguments which just forward to a corresponding \a Protocol\c
84             ::init_server() member. See the documentation of the respective Protocol class for a
85             detailed documentation of that protocols constructors.
86          */
87
88         ProtocolServerSocketHandle();
89
90 #       define BOOST_PP_ITERATION_PARAMS_1 (4, (1, 9, "Socket/ProtocolServerSocketHandle.mpp", 1))
91 #       include BOOST_PP_ITERATE()
92
93         /** \brief Create uninitialized socket variable
94
95             This special constructor is called when passing
96             ProtocolServerSocketHandle::Uninitialized as only argument to the constructor. This will
97             create an in-\ref valid() socket handle which can however be assigned later with another
98             socket instance.
99
100             \implementation The socket handle will have no \c body allocated.
101          */
102         ProtocolServerSocketHandle(UninitializedType);
103         ///@}
104         ///////////////////////////////////////////////////////////////////////////
105
106         Protocol const & protocol();    ///< Access the protocol interface
107                                         /**< The returned protocol class reference gives access to
108                                            the complete protocol interface as defined by that
109                                            class. See the respective protocol class documentation.
110                                            \returns \a Protocol class reference */
111
112         ProtocolClientSocketHandle<SocketProtocol> accept();
113
114         static ProtocolServerSocketHandle cast_static(FileHandle handle);
115         static ProtocolServerSocketHandle cast_dynamic(FileHandle handle);
116
117         void state(SocketStateMap & map, unsigned lod=0);
118         std::string dumpState(unsigned lod=0);
119
120     protected:
121         ProtocolServerSocketHandle(FileHandle other, bool isChecked);
122
123     private:
124
125     };
126
127     /// @}
128 }
129
130 ///////////////////////////////hh.e////////////////////////////////////////
131 //#include "ProtocolServerSocketHandle.cci"
132 //#include "ProtocolServerSocketHandle.ct"
133 #include "ProtocolServerSocketHandle.cti"
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: