SocketSink.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 SocketSink inline template implementation */
16 
17 //#include "SocketSink.ih"
18 
19 // Custom includes
20 
21 #define prefix_ inline
22 //-/////////////////////////////////////////////////////////////////////////////////////////////////
23 
24 //-/////////////////////////////////////////////////////////////////////////////////////////////////
25 // senf::ppi::TargetDgramWriter<HandleType>
26 
27 template <class HandleType>
28 prefix_ senf::ppi::TargetDgramWriter<HandleType>::TargetDgramWriter()
29 {}
30 
31 template <class HandleType>
32 prefix_ senf::ppi::TargetDgramWriter<HandleType>::
33 TargetDgramWriter(typename Handle::Address const & target)
34 : target_ (target)
35 {}
36 
37 template <class HandleType>
38 prefix_ typename senf::ppi::TargetDgramWriter<HandleType>::Handle::Address
39 senf::ppi::TargetDgramWriter<HandleType>::target()
40  const
41 {
42  return target_;
43 }
44 
45 template <class HandleType>
46 prefix_ void
47 senf::ppi::TargetDgramWriter<HandleType>::target(typename Handle::Address const & target)
48 {
49  target_ = target;
50 }
51 
52 template <class HandleType>
53 prefix_ bool senf::ppi::TargetDgramWriter<HandleType>::operator()(Handle & handle,
54  Packet const & packet)
55 {
56  if (target_)
57  return handle.writeto(target_, packet.data()) != packet.data().begin();
58  return false;
59 }
60 
61 //-/////////////////////////////////////////////////////////////////////////////////////////////////
62 // senf::ppi::module::ActiveSocketSink<Writer>
63 
64 template <class Writer>
65 prefix_ Writer & senf::ppi::module::ActiveSocketSink<Writer>::writer()
66 {
67  return writer_;
68 }
69 
70 template <class Writer>
71 prefix_ typename senf::ppi::module::ActiveSocketSink<Writer>::Handle
72 senf::ppi::module::ActiveSocketSink<Writer>::handle()
73 {
74  return handle_;
75 }
76 
77 template <class Writer>
78 prefix_ void senf::ppi::module::ActiveSocketSink<Writer>::handle(Handle const & handle)
79 {
80  handle_ = handle;
81  event_.set(handle_, IOEvent::Write);
82 }
83 
84 //-/////////////////////////////////////////////////////////////////////////////////////////////////
85 // senf::ppi::module::PassiveSocketSink<Writer>
86 
87 template <class Writer>
88 prefix_ Writer & senf::ppi::module::PassiveSocketSink<Writer>::writer()
89 {
90  return writer_;
91 }
92 
93 template <class Writer>
94 prefix_ typename Writer::Handle & senf::ppi::module::PassiveSocketSink<Writer>::handle()
95 {
96  return handle_;
97 }
98 
99 template <class Writer>
100 prefix_ void senf::ppi::module::PassiveSocketSink<Writer>::handle(Handle const & handle)
101 {
102  handle_ = handle;
103  checkThrottle();
104 }
105 
106 //-/////////////////////////////////////////////////////////////////////////////////////////////////
107 #undef prefix_
108 
109 
110 // Local Variables:
111 // mode: c++
112 // fill-column: 100
113 // comment-column: 40
114 // c-file-style: "senf"
115 // indent-tabs-mode: nil
116 // ispell-local-dictionary: "american"
117 // compile-command: "scons -u test"
118 // End: