FastConnector.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 FastConnector inline template implementation */
16 
17 //#include "FastConnector.ih"
18 
19 // Custom includes
20 #include <senf/Utils/type_traits.hh>
21 
22 #define prefix_ inline
23 ///////////////////////////////cti.p///////////////////////////////////////
24 
25 ///////////////////////////////////////////////////////////////////////////
26 // senf::ppi::connector::FastPassiveInput<PacketType>
27 
28 template <class PacketType>
29 prefix_ senf::ppi::connector::FastPassiveInput<PacketType>::FastPassiveInput()
30 {}
31 
32 template <class PacketType>
33 prefix_ senf::ppi::connector::FastPassiveInput<PacketType>::~FastPassiveInput()
34 {
35  unregisterConnector();
36 }
37 
38 template <class PacketType>
39 prefix_ senf::ppi::connector::FastActiveOutput<PacketType> &
40 senf::ppi::connector::FastPassiveInput<PacketType>::peer()
41  const
42 {
43  return static_cast<FastActiveOutput<PacketType> &>(Connector::peer());
44 }
45 
46 template <class PacketType>
47 template <class Handler>
48 prefix_ void senf::ppi::connector::FastPassiveInput<PacketType>::onRequest(Handler handler)
49 {
50  cb_.bind(static_cast<typename senf::member_class<Handler>::type *>(& module()), handler);
51 }
52 
53 template <class PacketType>
54 prefix_ PacketType const & senf::ppi::connector::FastPassiveInput<PacketType>::operator()()
55  const
56 {
57  SENF_ASSERT( packet_, "FastPassiveInput::operator() called without being signaled (no packet)" );
58  return * packet_;
59 }
60 
61 template <class PacketType>
62 prefix_ void senf::ppi::connector::FastPassiveInput<PacketType>::v_init()
63 {}
64 
65 ///////////////////////////////////////////////////////////////////////////
66 // senf::ppi::connector::FastActiveOutput<PacketType>
67 
68 template <class PacketType>
69 prefix_ senf::ppi::connector::FastActiveOutput<PacketType>::FastActiveOutput()
70 {}
71 
72 template <class PacketType>
73 prefix_ senf::ppi::connector::FastActiveOutput<PacketType>::~FastActiveOutput()
74 {
75  unregisterConnector();
76 }
77 
78 template <class PacketType>
79 prefix_ senf::ppi::connector::FastPassiveInput<PacketType> &
80 senf::ppi::connector::FastActiveOutput<PacketType>::peer()
81  const
82 {
83  return static_cast<FastPassiveInput<PacketType> &>(Connector::peer());
84 }
85 
86 template <class PacketType>
87 prefix_ void
88 senf::ppi::connector::FastActiveOutput<PacketType>::operator()(PacketType const & packet)
89  const
90 {
91  peer().packet_ = & packet;
92  peer().cb_();
93  peer().packet_ = 0;
94 }
95 
96 template <class PacketType>
97 prefix_ void senf::ppi::connector::FastActiveOutput<PacketType>::v_init()
98 {}
99 
100 ///////////////////////////////////////////////////////////////////////////
101 
102 template <class PacketType>
103 prefix_ void senf::ppi::connect(connector::FastActiveOutput<PacketType> & source,
104  connector::FastPassiveInput<PacketType> & target)
105 {
106  source.connect(target);
107 }
108 
109 ///////////////////////////////cti.e///////////////////////////////////////
110 #undef prefix_
111 
112 
113 // Local Variables:
114 // mode: c++
115 // fill-column: 100
116 // comment-column: 40
117 // c-file-style: "senf"
118 // indent-tabs-mode: nil
119 // ispell-local-dictionary: "american"
120 // compile-command: "scons -u test"
121 // End: