timeout.h
#ifndef XF_TIMEOUT_H
#define XF_TIMEOUT_H
#include "xf/event.h"
namespace interface {
class XFTimeoutManager;
}
class XFTimeout : public XFEvent
{
friend class interface::XFTimeoutManager;
public:
XFTimeout(int id, int interval, interface::XFBehavior * pBehavior = nullptr);
bool operator ==(const XFTimeout & timeout) const;
bool deleteAfterConsume() const override;
inline int getInterval() const { return interval_; }
inline void setRelTicks(int relTicks) { relTicks_ = relTicks; }
inline int getRelTicks() const { return relTicks_; }
inline void substractFromRelTicks(int ticksToSubstract) { relTicks_ -= ticksToSubstract; }
inline void addToRelTicks(int ticksToAdd) { relTicks_ += ticksToAdd; }
protected:
const int interval_;
int relTicks_;
};
// end of xf_core group
#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