Simplified XF 1.1.0

timeout.h
1#ifndef XF_TIMEOUT_H
2#define XF_TIMEOUT_H
3
4#include "xf/event.h"
5
6 namespace interface {
7 class XFTimeoutManager;
8}
9
27 class XFTimeout : public XFEvent
28{
29 friend class interface::XFTimeoutManager;
30
31 public:
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
54 protected:
55 const int interval_;
56 int relTicks_;
57};
58 // end of xf_core group
60#endif // XF_TIMEOUT_H
XFEvent
Base class for all types of events and timeouts.
Definition: event.h:23
XFTimeout
Used by the TimeoutManager to create and handle a timeout.
Definition: timeout.h:28
XFTimeout::XFTimeout
XFTimeout(int id, int interval, interface::XFBehavior *pBehavior=nullptr)
XFTimeout::deleteAfterConsume
bool deleteAfterConsume() const override
Tells the dispatcher if the event must be deleted or not.
XFTimeout::getInterval
int getInterval() const
Returns the timeout interval in milliseconds.
Definition: timeout.h:48
XFTimeout::getRelTicks
int getRelTicks() const
Returns remaining ticks.
Definition: timeout.h:50
XFTimeout::relTicks_
int relTicks_
Used by the TimeoutManager to calculate remaining time (in milliseconds). Can get negative!
Definition: timeout.h:56
XFTimeout::operator==
bool operator==(const XFTimeout &timeout) const
XFTimeout::setRelTicks
void setRelTicks(int relTicks)
Sets remaining ticks.
Definition: timeout.h:49
XFTimeout::addToRelTicks
void addToRelTicks(int ticksToAdd)
Adds ticksToAdd to remaining ticks.
Definition: timeout.h:52
XFTimeout::interval_
const int interval_
Timeout interval in milliseconds.
Definition: timeout.h:55
XFTimeout::substractFromRelTicks
void substractFromRelTicks(int ticksToSubstract)
Substracts ticksToSubstract from remaining ticks.
Definition: timeout.h:51
XFTimeoutManager
Default implementation of the XF TimeoutManager.
Definition: timeoutmanager.h:21
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