4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
6 // The contents of this file are subject to the Fraunhofer FOKUS Public License
7 // Version 1.0 (the "License"); you may not use this file except in compliance
8 // with the License. You may obtain a copy of the License at
9 // http://senf.berlios.de/license.html
11 // The Fraunhofer FOKUS Public License Version 1.0 is based on,
12 // but modifies the Mozilla Public License Version 1.1.
13 // See the full license text for the amendments.
15 // Software distributed under the License is distributed on an "AS IS" basis,
16 // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
17 // for the specific language governing rights and limitations under the License.
19 // The Original Code is Fraunhofer FOKUS code.
21 // The Initial Developer of the Original Code is Fraunhofer-Gesellschaft e.V.
22 // (registered association), Hansastraße 27 c, 80686 Munich, Germany.
23 // All Rights Reserved.
26 // Stefan Bund <g0dil@berlios.de>
29 \brief ProtocolClientSocketHandle inline template
33 // Definition of inline template functions
35 //#include "ProtocolClientSocketHandle.ih"
38 #include <senf/Utils/senfassert.hh>
40 #define prefix_ inline
41 //-/////////////////////////////////////////////////////////////////////////////////////////////////
43 template <class SocketProtocol>
44 prefix_ senf::ProtocolClientSocketHandle<SocketProtocol>::
45 ProtocolClientSocketHandle(senf::NoInit_t)
48 template <class SocketProtocol>
49 prefix_ senf::ProtocolClientSocketHandle<SocketProtocol>::ProtocolClientSocketHandle()
50 : ClientSocketHandle<typename SocketProtocol::Policy>(
51 std::auto_ptr<senf::SocketBody>(new senf::ProtocolSocketBody<SocketProtocol>(false)))
53 this->protocol().init_client();
56 #define BOOST_PP_ITERATION_PARAMS_1 \
57 (4, (1, 9, SENF_ABSOLUTE_INCLUDE_PATH(Socket/ProtocolClientSocketHandle.mpp), 2))
58 #include BOOST_PP_ITERATE()
60 template <class SocketProtocol>
61 prefix_ senf::ProtocolClientSocketHandle<SocketProtocol>::
62 ProtocolClientSocketHandle(FileHandle other, bool isChecked)
63 : ClientSocketHandle<typename Protocol::Policy>(other, isChecked)
66 template <class SocketProtocol>
67 prefix_ SocketProtocol &
68 senf::ProtocolClientSocketHandle<SocketProtocol>::protocol()
70 SENF_ASSERT( dynamic_cast<SocketProtocol *>(&this->body().protocol()),
71 "Internal failure: Incompatible protocol class found it's way into this handle");
72 // Need dynamic_cast here, since senf::SocketProtocol is a
74 return dynamic_cast<SocketProtocol &>(this->body().protocol());
77 template <class SocketProtocol>
78 prefix_ senf::ProtocolClientSocketHandle<SocketProtocol>
79 senf::ProtocolClientSocketHandle<SocketProtocol>::cast_static(FileHandle handle)
81 return ProtocolClientSocketHandle(handle,true);
84 template <class SocketProtocol>
85 prefix_ senf::ProtocolClientSocketHandle<SocketProtocol>
86 senf::ProtocolClientSocketHandle<SocketProtocol>::cast_dynamic(FileHandle handle)
88 ClientSocketHandle<typename SocketProtocol::Policy> h(
89 ClientSocketHandle<typename SocketProtocol::Policy>::cast_dynamic(handle));
90 // throw std::bad_cast if the protocol is invalid
91 dynamic_cast<SocketProtocol const &>(static_cast<SocketBody&>(FileHandle::body(h)).protocol());
92 return cast_static(handle);
95 template <class SocketProtocol>
97 senf::ProtocolClientSocketHandle<SocketProtocol>::state(SocketStateMap & map,
100 map["handle"] = prettyName(typeid(*this));
102 map["valid"] << "true";
103 this->body().state(map,lod);
105 map["valid"] << "false";
108 template <class SocketProtocol>
110 senf::ProtocolClientSocketHandle<SocketProtocol>::dumpState(unsigned lod)
114 return detail::dumpState(map);
117 //-/////////////////////////////////////////////////////////////////////////////////////////////////
124 // c-file-style: "senf"
125 // indent-tabs-mode: nil
126 // ispell-local-dictionary: "american"
127 // compile-command: "scons -u test"
128 // comment-column: 40