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
27 #ifndef HH_SocketHandle_
28 #define HH_SocketHandle_ 1
31 #include <memory> // std::auto_ptr
32 #include "FileHandle.hh"
33 #include "SocketPolicy.hh"
35 //#include "SocketHandle.mpp"
36 #include "SocketHandle.ih"
37 ///////////////////////////////hh.p////////////////////////////////////////
38 #include "SocketHandle.ih"
45 template <class SocketPolicy>
50 ///////////////////////////////////////////////////////////////////////////
53 typedef SocketPolicy Policy;
55 template <class OtherPolicy>
57 : public boost::enable_if< SocketPolicyIsBaseOf<SocketPolicy,OtherPolicy>,
61 ///////////////////////////////////////////////////////////////////////////
62 ///\name Structors and default members
65 // default copy constructor
66 // default copy assignment
69 // conversion constructors
70 template <class OtherPolicy>
71 SocketHandle(SocketHandle<OtherPolicy> other,
72 typename IsCompatible<OtherPolicy>::type * = 0);
75 ///////////////////////////////////////////////////////////////////////////
77 template <class OtherPolicy>
78 typename IsCompatible<OtherPolicy>::type const & operator=(SocketHandle<OtherPolicy> other);
80 static SocketHandle cast_static(FileHandle handle);
81 static SocketHandle cast_dynamic(FileHandle handle);
83 void state(SocketStateMap & map, unsigned lod=0);
84 std::string dumpState(unsigned lod=0);
87 explicit SocketHandle(std::auto_ptr<SocketProtocol> protocol, bool isServer);
88 SocketHandle(FileHandle other, bool isChecked);
91 SocketBody const & body() const;
92 SocketProtocol const & protocol() const;
94 void assign(FileHandle other);
100 template <class Policy>
101 std::ostream & operator<<(std::ostream & os, SocketHandle<Policy> handle);
103 template <class Target, class Source>
104 Target static_socket_cast(Source handle);
106 template <class Target, class Source>
107 Target dynamic_socket_cast(Source handle);
109 template <class Target, class Source>
110 bool check_socket_cast(Source handle);
113 ///////////////////////////////hh.e////////////////////////////////////////
114 #include "SocketHandle.cci"
115 #include "SocketHandle.ct"
116 #include "SocketHandle.cti"
122 // c-file-style: "senf"