timeoutmanager.h
#ifndef XF_INTERFACE_TIMEOUTMANAGER_H
#define XF_INTERFACE_TIMEOUTMANAGER_H
#include <cstdint>
#include <functional>
namespace interface {
class XFBehavior;
}
class XFTimeout;
namespace interface {
class XFTimeoutManager
{
public:
virtual ~XFTimeoutManager() = default;
static XFTimeoutManager * getInstance();
virtual void initialize(int32_t tickInterval)
{
tickInterval_ = tickInterval;
}
virtual int32_t getTickInterval() const
{
return tickInterval_;
}
virtual void start(std::function<void(uint32_t)> startTimeoutManagerTimer = nullptr) = 0;
virtual void scheduleTimeout(int32_t timeoutId, int32_t interval, interface::XFBehavior * pBehavior) = 0;
virtual void unscheduleTimeout(int32_t timeoutId, interface::XFBehavior * pBehavior) = 0;
virtual void tick() = 0;
protected:
XFTimeoutManager() :
tickInterval_(0)
{}
virtual void addTimeout(XFTimeout * pNewTimeout) = 0;
protected:
int32_t tickInterval_;
};
} // namespace interface
#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