EventBinding.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 EventBinding inline template implementation */
16 
17 //#include "EventBinding.ih"
18 
19 // Custom includes
20 #include <senf/PPI/EventManager.hh>
21 
22 #define prefix_ inline
23 //-/////////////////////////////////////////////////////////////////////////////////////////////////
24 
25 //-/////////////////////////////////////////////////////////////////////////////////////////////////
26 // senf::ppi::detail::EventBindingHelper<EventType,Self>
27 
28 template <class EventType, class Self>
29 prefix_ void
30 senf::ppi::detail::EventBindingHelper<EventType,Self>::callback(EventArg event,
31  ClockService::clock_type time)
32 {
33  self().eventTime(time);
34  self().callback_(event);
35 }
36 
37 template <class EventType, class Self>
38 prefix_ void senf::ppi::detail::EventBindingHelper<EventType,Self>::callback(EventArg event)
39 {
40  callback(event, self().manager().now());
41 }
42 
43 //-/////////////////////////////////////////////////////////////////////////////////////////////////
44 // private members
45 
46 template <class EventType, class Self>
47 prefix_ Self & senf::ppi::detail::EventBindingHelper<EventType,Self>::self()
48 {
49  return * static_cast<Self*>(this);
50 }
51 
52 //-/////////////////////////////////////////////////////////////////////////////////////////////////
53 // senf::ppi::detail::EventBindingHelper<void,Self>
54 
55 template <class Self>
56 prefix_ void
57 senf::ppi::detail::EventBindingHelper<void,Self>::callback(ClockService::clock_type time)
58 {
59  self().eventTime(time);
60  self().callback_();
61 }
62 
63 template <class Self>
64 prefix_ void senf::ppi::detail::EventBindingHelper<void,Self>::callback()
65 {
66  callback(self().manager().now());
67 }
68 
69 //-/////////////////////////////////////////////////////////////////////////////////////////////////
70 // private members
71 
72 template <class Self>
73 prefix_ Self & senf::ppi::detail::EventBindingHelper<void,Self>::self()
74 {
75  return * static_cast<Self*>(this);
76 }
77 
78 //-/////////////////////////////////////////////////////////////////////////////////////////////////
79 // senf::ppi::detail::EventBinding<EvImpl>
80 
81 template <class EventType>
82 prefix_ senf::ppi::detail::EventBinding<EventType>::EventBinding(EventManager & manager,
83  module::Module & module,
84  Callback callback,
85  EventDescriptor & descriptor)
86  : EventBindingBase(manager, module, descriptor), callback_(callback)
87 {}
88 
89 //-/////////////////////////////////////////////////////////////////////////////////////////////////
90 #undef prefix_
91 
92 
93 // Local Variables:
94 // mode: c++
95 // fill-column: 100
96 // comment-column: 40
97 // c-file-style: "senf"
98 // indent-tabs-mode: nil
99 // ispell-local-dictionary: "american"
100 // compile-command: "scons -u ../test"
101 // End: