Fix documentation build under maverick (doxygen 1.7.1)
[senf.git] / senf / Socket / ServerSocketHandle.cti
1 // $Id$
2 //
3 // Copyright (C) 2006
4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 //     Stefan Bund <g0dil@berlios.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 ServerSocketHandle inline template implementation
25  */
26
27 // Definition of inline template functions
28
29 //#include "ServerSocketHandle.ih"
30
31 // Custom includes
32 #include <typeinfo>
33
34 #define prefix_ inline
35 //-/////////////////////////////////////////////////////////////////////////////////////////////////
36
37 template <class SPolicy>
38 prefix_ senf::ServerSocketHandle<SPolicy>::ServerSocketHandle()
39 {}
40
41 template <class SPolicy>
42 template <class OtherPolicy>
43 prefix_ senf::ServerSocketHandle<SPolicy>::
44 ServerSocketHandle(ServerSocketHandle<OtherPolicy> other,
45                    typename SocketHandle<SPolicy>::template IsCompatible<OtherPolicy>::type *)
46     : SocketHandle<SPolicy>(other,true)
47 {}
48
49 template <class SPolicy>
50 prefix_  senf::ServerSocketHandle<SPolicy>::
51 ServerSocketHandle(std::auto_ptr<SocketBody> body)
52     : SocketHandle<SPolicy>(body)
53 {}
54
55 template <class SPolicy>
56 template <class OtherPolicy>
57 prefix_ typename senf::SocketHandle<SPolicy>::template IsCompatible<OtherPolicy>::type const &
58 senf::ServerSocketHandle<SPolicy>::operator=(ServerSocketHandle<OtherPolicy> other)
59 {
60     assign(other);
61     return *this;
62 }
63
64 //-/////////////////////////////////////////////////////////////////////////////////////////////////
65 // Server socket interface
66
67 template <class SPolicy>
68 prefix_ void senf::ServerSocketHandle<SPolicy>::bind(AddressParam addr)
69 {
70     SPolicy::AddressingPolicy::bind(*this,addr);
71 }
72
73 template <class SPolicy>
74 prefix_ void senf::ServerSocketHandle<SPolicy>::listen(unsigned backlog)
75 {
76     SPolicy::CommunicationPolicy::listen(*this,backlog);
77 }
78
79 template <class SPolicy>
80 prefix_ typename senf::ServerSocketHandle<SPolicy>::Address
81 senf::ServerSocketHandle<SPolicy>::local()
82 {
83     typename SPolicy::AddressingPolicy::Address addr;
84     this->local(addr);
85     return addr;
86 }
87
88 template <class SPolicy>
89 prefix_ void senf::ServerSocketHandle<SPolicy>::local(Address & addr)
90 {
91     SPolicy::AddressingPolicy::local(*this,addr);
92 }
93
94 template <class SPolicy>
95 prefix_ typename senf::ServerSocketHandle<SPolicy>::ClientHandle
96 senf::ServerSocketHandle<SPolicy>::accept()
97 {
98     return ClientHandle(this->body().clone(
99                             SPolicy::CommunicationPolicy::accept(*this), false));
100 }
101
102 template <class SPolicy>
103 prefix_ std::pair<typename senf::ServerSocketHandle<SPolicy>::ClientHandle,
104                   typename senf::ServerSocketHandle<SPolicy>::Address>
105 senf::ServerSocketHandle<SPolicy>::acceptfrom()
106 {
107
108     Address address;
109     ClientHandle handle = acceptfrom(address);
110     return std::make_pair(handle,address);
111 }
112
113 template <class SPolicy>
114 prefix_ typename senf::ServerSocketHandle<SPolicy>::ClientHandle
115 senf::ServerSocketHandle<SPolicy>::acceptfrom(Address & addr)
116 {
117     return ClientHandle(this->body().clone(
118                             SPolicy::CommunicationPolicy::accept(*this,addr), false));
119 }
120
121 //-/////////////////////////////////////////////////////////////////////////////////////////////////
122
123 template <class SPolicy>
124 prefix_ senf::ServerSocketHandle<SPolicy>::ServerSocketHandle(FileHandle other,
125                                                                     bool isChecked)
126     : SocketHandle<SPolicy>(other, isChecked)
127 {}
128
129 template <class SPolicy>
130 prefix_ senf::ServerSocketHandle<SPolicy>
131 senf::ServerSocketHandle<SPolicy>::cast_static(FileHandle handle)
132 {
133     return ServerSocketHandle(handle,true);
134 }
135
136 template <class SPolicy>
137 prefix_ senf::ServerSocketHandle<SPolicy>
138 senf::ServerSocketHandle<SPolicy>::cast_dynamic(FileHandle handle)
139 {
140     SocketHandle<SPolicy> h (SocketHandle<SPolicy>::cast_dynamic(handle));
141     if (! static_cast<SocketBody&>(FileHandle::body(handle)).isServer())
142         throw std::bad_cast();
143     return cast_static(handle);
144 }
145
146 template <class SPolicy>
147 prefix_ void senf::ServerSocketHandle<SPolicy>::state(SocketStateMap & map, unsigned lod)
148 {
149     map["handle"] = prettyName(typeid(*this));
150     if (this->valid()) {
151         map["valid"] << "true";
152         this->body().state(map,lod);
153     } else
154         map["valid"] << "false";
155 }
156
157 template <class SPolicy>
158 prefix_ std::string senf::ServerSocketHandle<SPolicy>::dumpState(unsigned lod)
159 {
160     SocketStateMap map;
161     state(map,lod);
162     return detail::dumpState(map);
163 }
164
165 //-/////////////////////////////////////////////////////////////////////////////////////////////////
166 #undef prefix_
167
168 \f
169 // Local Variables:
170 // mode: c++
171 // fill-column: 100
172 // c-file-style: "senf"
173 // indent-tabs-mode: nil
174 // ispell-local-dictionary: "american"
175 // compile-command: "scons -u test"
176 // comment-column: 40
177 // End: