ReadWritePolicy.cti
Go to the documentation of this file.
1 //
2 // Copyright (c) 2020 Fraunhofer Institute for Applied Information Technology (FIT)
3 // Network Research Group (NET)
4 // Schloss Birlinghoven, 53754 Sankt Augustin, GERMANY
5 // Contact: support@wiback.org
6 //
7 // This file is part of the SENF code tree.
8 // It is licensed under the 3-clause BSD License (aka New BSD License).
9 // See LICENSE.txt in the top level directory for details or visit
10 // https://opensource.org/licenses/BSD-3-Clause
11 //
12 
13 
14 /** \file
15  \brief ReadPolicy and WritePolicy inline template implementation
16  */
17 
18 //#include "ReadWritePolicy.ih"
19 
20 // Custom includes
21 
22 #define prefix_ inline
23 //-/////////////////////////////////////////////////////////////////////////////////////////////////
24 
25 #ifndef DOXYGEN
26 template <class SPolicy>
27 prefix_ unsigned senf::ReadablePolicy::
28 readfrom(ClientSocketHandle<SPolicy> & handle, char * buffer, unsigned size,
29  typename SPolicy::AddressingPolicy::Address & address,
30  typename IfCommunicationPolicyIs<SPolicy,UnconnectedCommunicationPolicy>::type *)
31 {
32  return do_readfrom(handle, buffer, size, address.sockaddr_p(), address.socklen_p());
33 }
34 #else
35 template <class SPolicy>
36 prefix_ unsigned senf::ReadablePolicy::
37 readfrom(ClientSocketHandle<SPolicy> & handle, char * buffer, unsigned size,
38  typename Policy::AddressingPolicy::Address & address)
39 {}
40 #endif
41 
42 #ifndef DOXYGEN
43 template <class SPolicy>
44 prefix_ unsigned senf::WriteablePolicy::
45 write(ClientSocketHandle<SPolicy> & handle, char const * buffer, unsigned size,
46  typename IfCommunicationPolicyIs<SPolicy,ConnectedCommunicationPolicy>::type *)
47 {
48  return do_write(handle,buffer,size);
49 }
50 #else
51 template <class SPolicy>
52 prefix_ unsigned senf::WriteablePolicy::
53 write(ClientSocketHandle<SPolicy> & handle, char const * buffer, unsigned size)
54 {}
55 #endif
56 
57 #ifndef DOXYGEN
58 template <class SPolicy>
59 prefix_ unsigned senf::WriteablePolicy::
60 writeto(ClientSocketHandle<SPolicy> & handle,
61  typename boost::call_traits<typename SPolicy::AddressingPolicy::Address>::param_type addr,
62  char const * buffer, unsigned size,
63  typename IfCommunicationPolicyIs<SPolicy,UnconnectedCommunicationPolicy>::type *)
64 {
65  return do_writeto(handle, buffer, size, addr.sockaddr_p(), addr.socklen());
66 }
67 #else
68 template <class SPolicy>
69 prefix_ unsigned senf::WriteablePolicy::
70 writeto(ClientSocketHandle<SPolicy> & handle,
71  typename Policy::AddressingPolicy::Address const & addr,
72  char const * buffer, unsigned size)
73 {}
74 #endif
75 
76 //-/////////////////////////////////////////////////////////////////////////////////////////////////
77 #undef prefix_
78 
79 
80 // Local Variables:
81 // mode: c++
82 // fill-column: 100
83 // c-file-style: "senf"
84 // indent-tabs-mode: nil
85 // ispell-local-dictionary: "american"
86 // compile-command: "scons -u test"
87 // comment-column: 40
88 // End: