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 ProtocolClientSocketHandle inline template
28 // Definition of inline template functions
30 //#include "ProtocolClientSocketHandle.ih"
33 #include "../Utils/senfassert.hh"
35 #define prefix_ inline
36 ///////////////////////////////cti.p///////////////////////////////////////
38 template <class SocketProtocol>
39 prefix_ senf::ProtocolClientSocketHandle<SocketProtocol>::
40 ProtocolClientSocketHandle(senf::NoInit_t)
43 template <class SocketProtocol>
44 prefix_ senf::ProtocolClientSocketHandle<SocketProtocol>::ProtocolClientSocketHandle()
45 : ClientSocketHandle<typename SocketProtocol::Policy>(
46 std::auto_ptr<senf::SocketBody>(new senf::ProtocolSocketBody<SocketProtocol>(false)))
48 this->protocol().init_client();
51 #define BOOST_PP_ITERATION_PARAMS_1 (4, (1, 9, SENF_ABSOLUTE_INCLUDE_PATH(Socket/ProtocolClientSocketHandle.mpp), 2))
52 #include BOOST_PP_ITERATE()
54 template <class SocketProtocol>
55 prefix_ senf::ProtocolClientSocketHandle<SocketProtocol>::
56 ProtocolClientSocketHandle(FileHandle other, bool isChecked)
57 : ClientSocketHandle<typename Protocol::Policy>(other, isChecked)
60 template <class SocketProtocol>
61 prefix_ SocketProtocol const &
62 senf::ProtocolClientSocketHandle<SocketProtocol>::protocol()
64 SENF_ASSERT( dynamic_cast<SocketProtocol const *>(&this->body().protocol()) );
65 // Need dynamic_cast here, since senf::SocketProtocol is a
67 return dynamic_cast<SocketProtocol const &>(this->body().protocol());
70 template <class SocketProtocol>
71 prefix_ senf::ProtocolClientSocketHandle<SocketProtocol>
72 senf::ProtocolClientSocketHandle<SocketProtocol>::cast_static(FileHandle handle)
74 return ProtocolClientSocketHandle(handle,true);
77 template <class SocketProtocol>
78 prefix_ senf::ProtocolClientSocketHandle<SocketProtocol>
79 senf::ProtocolClientSocketHandle<SocketProtocol>::cast_dynamic(FileHandle handle)
81 ClientSocketHandle<typename SocketProtocol::Policy> h(
82 ClientSocketHandle<typename SocketProtocol::Policy>::cast_dynamic(handle));
83 // throw std::bad_cast if the protocol is invalid
84 dynamic_cast<SocketProtocol const &>(static_cast<SocketBody&>(FileHandle::body(h)).protocol());
85 return cast_static(handle);
88 template <class SocketProtocol>
90 senf::ProtocolClientSocketHandle<SocketProtocol>::state(SocketStateMap & map,
93 map["handle"] = prettyName(typeid(*this));
94 this->body().state(map,lod);
97 template <class SocketProtocol>
99 senf::ProtocolClientSocketHandle<SocketProtocol>::dumpState(unsigned lod)
103 return detail::dumpState(map);
106 ///////////////////////////////cti.e///////////////////////////////////////
113 // c-file-style: "senf"
114 // indent-tabs-mode: nil
115 // ispell-local-dictionary: "american"
116 // compile-command: "scons -u test"
117 // comment-column: 40