IntervalTimer.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_IntervalTimer_
18 #define HH_SENF_PPI_IntervalTimer_ 1
19 
20 // Custom includes
23 #include "Events.hh"
24 
25 //#include "IntervalTimer.mpp"
26 //-/////////////////////////////////////////////////////////////////////////////////////////////////
27 
28 namespace senf {
29 namespace ppi {
30 
36  {
39  unsigned number;
40  };
41 
52  : public EventImplementation<IntervalTimerEventInfo>
53  {
54  public:
55  //-////////////////////////////////////////////////////////////////////////
57  //\{
58 
59  explicit IntervalTimer(ClockService::clock_type interval,
60  unsigned eventsPerInterval=1);
61  IntervalTimer();
62 
63  //\}
64  //-////////////////////////////////////////////////////////////////////////
65 
66  void interval(ClockService::clock_type interval, unsigned eventsPerInterval=1);
67  std::pair<ClockService::clock_type, unsigned> interval() const;
68 
69  protected:
70 
71  private:
72  virtual void v_enable();
73  virtual void v_disable();
74 
75  void schedule();
76  void cb();
77 
78  ClockService::clock_type interval_;
79  unsigned eventsPerInterval_;
81  scheduler::TimerEvent timer_;
82  };
83 
84 }}
85 
86 //-/////////////////////////////////////////////////////////////////////////////////////////////////
87 #include "IntervalTimer.cci"
88 //#include "IntervalTimer.ct"
89 //#include "IntervalTimer.cti"
90 #endif
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:
config::time_type clock_type
High precision regularly signaled event.
Event implementation base class.
Definition: Events.hh:169
Events public header.
unsigned number
Number of the current event within the interval.
IntervalTimer event information.
ClockService::clock_type intervalStart
Start of the current time interval.
ClockService::clock_type expected
Scheduled event time.