Implemented global cross-reference generation
[senf.git] / Socket / SocketProtocol.hh
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 #ifndef HH_SocketProtocol_
24 #define HH_SocketProtocol_ 1
25
26 // Custom includes
27 #include <boost/utility.hpp>
28 /** \fixme this is not nice. The includes and predefs should be restructured */
29 #include "SocketHandle.ih"
30
31 //#include "SocketProtocol.mpp"
32 ///////////////////////////////hh.p////////////////////////////////////////
33
34 namespace senf {
35
36
37     class SocketPolicyBase;
38
39     class SocketProtocol : boost::noncopyable
40     {
41     public:
42         ///////////////////////////////////////////////////////////////////////////
43         // Types
44
45         ///////////////////////////////////////////////////////////////////////////
46         ///\name Structors and default members
47         ///@{
48
49         SocketProtocol();
50         virtual ~SocketProtocol() = 0;
51
52         // default default constructor
53         // no copy
54         // no conversion constructors
55
56         ///@}
57         ///////////////////////////////////////////////////////////////////////////
58
59         SocketBody & body() const;
60         virtual SocketPolicyBase const & policy() const = 0;
61         
62         ///////////////////////////////////////////////////////////////////////////
63         // Virtual interface
64
65         virtual std::auto_ptr<SocketProtocol> clone() const = 0;
66         virtual unsigned available() const = 0;
67         virtual bool eof() const = 0;
68         virtual void state(SocketStateMap & map, unsigned lod) const;
69
70     protected:
71
72     private:
73         // backpointer to owning SocketBody instance
74         SocketBody * body_;
75         friend class SocketBody; 
76    };
77
78     template <class SocketPolicy>
79     class ConcreteSocketProtocol
80         : public virtual SocketProtocol
81     {
82     public:
83         ///////////////////////////////////////////////////////////////////////////
84         // Types
85
86         typedef SocketPolicy Policy;
87
88         ///////////////////////////////////////////////////////////////////////////
89         ///\name Structors and default members
90         ///@{
91
92         ~ConcreteSocketProtocol() = 0;
93
94         // no default constructor
95         // no copy
96         // no conversion constructors
97
98         ///@}
99         ///////////////////////////////////////////////////////////////////////////
100
101         Policy const & policy() const;
102
103     protected:
104
105     private:
106         Policy policy_;
107
108     };
109
110 }
111
112 ///////////////////////////////hh.e////////////////////////////////////////
113 #include "SocketProtocol.cci"
114 //#include "SocketProtocol.ct"
115 #include "SocketProtocol.cti"
116 #endif
117
118 \f
119 // Local Variables:
120 // mode: c++
121 // c-file-style: "senf"
122 // End: