Simplified XF 1.1.0
timeout.h
1#ifndef XF_TIMEOUT_H
2#define XF_TIMEOUT_H
3
4#include "xf/event.h"
5
6namespace interface {
8}
9
27class XFTimeout : public XFEvent
28{
29 friend class interface::XFTimeoutManager;
30
31public:
38 XFTimeout(int id, int interval, interface::XFBehavior * pBehavior = nullptr);
39
44 bool operator ==(const XFTimeout & timeout) const;
45
46 bool deleteAfterConsume() const override;
47
48 inline int getInterval() const { return interval_; }
49 inline void setRelTicks(int relTicks) { relTicks_ = relTicks; }
50 inline int getRelTicks() const { return relTicks_; }
51 inline void substractFromRelTicks(int ticksToSubstract) { relTicks_ -= ticksToSubstract; }
52 inline void addToRelTicks(int ticksToAdd) { relTicks_ += ticksToAdd; }
53
54protected:
55 const int interval_;
57};
58 // end of xf_core group
60#endif // XF_TIMEOUT_H
Base class for all types of events and timeouts.
Definition: event.h:23
Used by the TimeoutManager to create and handle a timeout.
Definition: timeout.h:28
XFTimeout(int id, int interval, interface::XFBehavior *pBehavior=nullptr)
bool deleteAfterConsume() const override
Tells the dispatcher if the event must be deleted or not.
int getInterval() const
Returns the timeout interval in milliseconds.
Definition: timeout.h:48
int getRelTicks() const
Returns remaining ticks.
Definition: timeout.h:50
int relTicks_
Used by the TimeoutManager to calculate remaining time (in milliseconds). Can get negative!
Definition: timeout.h:56
bool operator==(const XFTimeout &timeout) const
void setRelTicks(int relTicks)
Sets remaining ticks.
Definition: timeout.h:49
void addToRelTicks(int ticksToAdd)
Adds ticksToAdd to remaining ticks.
Definition: timeout.h:52
const int interval_
Timeout interval in milliseconds.
Definition: timeout.h:55
void substractFromRelTicks(int ticksToSubstract)
Substracts ticksToSubstract from remaining ticks.
Definition: timeout.h:51
Default implementation of the XF TimeoutManager.
Definition: timeoutmanager.h:21
Interface to receive and process events.
Definition: behavior.h:24
Interface for TimerManager classes (and some few 'tick' stuff already provided).
Definition: timeoutmanager.h:26