Implemented global cross-reference generation
[senf.git] / Socket / ReadWritePolicy.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 /** \file
24
25     \todo ReadWritePolicy.test.cc 
26  */
27
28 #ifndef HH_ReadWritePolicy_
29 #define HH_ReadWritePolicy_ 1
30
31 // Custom includes
32 #include "SocketPolicy.hh"
33 #include "ClientSocketHandle.hh"
34 #include "CommunicationPolicy.hh" 
35
36 //#include "ReadWritePolicy.mpp"
37 ///////////////////////////////hh.p////////////////////////////////////////
38
39
40 struct sockaddr;
41
42 namespace senf {
43
44
45     struct ReadablePolicy : public ReadPolicyBase
46     {
47         static unsigned read(FileHandle handle, char * buffer, unsigned size);
48         template <class Policy>
49         static unsigned readfrom(ClientSocketHandle<Policy> handle, char * buffer, unsigned size,
50                                  typename Policy::AddressingPolicy::Address & address,
51                                  typename IfCommunicationPolicyIs<Policy,UnconnectedCommunicationPolicy>::type * = 0);
52
53     private:
54         static unsigned do_readfrom(FileHandle handle, char * buffer, unsigned size,
55                                     struct ::sockaddr * addr, socklen_t len);
56     };
57
58     struct NotReadablePolicy : public ReadPolicyBase
59     {};
60
61     struct WriteablePolicy : public WritePolicyBase
62     {
63         template <class Policy>
64         static unsigned write(ClientSocketHandle<Policy> handle, char const * buffer, unsigned size,
65                               typename IfCommunicationPolicyIs<Policy,ConnectedCommunicationPolicy>::type * = 0);
66         template <class Policy>
67         static unsigned writeto(ClientSocketHandle<Policy> handle, 
68                                 typename boost::call_traits<typename Policy::AddressingPolicy::Address>::param_type addr,
69                                 char const * buffer, unsigned size,
70                                 typename IfCommunicationPolicyIs<Policy,UnconnectedCommunicationPolicy>::type * = 0);
71
72     private:
73         static unsigned do_write(FileHandle handle, char const * buffer, unsigned size);
74         static unsigned do_writeto(FileHandle handle, char const * buffer, unsigned size,
75                                    struct sockaddr * addr, socklen_t len);
76     };
77     
78     struct NotWriteablePolicy : public WritePolicyBase
79     {};
80
81 }
82
83
84 ///////////////////////////////hh.e////////////////////////////////////////
85 //#include "ReadWritePolicy.cci"
86 //#include "ReadWritePolicy.ct"
87 #include "ReadWritePolicy.cti"
88 #endif
89
90 \f
91 // Local Variables:
92 // mode: c++
93 // c-file-style: "senf"
94 // End: