Simplified XF 1.1.0

timeoutmanager.h
1#ifndef XF_INTERFACE_TIMEOUTMANAGER_H
2#define XF_INTERFACE_TIMEOUTMANAGER_H
3
4#include <cstdint>
5#include <functional>
6
7 namespace interface {
8 class XFBehavior;
9}
10 class XFTimeout;
11
12 namespace interface {
13
25 class XFTimeoutManager
26{
27 public:
28 virtual ~XFTimeoutManager() = default;
29
30 static XFTimeoutManager * getInstance();
31
36 virtual void initialize(int32_t tickInterval)
37 {
38 tickInterval_ = tickInterval;
39 }
40
44 virtual int32_t getTickInterval() const
45 {
46 return tickInterval_;
47 }
48
52 virtual void start(std::function<void(uint32_t)> startTimeoutManagerTimer = nullptr) = 0;
53
61 virtual void scheduleTimeout(int32_t timeoutId, int32_t interval, interface::XFBehavior * pBehavior) = 0;
62
66 virtual void unscheduleTimeout(int32_t timeoutId, interface::XFBehavior * pBehavior) = 0;
67
76 virtual void tick() = 0;
77
78 protected:
79 XFTimeoutManager() :
80 tickInterval_(0)
81 {}
82
83 virtual void addTimeout(XFTimeout * pNewTimeout) = 0;
84
85 protected:
86 int32_t tickInterval_;
87};
88
89} // namespace interface
90#endif // XF_INTERFACE_TIMEOUTMANAGER_H
XFBehavior
Base class for state machines, activities, process and data flows.
Definition: behavior.h:29
XFTimeout
Used by the TimeoutManager to create and handle a timeout.
Definition: timeout.h:28
interface::XFBehavior
Interface to receive and process events.
Definition: behavior.h:24
interface::XFTimeoutManager
Interface for TimerManager classes (and some few 'tick' stuff already provided).
Definition: timeoutmanager.h:26
interface::XFTimeoutManager::scheduleTimeout
virtual void scheduleTimeout(int32_t timeoutId, int32_t interval, interface::XFBehavior *pBehavior)=0
interface::XFTimeoutManager::tickInterval_
int32_t tickInterval_
Interval in milliseconds the TimeoutManager is decrementing the timeouts.
Definition: timeoutmanager.h:86
interface::XFTimeoutManager::addTimeout
virtual void addTimeout(XFTimeout *pNewTimeout)=0
Adds the timeout to the list of timeouts.
interface::XFTimeoutManager::getTickInterval
virtual int32_t getTickInterval() const
Returns tick interval in milliseconds.
Definition: timeoutmanager.h:44
interface::XFTimeoutManager::tick
virtual void tick()=0
Called periodically with a delay defined by TimeoutManager::_tickInterval.
interface::XFTimeoutManager::getInstance
static XFTimeoutManager * getInstance()
Returns a pointer to the single instance of TimeoutManager.
Definition: timeoutmanager.cpp:18
interface::XFTimeoutManager::initialize
virtual void initialize(int32_t tickInterval)
Definition: timeoutmanager.h:36
interface::XFTimeoutManager::start
virtual void start(std::function< void(uint32_t)> startTimeoutManagerTimer=nullptr)=0
interface::XFTimeoutManager::unscheduleTimeout
virtual void unscheduleTimeout(int32_t timeoutId, interface::XFBehavior *pBehavior)=0