4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 // Stefan Bund <g0dil@berlios.de>
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.
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.
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.
24 \brief ProtocolServerSocketHandle inline template implementation
27 // Definition of inline template functions
29 //#include "ProtocolServerSocketHandle.ih"
32 #include <senf/Utils/senfassert.hh>
33 #include "ProtocolClientSocketHandle.hh"
35 #define prefix_ inline
36 ///////////////////////////////cti.p///////////////////////////////////////
38 template <class SocketProtocol>
39 prefix_ senf::ProtocolServerSocketHandle<SocketProtocol>::
40 ProtocolServerSocketHandle(senf::NoInit_t)
43 template <class SocketProtocol>
44 prefix_ senf::ProtocolServerSocketHandle<SocketProtocol>::ProtocolServerSocketHandle()
45 : ServerSocketHandle<typename SocketProtocol::Policy>(
46 std::auto_ptr<senf::SocketBody>(new ProtocolSocketBody<SocketProtocol>(true)))
49 #define BOOST_PP_ITERATION_PARAMS_1 \
50 (4, (1, 9, SENF_ABSOLUTE_INCLUDE_PATH(Socket/ProtocolServerSocketHandle.mpp), 2))
51 #include BOOST_PP_ITERATE()
53 template <class SocketProtocol>
54 prefix_ SocketProtocol &
55 senf::ProtocolServerSocketHandle<SocketProtocol>::protocol()
57 SENF_ASSERT( dynamic_cast<SocketProtocol const *>(&this->body().protocol()),
58 "Internal failure: Incompatible protocol class fount it's way into this handle");
59 // Need dynamic_cast here, since senf::SocketProtocol is a
61 return dynamic_cast<SocketProtocol &>(this->body().protocol());
64 template <class SocketProtocol>
65 prefix_ senf::ProtocolClientSocketHandle<SocketProtocol>
66 senf::ProtocolServerSocketHandle<SocketProtocol>::accept()
68 return ProtocolClientSocketHandle<SocketProtocol>(
69 FileHandle(this->ServerSocketHandle<typename SocketProtocol::Policy>::accept()),true);
72 template <class SocketProtocol>
73 prefix_ senf::ProtocolServerSocketHandle<SocketProtocol>
74 senf::ProtocolServerSocketHandle<SocketProtocol>::cast_static(FileHandle handle)
76 return ProtocolServerSocketHandle(handle,true);
79 template <class SocketProtocol>
80 prefix_ senf::ProtocolServerSocketHandle<SocketProtocol>
81 senf::ProtocolServerSocketHandle<SocketProtocol>::cast_dynamic(FileHandle handle)
83 ServerSocketHandle<typename SocketProtocol::Policy> h(
84 ServerSocketHandle<typename SocketProtocol::Policy>::cast_dynamic(handle));
85 // throw std::bad_cast if the protocol is invalid
86 dynamic_cast<SocketProtocol const &>(static_cast<SocketBody&>(FileHandle::body(h)).protocol());
87 return cast_static(handle);
90 template <class SocketProtocol>
92 senf::ProtocolServerSocketHandle<SocketProtocol>::state(SocketStateMap & map,
95 map["handle"] = prettyName(typeid(*this));
97 map["valid"] << "true";
98 this->body().state(map,lod);
100 map["valid"] << "false";
103 template <class SocketProtocol>
105 senf::ProtocolServerSocketHandle<SocketProtocol>::dumpState(unsigned lod)
109 return detail::dumpState(map);
112 template <class SocketProtocol>
113 prefix_ senf::ProtocolServerSocketHandle<SocketProtocol>::
114 ProtocolServerSocketHandle(FileHandle other, bool isChecked)
115 : ServerSocketHandle<typename SocketProtocol::Policy>(other,isChecked)
118 ///////////////////////////////cti.e///////////////////////////////////////
125 // c-file-style: "senf"
126 // indent-tabs-mode: nil
127 // ispell-local-dictionary: "american"
128 // compile-command: "scons -u test"
129 // comment-column: 40