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 ProtocolServerSocketHandle inline template implementation
32 // Definition of inline template functions
34 //#include "ProtocolServerSocketHandle.ih"
37 #include <senf/Utils/senfassert.hh>
38 #include "ProtocolClientSocketHandle.hh"
40 #define prefix_ inline
41 //-/////////////////////////////////////////////////////////////////////////////////////////////////
43 template <class SocketProtocol>
44 prefix_ senf::ProtocolServerSocketHandle<SocketProtocol>::
45 ProtocolServerSocketHandle(senf::NoInit_t)
48 template <class SocketProtocol>
49 prefix_ senf::ProtocolServerSocketHandle<SocketProtocol>::ProtocolServerSocketHandle()
50 : ServerSocketHandle<typename SocketProtocol::Policy>(
51 std::auto_ptr<senf::SocketBody>(new ProtocolSocketBody<SocketProtocol>(true)))
54 #define BOOST_PP_ITERATION_PARAMS_1 \
55 (4, (1, 9, SENF_ABSOLUTE_INCLUDE_PATH(Socket/ProtocolServerSocketHandle.mpp), 2))
56 #include BOOST_PP_ITERATE()
58 template <class SocketProtocol>
59 prefix_ SocketProtocol &
60 senf::ProtocolServerSocketHandle<SocketProtocol>::protocol()
62 SENF_ASSERT( dynamic_cast<SocketProtocol const *>(&this->body().protocol()),
63 "Internal failure: Incompatible protocol class fount it's way into this handle");
64 // Need dynamic_cast here, since senf::SocketProtocol is a
66 return dynamic_cast<SocketProtocol &>(this->body().protocol());
69 template <class SocketProtocol>
70 prefix_ senf::ProtocolClientSocketHandle<SocketProtocol>
71 senf::ProtocolServerSocketHandle<SocketProtocol>::accept()
73 return ProtocolClientSocketHandle<SocketProtocol>(
74 FileHandle(this->ServerSocketHandle<typename SocketProtocol::Policy>::accept()),true);
77 template <class SocketProtocol>
78 prefix_ senf::ProtocolServerSocketHandle<SocketProtocol>
79 senf::ProtocolServerSocketHandle<SocketProtocol>::cast_static(FileHandle handle)
81 return ProtocolServerSocketHandle(handle,true);
84 template <class SocketProtocol>
85 prefix_ senf::ProtocolServerSocketHandle<SocketProtocol>
86 senf::ProtocolServerSocketHandle<SocketProtocol>::cast_dynamic(FileHandle handle)
88 ServerSocketHandle<typename SocketProtocol::Policy> h (
89 ServerSocketHandle<typename SocketProtocol::Policy>::cast_dynamic(handle));
90 // throw std::bad_cast if the protocol is invalid
91 IGNORE( dynamic_cast<SocketProtocol const &>(static_cast<SocketBody&>(FileHandle::body(h)).protocol()) );
92 return cast_static(handle);
95 template <class SocketProtocol>
97 senf::ProtocolServerSocketHandle<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::ProtocolServerSocketHandle<SocketProtocol>::dumpState(unsigned lod)
114 return detail::dumpState(map);
117 template <class SocketProtocol>
118 prefix_ senf::ProtocolServerSocketHandle<SocketProtocol>::
119 ProtocolServerSocketHandle(FileHandle other, bool isChecked)
120 : ServerSocketHandle<typename SocketProtocol::Policy>(other,isChecked)
123 //-/////////////////////////////////////////////////////////////////////////////////////////////////
130 // c-file-style: "senf"
131 // indent-tabs-mode: nil
132 // ispell-local-dictionary: "american"
133 // compile-command: "scons -u test"
134 // comment-column: 40