removed some errors, added basic unit tests
[senf.git] / Socket / Protocols / UN / UNDatagramSocketHandle.hh
1 // $Id$
2 //
3 // Copyright (C) 2007 
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the
17 // Free Software Foundation, Inc.,
18 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
19
20 /** \file
21     \brief UNDatagramSocketHandle public header */
22
23 #ifndef HH_UNDatagramSocketHandle_
24 #define HH_UNDatagramSocketHandle_ 1
25
26 // Custom includes
27 #include "UNAddressing.hh"
28 #include "UNProtocol.hh"
29 #include "../../../Socket/Protocols/BSDSocketProtocol.hh"
30 #include "../../../Socket/FramingPolicy.hh"
31 #include "../../../Socket/CommunicationPolicy.hh"
32 #include "../../../Socket/ReadWritePolicy.hh"
33 #include "../../../Socket/BufferingPolicy.hh"
34 #include "../../../Socket/ProtocolClientSocketHandle.hh"
35
36
37
38 //#include "UNDatagramSocketHandle.mpp"
39 ///////////////////////////////hh.p////////////////////////////////////////
40
41 namespace senf {
42
43     /// \addtogroup concrete_protocol_group
44     /// @{
45
46     typedef MakeSocketPolicy<
47         UNAddressingPolicy,
48         DatagramFramingPolicy,
49         UnconnectedCommunicationPolicy,
50         ReadablePolicy,
51         WriteablePolicy,
52         SocketBufferingPolicy
53         >::policy UNDatagramSocket_Policy;   ///< Socket Policy of the Unix Domain Datagram Protocol
54
55     /** \brief Unix Domain Datagram Socket Protocol
56
57         \par Socket Handle typedefs:
58             \ref UNDatagramSocketHandle (ProtocolClientSocketHandle)
59
60         \par Policy Interface: (to be checked)
61             ClientSocketHandle::read(), ClientSocketHandle::readfrom(),
62             ClientSocketHandle::writeto(), ClientSocketHandle::bind(), ClientSocketHandle::local(),
63             ClientSocketHandle::rcvbuf(), ClientSocketHandle::sndbuf()
64
65         \par Address Type:
66             UNAddress
67
68         UNDatagramSocketProtocol provides an datagram protocol socket based on the unix domain  addressing.
69
70         This class is utilized as the protocol class of the ProtocolClientSocketHandle
71         via the Socket Handle typedefs above.
72
73     */
74     class UNDatagramSocketProtocol
75         : public ConcreteSocketProtocol<UNDatagramSocket_Policy>,
76           public UNProtocol, 
77           public BSDSocketProtocol,
78           public AddressableBSDSocketProtocol
79     {
80     public:
81         ///////////////////////////////////////////////////////////////////////////
82         // internal interface
83
84         ///\name Constructors
85         ///@{
86
87         void init_client() const;       ///< Create unconnected client socket
88                                         /**< \note This member is implicitly called from the
89                                              ProtocolClientSocketHandle::ProtocolClientSocketHandle()
90                                              constructor */
91         void init_client(UNSocketAddress const & address) const;
92                                         ///< Create client socket and bind
93                                         /**< Creates a new client socket and bind to the given
94                                              address.
95                                              \param[in] local address to bind to */
96                                         /**< \note This member is implicitly called from the
97                                              ProtocolClientSocketHandle::ProtocolClientSocketHandle()
98                                              constructor */
99         
100         ///@}
101         ///\name Abstract Interface Implementation
102
103         std::auto_ptr<SocketProtocol> clone() const;
104
105         ///@}
106     };
107
108     typedef ProtocolClientSocketHandle<UNDatagramSocketProtocol> UNDatagramClientSocketHandle;
109
110     typedef MakeSocketPolicy<
111         UNDatagramSocket_Policy,
112         UNAddressingPolicy
113         >::policy UNDatagramSocket_Policy;
114 }
115 ///////////////////////////////hh.e////////////////////////////////////////
116 //#include "UNDatagramSocketHandle.cci"
117 //#include "UNDatagramSocketHandle.ct"
118 //#include "UNDatagramSocketHandle.cti"
119 #endif
120
121 \f
122 // Local Variables:
123 // mode: c++
124 // fill-column: 100
125 // comment-column: 40
126 // c-file-style: "senf"
127 // indent-tabs-mode: nil
128 // ispell-local-dictionary: "american"
129 // compile-command: "scons -u test"
130 // End: