47 spTimer = std::numeric_limits<int>::max()
78 [[nodiscard]]
int getPriority()
const;
85 void setInterval(
const timespec& interval);
91 [[nodiscard]]
const timespec& getInterval()
const;
107 [[nodiscard]]
bool isEnabled()
const;
114 virtual inline bool call(
const timespec& time);
189 typedef bool (T::*
Pmf)(const timespec& t);
226 inline bool call(
const timespec& t)
override
228 return (_self->*_pmf)(t);
248 typedef bool (*Pf)(
const timespec&);
281 bool call(
const timespec& time)
override;
289inline bool StaticSustain::call(
const timespec& time)
Timer class that has fixed time intervals at which it becomes true.
Definition IntervalTimer.h:14
void enable()
Enables the timer with the current interval time.
Definition IntervalTimer.h:155
bool isEnabled() const
Gets timer enabled.
Definition IntervalTimer.h:165
const TimeSpec & getInterval() const
Gets the set interval time in TimeSpec format.
Definition IntervalTimer.h:170
void disable()
Disables the timer.
Definition IntervalTimer.h:160
void set(const timespec &t)
Sets the timers interval time.
Implements a class to hook a static function to the global main thread sustain call.
Definition Sustain.h:243
StaticSustain & operator=(const StaticSustain &)=delete
Prevent copying.
StaticSustain(const StaticSustain &)=delete
Prevent copying.
StaticSustain(Pf pf, int priority=spDefault, PtrVector *vector=_defaultVector)
One and only constructor.
Definition Sustain.h:257
Base class for template TSustain which enables repetitive calls from the main thread with a set frequ...
Definition Sustain.h:36
void disable()
Disables this entry.
Definition Sustain.h:162
static void flushVector(PtrVector *vector)
Flushes the vector and clears all Vector member of all entries first.
~SustainBase()
oes not have to be virtual because this base class is not used must always be derived.
const timespec & getInterval() const
Gets the interval at which the hooked function is called.
Definition Sustain.h:152
virtual bool call(const timespec &time)
Must be overloaded to be able to call the sustain member function.
Definition Sustain.h:172
int _priority
Data member holing priority.
Definition Sustain.h:136
bool isEnabled() const
Returns if the entry is enabled or not.
Definition Sustain.h:167
TVector< SustainBase * > PtrVector
Definition Sustain.h:38
IntervalTimer _timer
Timer for when priority spTimer has been set.
Definition Sustain.h:144
PtrVector * _list
Vector where this entry is part of.
Definition Sustain.h:140
static void callSustain(PtrVector *vector=nullptr)
Calls all sustain table entry functions in the vector passed. The default is the static default vecto...
SustainBase(PtrVector *vector, int priority)
Default Constructor adding itself to the passed vector. If the passed vector is NULL the default vect...
void setInterval(const timespec &interval)
Sets the interval at which the hooked function is called. This is only valid when the priority for th...
Definition Sustain.h:147
int getPriority() const
Gets the priority value of this instance;.
Definition Sustain.h:284
static PtrVector * _defaultVector
Pointer to the default vector which is automatically created when.
Definition Sustain.h:132
void enable()
Enables this entry.
Definition Sustain.h:157
ESustainPriority
Do not use an iterator because the sustain function could affect the vector itself.
Definition Sustain.h:43
@ spDefault
Definition Sustain.h:45
SustainBase & operator=(const SustainBase &)=delete
Prevent copying.
SustainBase(const SustainBase &)=delete
Prevent copying.
Template to make the sustain system call a class method regularly.
Definition Sustain.h:184
TSustain(const TSustain &)=delete
Prevent copying.
TSustain(T *self, Pmf pmf, int priority=spDefault, PtrVector *vector=nullptr)
One and only initializing constructor.
Definition Sustain.h:233
TSustain & operator=(const TSustain &)=delete
Prevent copying.
bool(T::* Pmf)(const timespec &t)
Required type.
Definition Sustain.h:189
Counted vector having additional methods and operators for ease of usage.
Definition TVector.h:25
#define _MISC_FUNC
Definition misc/global.h:39
#define _MISC_CLASS
Definition misc/global.h:40
Definition Application.h:10
_MISC_FUNC bool setSustainTimer(int msec)
This function will enable a timer that call all Sustain functions in the _defaultVector member of the...
_MISC_FUNC int getSustainTimer()
Gets the current sustain timer interval in milliseconds.