Fix documentation build under maverick (doxygen 1.7.1)
[senf.git] / senf / Socket / SocketPolicy.test.hh
1 // $Id$
2 //
3 // Copyright (C) 2006
4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 //     Stefan Bund <g0dil@berlios.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_SENF_Socket_SocketPolicy_test_
24 #define HH_SENF_Socket_SocketPolicy_test_ 1
25
26 // Custom includes
27 #include "SocketPolicy.hh"
28 #include "FileHandle.hh"
29
30 //#include "SocketPolicy.test.mpp"
31 //-/////////////////////////////////////////////////////////////////////////////////////////////////
32
33 namespace senf {
34 namespace test {
35
36     struct SomeAddressingPolicy : public senf::AddressingPolicyBase
37     {
38         typedef unsigned Address;
39
40         static void peer(FileHandle handle, unsigned & addr)
41             { addr=1; }
42         static void local(FileHandle, unsigned & addr)
43             { addr=2; }
44         static void connect(FileHandle, unsigned addr)
45             {}
46         static void bind(FileHandle, unsigned addr)
47             {}
48     };
49
50     struct SomeFramingPolicy : public senf::FramingPolicyBase
51     {};
52
53     struct SomeCommunicationPolicy : public senf::CommunicationPolicyBase
54     {
55         static int accept(FileHandle handle, unsigned & addr)
56             { addr = 3; return -1; }
57         static int accept(FileHandle handle)
58             { return -1; }
59     };
60
61     struct SomeReadPolicy : public senf::ReadPolicyBase
62     {
63         static unsigned const TEST_SIZE = 9;
64
65         static unsigned read(FileHandle handle, char * buffer, unsigned size)
66             {
67                 int const n (size<TEST_SIZE?size:TEST_SIZE);
68                 ::memcpy(buffer,"TEST-READ",n);
69                 return n;
70             }
71
72         static unsigned readfrom(FileHandle handle, char * buffer, unsigned size,
73                                  unsigned & address)
74             {
75                 return read(handle,buffer,size);
76             }
77     };
78
79     struct SomeWritePolicy : public senf::WritePolicyBase
80     {
81         static unsigned write(FileHandle handle, char const * buffer, unsigned size)
82             {
83                 if (size == 10 && ::strncmp(buffer,"TEST-WRITE",10) == 0)
84                     return size;
85                 else
86                     return 0;
87             }
88
89         static unsigned writeto(FileHandle handle, unsigned address,
90                                 char const * buffer, unsigned size)
91             {
92                 return write(handle,buffer,size);
93             }
94     };
95
96     typedef senf::MakeSocketPolicy<
97         SomeAddressingPolicy,
98         SomeFramingPolicy,
99         SomeCommunicationPolicy,
100         SomeReadPolicy,
101         SomeWritePolicy
102         >::policy SomeSocketPolicy;
103
104 }}
105
106 //-/////////////////////////////////////////////////////////////////////////////////////////////////
107 //#include "SocketPolicy.test.cci"
108 //#include "SocketPolicy.test.ct"
109 //#include "SocketPolicy.test.cti"
110 //#include "SocketPolicy.test.mpp"
111 #endif
112
113 \f
114 // Local Variables:
115 // mode: c++
116 // fill-column: 100
117 // c-file-style: "senf"
118 // indent-tabs-mode: nil
119 // ispell-local-dictionary: "american"
120 // compile-command: "scons -u test"
121 // comment-column: 40
122 // End: