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 // TODO: Create a SocketHandleBase class and move some non-Policy
24 // dependent code there
26 #ifndef HH_SocketHandle_
27 #define HH_SocketHandle_ 1
30 #include <memory> // std::auto_ptr
31 #include "FileHandle.hh"
32 #include "SocketPolicy.hh"
34 //#include "SocketHandle.mpp"
35 #include "SocketHandle.ih"
36 ///////////////////////////////hh.p////////////////////////////////////////
37 #include "SocketHandle.ih"
44 template <class SocketPolicy>
49 ///////////////////////////////////////////////////////////////////////////
52 typedef SocketPolicy Policy;
54 template <class OtherPolicy>
56 : public boost::enable_if< SocketPolicyIsBaseOf<SocketPolicy,OtherPolicy>,
60 ///////////////////////////////////////////////////////////////////////////
61 ///\name Structors and default members
64 // default copy constructor
65 // default copy assignment
68 // conversion constructors
69 template <class OtherPolicy>
70 SocketHandle(SocketHandle<OtherPolicy> other,
71 typename IsCompatible<OtherPolicy>::type * = 0);
74 ///////////////////////////////////////////////////////////////////////////
76 template <class OtherPolicy>
77 typename IsCompatible<OtherPolicy>::type const & operator=(SocketHandle<OtherPolicy> other);
79 static SocketHandle cast_static(FileHandle handle);
80 static SocketHandle cast_dynamic(FileHandle handle);
82 void state(SocketStateMap & map, unsigned lod=0);
83 std::string dumpState(unsigned lod=0);
86 explicit SocketHandle(std::auto_ptr<SocketProtocol> protocol, bool isServer);
87 SocketHandle(FileHandle other, bool isChecked);
90 SocketBody const & body() const;
91 SocketProtocol const & protocol() const;
93 void assign(FileHandle other);
99 template <class Policy>
100 std::ostream & operator<<(std::ostream & os, SocketHandle<Policy> handle);
102 template <class Target, class Source>
103 Target static_socket_cast(Source handle);
105 template <class Target, class Source>
106 Target dynamic_socket_cast(Source handle);
108 template <class Target, class Source>
109 bool check_socket_cast(Source handle);
112 ///////////////////////////////hh.e////////////////////////////////////////
113 #include "SocketHandle.cci"
114 #include "SocketHandle.ct"
115 #include "SocketHandle.cti"
121 // c-file-style: "satcom"