4 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
5 // Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
6 // Stefan Bund <stefan.bund@fokus.fraunhofer.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 "ProtocolClientSocketHandle.hh"
34 #define prefix_ inline
35 ///////////////////////////////cti.p///////////////////////////////////////
37 template <class SocketProtocol>
38 prefix_ senf::ProtocolServerSocketHandle<SocketProtocol>::
39 ProtocolServerSocketHandle(UninitializedType)
42 template <class SocketProtocol>
43 prefix_ senf::ProtocolServerSocketHandle<SocketProtocol>::ProtocolServerSocketHandle()
44 : ServerSocketHandle<typename SocketProtocol::Policy>(
45 std::auto_ptr<senf::SocketProtocol>(new SocketProtocol()))
48 #define BOOST_PP_ITERATION_PARAMS_1 (4, (1, 9, SENF_ABSOLUTE_INCLUDE_PATH(Socket/ProtocolServerSocketHandle.mpp), 2))
49 #include BOOST_PP_ITERATE()
51 template <class SocketProtocol>
52 prefix_ SocketProtocol const &
53 senf::ProtocolServerSocketHandle<SocketProtocol>::protocol()
55 BOOST_ASSERT( dynamic_cast<SocketProtocol const *>(&this->body().protocol()) );
56 // Need dynamic_cast here, since senf::SocketProtocol is a
58 return dynamic_cast<SocketProtocol const &>(this->body().protocol());
61 template <class SocketProtocol>
62 prefix_ senf::ProtocolClientSocketHandle<SocketProtocol>
63 senf::ProtocolServerSocketHandle<SocketProtocol>::accept()
65 return ProtocolClientSocketHandle<SocketProtocol>(
66 FileHandle(this->ServerSocketHandle<typename SocketProtocol::Policy>::accept()),true);
69 template <class SocketProtocol>
70 prefix_ senf::ProtocolServerSocketHandle<SocketProtocol>
71 senf::ProtocolServerSocketHandle<SocketProtocol>::cast_static(FileHandle handle)
73 return ProtocolServerSocketHandle(handle,true);
76 template <class SocketProtocol>
77 prefix_ senf::ProtocolServerSocketHandle<SocketProtocol>
78 senf::ProtocolServerSocketHandle<SocketProtocol>::cast_dynamic(FileHandle handle)
80 ServerSocketHandle<typename SocketProtocol::Policy> h(
81 ServerSocketHandle<typename SocketProtocol::Policy>::cast_dynamic(handle));
82 // throw std::bad_cast if the protocol is invalid
83 dynamic_cast<SocketProtocol const &>(static_cast<SocketBody&>(FileHandle::body(h)).protocol());
84 return cast_static(handle);
87 template <class SocketProtocol>
89 senf::ProtocolServerSocketHandle<SocketProtocol>::state(SocketStateMap & map,
92 map["handle"] = prettyName(typeid(*this));
93 this->body().state(map,lod);
96 template <class SocketProtocol>
98 senf::ProtocolServerSocketHandle<SocketProtocol>::dumpState(unsigned lod)
102 return detail::dumpState(map);
105 template <class SocketProtocol>
106 prefix_ senf::ProtocolServerSocketHandle<SocketProtocol>::
107 ProtocolServerSocketHandle(FileHandle other, bool isChecked)
108 : ServerSocketHandle<typename SocketProtocol::Policy>(other,isChecked)
111 ///////////////////////////////cti.e///////////////////////////////////////
118 // c-file-style: "senf"
119 // indent-tabs-mode: nil
120 // ispell-local-dictionary: "american"
121 // compile-command: "scons -u test"
122 // comment-column: 40