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.
23 // Definition of inline template functions
25 //#include "ClientSocketHandle.ih"
30 #define prefix_ inline
31 ///////////////////////////////cti.p///////////////////////////////////////
33 template <class Policy>
34 template <class OtherPolicy>
35 prefix_ satcom::lib::ClientSocketHandle<Policy>::
36 ClientSocketHandle(ClientSocketHandle<OtherPolicy> other,
37 typename SocketHandle<Policy>::template IsCompatible<OtherPolicy>::type *)
38 : SocketHandle<Policy>(other,true)
41 template <class Policy>
42 prefix_ satcom::lib::ClientSocketHandle<Policy>::ClientSocketHandle(FileHandle other,
44 : SocketHandle<Policy>(other, isChecked)
47 template <class Policy>
48 prefix_ satcom::lib::ClientSocketHandle<Policy>::
49 ClientSocketHandle(std::auto_ptr<SocketProtocol> protocol, int fd)
50 : SocketHandle<Policy>(protocol,false)
55 template <class Policy>
56 template <class OtherPolicy>
57 prefix_ typename satcom::lib::SocketHandle<Policy>::template IsCompatible<OtherPolicy>::type const &
58 satcom::lib::ClientSocketHandle<Policy>::operator=(ClientSocketHandle<OtherPolicy> other)
64 ///////////////////////////////////////////////////////////////////////////
66 ///////////////////////////////////////////////////////////////////////////
67 // reading and writing
69 template <class Policy>
70 prefix_ unsigned satcom::lib::ClientSocketHandle<Policy>::read(char * buffer,
73 return Policy::ReadPolicy::read(*this, buffer, size);
76 template <class Policy>
77 prefix_ unsigned satcom::lib::ClientSocketHandle<Policy>::
78 readfrom(char * buffer, unsigned size, typename Policy::AddressingPolicy::Address & from)
80 return Policy::ReadPolicy::readfrom(*this, buffer, size, from);
83 template <class Policy>
84 prefix_ unsigned satcom::lib::ClientSocketHandle<Policy>::write(char const * buffer,
87 return Policy::WritePolicy::write(*this, buffer, size);
90 template <class Policy>
91 prefix_ unsigned satcom::lib::ClientSocketHandle<Policy>::
92 writeto(typename boost::call_traits<typename Policy::AddressingPolicy::Address>::param_type addr,
93 std::string const & data)
95 return this->writeto(addr, data.data(), data.size());
98 template <class Policy>
99 prefix_ unsigned satcom::lib::ClientSocketHandle<Policy>::
100 writeto(typename boost::call_traits<typename Policy::AddressingPolicy::Address>::param_type addr,
101 char const * buffer, unsigned size)
103 return Policy::WritePolicy::writeto(*this, addr, buffer, size);
106 ///////////////////////////////////////////////////////////////////////////
109 template <class Policy>
110 prefix_ typename Policy::AddressingPolicy::Address
111 satcom::lib::ClientSocketHandle<Policy>::peer()
113 typename Policy::AddressingPolicy::Address addr;
118 template <class Policy>
119 prefix_ void satcom::lib::ClientSocketHandle<Policy>::
120 peer(typename Policy::AddressingPolicy::Address & addr)
122 Policy::AddressingPolicy::peer(*this,addr);
125 template <class Policy>
126 prefix_ typename Policy::AddressingPolicy::Address
127 satcom::lib::ClientSocketHandle<Policy>::local()
129 typename Policy::AddressingPolicy::Address addr;
134 template <class Policy>
135 prefix_ void satcom::lib::ClientSocketHandle<Policy>::
136 local(typename Policy::AddressingPolicy::Address & addr)
138 Policy::AddressingPolicy::local(*this,addr);
141 template <class Policy>
142 prefix_ void satcom::lib::ClientSocketHandle<Policy>::connect(AddressParam addr)
144 Policy::AddressingPolicy::connect(*this,addr);
147 template <class Policy>
148 prefix_ void satcom::lib::ClientSocketHandle<Policy>::
149 bind(typename boost::call_traits<typename Policy::AddressingPolicy::Address>::param_type addr)
151 Policy::AddressingPolicy::bind(*this,addr);
154 ///////////////////////////////////////////////////////////////////////////
157 template <class Policy>
158 prefix_ unsigned satcom::lib::ClientSocketHandle<Policy>::rcvbuf()
160 return Policy::BufferingPolicy::rcvbuf(*this);
163 template <class Policy>
164 prefix_ void satcom::lib::ClientSocketHandle<Policy>::rcvbuf(unsigned size)
166 Policy::BufferingPolicy::rcvbuf(*this,size);
169 template <class Policy>
170 prefix_ unsigned satcom::lib::ClientSocketHandle<Policy>::sndbuf()
172 return Policy::BufferingPolicy::sndbuf(*this);
175 template <class Policy>
176 prefix_ void satcom::lib::ClientSocketHandle<Policy>::sndbuf(unsigned size)
178 Policy::BufferingPolicy::sndbuf(*this,size);
181 ///////////////////////////////////////////////////////////////////////////
183 template <class Policy>
184 prefix_ satcom::lib::ClientSocketHandle<Policy>
185 satcom::lib::ClientSocketHandle<Policy>::cast_static(FileHandle handle)
187 return ClientSocketHandle(handle, true);
190 template <class Policy>
191 prefix_ satcom::lib::ClientSocketHandle<Policy>
192 satcom::lib::ClientSocketHandle<Policy>::cast_dynamic(FileHandle handle)
194 SocketHandle<Policy> h (SocketHandle<Policy>::cast_dynamic(handle));
195 if (static_cast<SocketBody&>(FileHandle::body(h)).isServer())
196 throw std::bad_cast();
197 return cast_static(handle);
200 template <class Policy>
201 prefix_ void satcom::lib::ClientSocketHandle<Policy>::state(SocketStateMap & map, unsigned lod)
203 map["handle"] = prettyName(typeid(*this));
204 this->body().state(map,lod);
207 template <class Policy>
208 prefix_ std::string satcom::lib::ClientSocketHandle<Policy>::dumpState(unsigned lod)
212 return detail::dumpState(map);
215 ///////////////////////////////cti.e///////////////////////////////////////
221 // c-file-style: "satcom"