Events.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 Events inline template implementation */
16 
17 #include "Events.ih"
18 
19 // Custom includes
20 #include <senf/Utils/senfassert.hh>
21 #include "detail/EventBinding.hh"
22 
23 #define prefix_ inline
24 //-/////////////////////////////////////////////////////////////////////////////////////////////////
25 
26 //-/////////////////////////////////////////////////////////////////////////////////////////////////
27 // senf::ppi::EventImplementationHelper<EventType,Self>
28 
29 //-/////////////////////////////////////////////////////////////////////////////////////////////////
30 // protected members
31 
32 template <class EventType, class Self>
33 prefix_ void
34 senf::ppi::EventImplementationHelper<EventType,Self>::callback(EventArg event,
35  ClockService::clock_type time)
36 {
37  binding().callback(event,time);
38 }
39 
40 template <class EventType, class Self>
41 prefix_ void senf::ppi::EventImplementationHelper<EventType,Self>::callback(EventArg event)
42 {
43  binding().callback(event);
44 }
45 
46 //-/////////////////////////////////////////////////////////////////////////////////////////////////
47 // private members
48 
49 template <class EventType, class Self>
50 prefix_ senf::ppi::detail::EventBinding<EventType> &
51 senf::ppi::EventImplementationHelper<EventType,Self>::binding()
52 {
53  SENF_ASSERT( static_cast<Self*>(this)->binding_,
54  "senf::ppi::EventImplementationHelper::binding(): Missing registerEvent()" );
55  return * static_cast<Self*>(this)->binding_;
56 }
57 
58 //-/////////////////////////////////////////////////////////////////////////////////////////////////
59 // senf::ppi::EventImplementationHelper<void,Self>
60 
61 //-/////////////////////////////////////////////////////////////////////////////////////////////////
62 // protected members
63 
64 template <class Self>
65 prefix_ void
66 senf::ppi::EventImplementationHelper<void,Self>::callback(ClockService::clock_type time)
67 {
68  binding().callback(time);
69 }
70 
71 template <class Self>
72 prefix_ void senf::ppi::EventImplementationHelper<void,Self>::callback()
73 {
74  binding().callback();
75 }
76 
77 //-/////////////////////////////////////////////////////////////////////////////////////////////////
78 // private members
79 
80 template <class Self>
81 prefix_ senf::ppi::detail::EventBinding<void> &
82 senf::ppi::EventImplementationHelper<void,Self>::binding()
83 {
84  SENF_ASSERT( static_cast<Self*>(this)->binding_,
85  "senf::ppi::EventImplementationHelper::binding(): Missing registerEvent()" );
86  return * static_cast<Self*>(this)->binding_;
87 }
88 
89 //-/////////////////////////////////////////////////////////////////////////////////////////////////
90 // senf::ppi::EventImplementation<EventType>
91 
92 template <class EventType>
93 prefix_ senf::ppi::module::Module & senf::ppi::EventImplementation<EventType>::module()
94  const
95 {
96  return binding_->module();
97 }
98 
99 template <class EventType>
100 prefix_ senf::ppi::EventManager & senf::ppi::EventImplementation<EventType>::manager()
101  const
102 {
103  return binding_->manager();
104 }
105 
106 //-/////////////////////////////////////////////////////////////////////////////////////////////////
107 // protected members
108 
109 template <class EventType>
110 prefix_ senf::ppi::EventImplementation<EventType>::EventImplementation()
111  : binding_(nullptr)
112 {}
113 
114 //-/////////////////////////////////////////////////////////////////////////////////////////////////
115 // private members
116 
117 template <class EventType>
118 prefix_ bool senf::ppi::EventImplementation<EventType>::v_isRegistered()
119 {
120  return binding_;
121 }
122 
123 template <class EventType>
124 prefix_ void
125 senf::ppi::EventImplementation<EventType>::setBinding(detail::EventBinding<Event> & binding)
126 {
127  binding_ = &binding;
128 }
129 
130 //-/////////////////////////////////////////////////////////////////////////////////////////////////
131 #undef prefix_
132 
133 
134 // Local Variables:
135 // mode: c++
136 // fill-column: 100
137 // comment-column: 40
138 // c-file-style: "senf"
139 // indent-tabs-mode: nil
140 // ispell-local-dictionary: "american"
141 // compile-command: "scons -u test"
142 // End: