EventBinding.hh
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 
17 #ifndef HH_SENF_PPI_detail_EventBinding_
18 #define HH_SENF_PPI_detail_EventBinding_ 1
19 
20 // Custom includes
22 #include <senf/PPI/predecl.hh>
23 #include "Callback.hh"
24 
25 //#include "EventBinding.mpp"
26 //-/////////////////////////////////////////////////////////////////////////////////////////////////
27 
28 namespace senf {
29 namespace ppi {
30 namespace detail {
31 
34  {
35  public:
37 
38  EventManager & manager() const;
39  module::Module & module() const;
40 
41  protected:
42  EventBindingBase(EventManager & manager, module::Module & module,
43  EventDescriptor & descriptor);
44 
46 
47  private:
48  EventManager * manager_;
49  module::Module * module_;
50  EventDescriptor * descriptor_;
51 
54  };
55 
58  template <class EventType, class Self>
60  {
61  public:
62  typedef typename detail::EventArgType<EventType>::type EventArg;
63 
64  void callback(EventArg event, ClockService::clock_type time);
65  void callback(EventArg event);
66 
67  private:
68  Self & self();
69  };
70 
71 #ifndef DOXYGEN
72 
73  template <class Self>
74  class EventBindingHelper<void,Self>
75  {
76  public:
77  void callback(ClockService::clock_type time);
78  void callback();
79 
80  private:
81  Self & self();
82  };
83 
84 #endif
85 
87  template <class EventType>
89  : public EventBindingBase,
90  public EventBindingHelper<EventType, EventBinding<EventType> >
91  {
92  public:
93  typedef EventType Event;
94  typedef typename detail::EventArgType<Event>::type EventArg;
96 
97  EventBinding(EventManager & manager, module::Module & module, Callback callback,
98  EventDescriptor & descriptor);
99 
100  private:
101  Callback callback_;
102 
103  friend class EventBindingHelper<EventType, EventBinding<EventType> >;
104  };
105 
106 }}}
107 
108 //-/////////////////////////////////////////////////////////////////////////////////////////////////
109 #include "EventBinding.cci"
110 //#include "EventBinding.ct"
111 #include "EventBinding.cti"
112 #endif
113 
114 
115 // Local Variables:
116 // mode: c++
117 // fill-column: 100
118 // comment-column: 40
119 // c-file-style: "senf"
120 // indent-tabs-mode: nil
121 // ispell-local-dictionary: "american"
122 // compile-command: "scons -u ../test"
123 // End:
Internal: Association Event - Module - Handler, base-class.
Definition: EventBinding.hh:33
config::time_type clock_type
Callback public header.
Module base-class.
Definition: Module.hh:169
detail::EventArgType< EventType >::type EventArg
Definition: EventBinding.hh:62
void eventTime(ClockService::clock_type time)
Definition: EventBinding.cc:35
Generic event interface base-class.
Definition: Events.hh:60
boost::function< void(Arg)> type
Definition: Callback.hh:47
Event registry and control.
Definition: EventManager.hh:40
predecl public header
EventManager & manager() const
Internal: Callback forwarders.
Definition: EventBinding.hh:59
module::Module & module() const
detail::Callback< EventArg >::type Callback
Definition: EventBinding.hh:95
Internal: Association Event - Module - Handler, event type specific.
Definition: EventBinding.hh:88
EventBindingBase(EventManager &manager, module::Module &module, EventDescriptor &descriptor)
detail::EventArgType< Event >::type EventArg
Definition: EventBinding.hh:94