![]() |
Scanframe Modular Application 0.1.0
|
Base class for template TSustain
which enables repetitive calls from the main thread with a set frequency.
More...
#include <Sustain.h>
Public Types | |
enum | ESustainPriority : int { spDefault = 100 , spTimer = std::numeric_limits<int>::max() } |
Do not use an iterator because the sustain function could affect the vector itself. More... | |
typedef TVector< SustainBase * > | PtrVector |
Public Member Functions | |
SustainBase (const SustainBase &)=delete | |
Prevent copying. | |
SustainBase & | operator= (const SustainBase &)=delete |
Prevent copying. | |
int | getPriority () const |
Gets the priority value of this instance;. | |
void | setInterval (const timespec &interval) |
Sets the interval at which the hooked function is called. This is only valid when the priority for this entry is spTimer. | |
const timespec & | getInterval () const |
Gets the interval at which the hooked function is called. | |
void | enable () |
Enables this entry. | |
void | disable () |
Disables this entry. | |
bool | isEnabled () const |
Returns if the entry is enabled or not. | |
virtual bool | call (const timespec &time) |
Must be overloaded to be able to call the sustain member function. | |
Static Public Member Functions | |
static void | flushVector (PtrVector *vector) |
Flushes the vector and clears all Vector member of all entries first. | |
static void | callSustain (PtrVector *vector=nullptr) |
Calls all sustain table entry functions in the vector passed. The default is the static default vector. | |
Protected Member Functions | |
SustainBase (PtrVector *vector, int priority) | |
Default Constructor adding itself to the passed vector. If the passed vector is NULL the default vector is selected. | |
~SustainBase () | |
oes not have to be virtual because this base class is not used must always be derived. | |
Protected Attributes | |
int | _priority |
Data member holing priority. | |
PtrVector * | _list |
Vector where this entry is part of. | |
IntervalTimer | _timer |
Timer for when priority spTimer has been set. | |
Static Protected Attributes | |
static PtrVector * | _defaultVector |
Pointer to the default vector which is automatically created when. | |
Base class for template TSustain
which enables repetitive calls from the main thread with a set frequency.
Purpose: Enables calling of sustain member functions of classes. The member functions must be of the type 'bool A_Name(int)'. This function is hooked into a table using class template 'TSustain'.
Usage: // In class declaration. TSustain< cls > Entry; // Function must return true if it wants to be called again. bool call(const timespec& t);
// Line in constructor Entry(this, &cls::MySustainFunction, priority, nullptr)
// To set the freq of the timer, use Entry.setInterval(const timespec& interval);
// To enable all this, do once, at program startup... // (this timer determines the maximum freq of sustained functions setSustainTimer(unsigned int ms);
typedef TVector<SustainBase*> sf::SustainBase::PtrVector |
enum sf::SustainBase::ESustainPriority : int |
|
delete |
Prevent copying.
|
protected |
Default Constructor adding itself to the passed vector. If the passed vector is NULL the default vector is selected.
vector | |
priority |
|
protected |
oes not have to be virtual because this base class is not used must always be derived.
|
inlinevirtual |
Must be overloaded to be able to call the sustain member function.
time |
|
static |
Calls all sustain table entry functions in the vector passed. The default is the static default vector.
vector |
|
inline |
Disables this entry.
|
inline |
Enables this entry.
|
static |
Flushes the vector and clears all Vector member of all entries first.
|
inline |
Gets the interval at which the hooked function is called.
|
inline |
Gets the priority value of this instance;.
|
inline |
Returns if the entry is enabled or not.
|
delete |
Prevent copying.
|
inline |
Sets the interval at which the hooked function is called. This is only valid when the priority for this entry is spTimer.
interval | In milliseconds. |
|
staticprotected |
Pointer to the default vector which is automatically created when.
|
protected |
Vector where this entry is part of.
|
protected |
Data member holing priority.
|
protected |
Timer for when priority spTimer has been set.