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 ProtocolClientSocketHandle inline template
28 // Definition of inline template functions
30 //#include "ProtocolClientSocketHandle.ih"
34 #define prefix_ inline
35 ///////////////////////////////cti.p///////////////////////////////////////
37 template <class SocketProtocol>
38 prefix_ senf::ProtocolClientSocketHandle<SocketProtocol>::
39 ProtocolClientSocketHandle(UninitializedType)
42 template <class SocketProtocol>
43 prefix_ senf::ProtocolClientSocketHandle<SocketProtocol>::ProtocolClientSocketHandle()
44 : ClientSocketHandle<typename SocketProtocol::Policy>(
45 std::auto_ptr<senf::SocketProtocol>(new SocketProtocol()))
47 this->protocol().init_client();
50 #define BOOST_PP_ITERATION_PARAMS_1 (4, (1, 9, SENF_ABSOLUTE_INCLUDE_PATH(Socket/ProtocolClientSocketHandle.mpp), 2))
51 #include BOOST_PP_ITERATE()
53 template <class SocketProtocol>
54 prefix_ senf::ProtocolClientSocketHandle<SocketProtocol>::
55 ProtocolClientSocketHandle(FileHandle other, bool isChecked)
56 : ClientSocketHandle<typename Protocol::Policy>(other, isChecked)
59 template <class SocketProtocol>
60 prefix_ SocketProtocol const &
61 senf::ProtocolClientSocketHandle<SocketProtocol>::protocol()
63 BOOST_ASSERT( dynamic_cast<SocketProtocol const *>(&this->body().protocol()) );
64 // Need dynamic_cast here, since senf::SocketProtocol is a
66 return dynamic_cast<SocketProtocol const &>(this->body().protocol());
69 template <class SocketProtocol>
70 prefix_ senf::ProtocolClientSocketHandle<SocketProtocol>
71 senf::ProtocolClientSocketHandle<SocketProtocol>::cast_static(FileHandle handle)
73 return ProtocolClientSocketHandle(handle,true);
76 template <class SocketProtocol>
77 prefix_ senf::ProtocolClientSocketHandle<SocketProtocol>
78 senf::ProtocolClientSocketHandle<SocketProtocol>::cast_dynamic(FileHandle handle)
80 ClientSocketHandle<typename SocketProtocol::Policy> h(
81 ClientSocketHandle<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::ProtocolClientSocketHandle<SocketProtocol>::state(SocketStateMap & map,
92 map["handle"] = prettyName(typeid(*this));
93 this->body().state(map,lod);
96 template <class SocketProtocol>
98 senf::ProtocolClientSocketHandle<SocketProtocol>::dumpState(unsigned lod)
102 return detail::dumpState(map);
105 ///////////////////////////////cti.e///////////////////////////////////////
112 // c-file-style: "senf"
113 // indent-tabs-mode: nil
114 // ispell-local-dictionary: "american"
115 // compile-command: "scons -u test"
116 // comment-column: 40