EventManager.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_EventManager_
18 #define HH_SENF_PPI_EventManager_ 1
19 
20 // Custom includes
21 #include <boost/noncopyable.hpp>
22 #include <boost/ptr_container/ptr_vector.hpp>
24 #include "predecl.hh"
25 #include "detail/Callback.hh"
26 #include "detail/EventBinding.hh"
27 
28 //#include "EventManager.mpp"
29 //-/////////////////////////////////////////////////////////////////////////////////////////////////
30 
31 namespace senf {
32 namespace ppi {
33 
41  : boost::noncopyable
42  {
43  public:
44  //-////////////////////////////////////////////////////////////////////////
45  // Types
46 
47 #ifndef DOXYGEN
48  // Somehow doxygen barfs on this definition
49  template <class Descriptor>
50  struct Callback
51  : public detail::Callback<typename Descriptor::EventArg>
52  {};
53 #endif
54 
55  //-////////////////////////////////////////////////////////////////////////
57  //\{
58 
59  static EventManager & instance();
60  static bool alive();
61 
62  // default default constructor
63  // default copy constructor
64  // default copy assignment
65  // default destructor
66 
67  // no conversion constructors
68 
69  //\}
70  //-////////////////////////////////////////////////////////////////////////
71 
72  ClockService::clock_type const & now();
73  ClockService::clock_type const & time();
74 
75  protected:
76 
77  private:
78  EventManager();
79  ~EventManager();
80 
81  template <class Descriptor>
82  void registerEvent(module::Module & module,
83  typename Callback<Descriptor>::type callback,
84  Descriptor & descriptor);
85 
86  void destroyModule(module::Module & module);
87  void destroyEvent(EventDescriptor & event);
88 
89  typedef boost::ptr_vector<detail::EventBindingBase> EventRegistrations;
90  EventRegistrations registrations_;
91 
92  void eventTime(ClockService::clock_type const & time);
93 
94  ClockService::clock_type eventTime_;
95 
96  static bool alive_;
97 
99  friend class module::Module;
100  friend class EventDescriptor;
101  };
102 
103 }}
104 
105 //-/////////////////////////////////////////////////////////////////////////////////////////////////
106 #include "EventManager.cci"
107 #include "EventManager.ct"
108 //#include "EventManager.cti"
109 #endif
110 
111 
112 // Local Variables:
113 // mode: c++
114 // fill-column: 100
115 // comment-column: 40
116 // c-file-style: "senf"
117 // indent-tabs-mode: nil
118 // ispell-local-dictionary: "american"
119 // compile-command: "scons -u test"
120 // 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
ClockService::clock_type const & time()
Expected time of the last event.
ClockService::clock_type const & now()
Current time at last event dispatch.
Provide callbacks with a single optional argument.
Definition: Callback.hh:45
Generic event interface base-class.
Definition: Events.hh:60
Event registry and control.
Definition: EventManager.hh:40
predecl public header
ClockService::clock_type const & eventTime()
static EventManager & instance()
EventBinding public header.