Fixed whitespace in all files (no tabs)
[senf.git] / Socket / ProtocolServerSocketHandle.cti
1 // $Id$
2 //
3 // Copyright (C) 2006
4 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
5 // Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
6 //     Stefan Bund <stefan.bund@fokus.fraunhofer.de>
7 //
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.
12 //
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.
17 //
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.
22
23 /** \file
24     \brief ProtocolServerSocketHandle inline template implementation
25  */
26
27 // Definition of inline template functions
28
29 //#include "ProtocolServerSocketHandle.ih"
30
31 // Custom includes
32 #include "ProtocolClientSocketHandle.hh"
33
34 #define prefix_ inline
35 ///////////////////////////////cti.p///////////////////////////////////////
36
37 template <class SocketProtocol>
38 prefix_ senf::ProtocolServerSocketHandle<SocketProtocol>::ProtocolServerSocketHandle()
39     : ServerSocketHandle<typename SocketProtocol::Policy>(
40         std::auto_ptr<senf::SocketProtocol>(new SocketProtocol()))
41 {}
42
43 #define BOOST_PP_ITERATION_PARAMS_1 (4, (1, 9, "Socket/ProtocolServerSocketHandle.mpp", 2))
44 #include BOOST_PP_ITERATE()
45
46 template <class SocketProtocol>
47 prefix_ SocketProtocol const &
48 senf::ProtocolServerSocketHandle<SocketProtocol>::protocol()
49 {
50     BOOST_ASSERT( dynamic_cast<SocketProtocol const *>(&this->body().protocol()) );
51     // Need dynamic_cast here, since senf::SocketProtocol is a
52     // virtual base
53     return dynamic_cast<SocketProtocol const &>(this->body().protocol());
54 }
55
56 template <class SocketProtocol>
57 prefix_ senf::ProtocolClientSocketHandle<SocketProtocol>
58 senf::ProtocolServerSocketHandle<SocketProtocol>::accept()
59 {
60     return ProtocolClientSocketHandle<SocketProtocol>(
61         FileHandle(this->ServerSocketHandle<typename SocketProtocol::Policy>::accept()),true);
62 }
63
64 template <class SocketProtocol>
65 prefix_ senf::ProtocolServerSocketHandle<SocketProtocol>
66 senf::ProtocolServerSocketHandle<SocketProtocol>::cast_static(FileHandle handle)
67 {
68     return ProtocolServerSocketHandle(handle,true);
69 }
70
71 template <class SocketProtocol>
72 prefix_ senf::ProtocolServerSocketHandle<SocketProtocol>
73 senf::ProtocolServerSocketHandle<SocketProtocol>::cast_dynamic(FileHandle handle)
74 {
75     ServerSocketHandle<typename SocketProtocol::Policy> h(
76         ServerSocketHandle<typename SocketProtocol::Policy>::cast_dynamic(handle));
77     // throw std::bad_cast if the protocol is invalid
78     dynamic_cast<SocketProtocol const &>(static_cast<SocketBody&>(FileHandle::body(h)).protocol());
79     return cast_static(handle);
80 }
81
82 template <class SocketProtocol>
83 prefix_ void
84 senf::ProtocolServerSocketHandle<SocketProtocol>::state(SocketStateMap & map,
85                                                                unsigned lod)
86 {
87     map["handle"] = prettyName(typeid(*this));
88     this->body().state(map,lod);
89 }
90
91 template <class SocketProtocol>
92 prefix_ std::string
93 senf::ProtocolServerSocketHandle<SocketProtocol>::dumpState(unsigned lod)
94 {
95     SocketStateMap map;
96     state(map,lod);
97     return detail::dumpState(map);
98 }
99
100 template <class SocketProtocol>
101 prefix_ senf::ProtocolServerSocketHandle<SocketProtocol>::
102 ProtocolServerSocketHandle(FileHandle other, bool isChecked)
103     : ServerSocketHandle<typename SocketProtocol::Policy>(other,isChecked)
104 {}
105
106 ///////////////////////////////cti.e///////////////////////////////////////
107 #undef prefix_
108
109 \f
110 // Local Variables:
111 // mode: c++
112 // fill-column: 100
113 // c-file-style: "senf"
114 // indent-tabs-mode: nil
115 // ispell-local-dictionary: "american"
116 // End: