Scanframe Modular Application 0.1.0
Loading...
Searching...
No Matches
sf::SustainBase Class Reference

Base class for template TSustain which enables repetitive calls from the main thread with a set frequency. More...

#include <Sustain.h>

Inheritance diagram for sf::SustainBase:
Collaboration diagram for sf::SustainBase:

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.
 
SustainBaseoperator= (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.
 

Detailed Description

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);

Member Typedef Documentation

◆ PtrVector

Member Enumeration Documentation

◆ ESustainPriority

Do not use an iterator because the sustain function could affect the vector itself.

Enumerator
spDefault 

Default priority

spTimer 

Maximum priority

Constructor & Destructor Documentation

◆ SustainBase() [1/2]

sf::SustainBase::SustainBase ( const SustainBase )
delete

Prevent copying.

◆ SustainBase() [2/2]

sf::SustainBase::SustainBase ( PtrVector vector,
int  priority 
)
protected

Default Constructor adding itself to the passed vector. If the passed vector is NULL the default vector is selected.

Parameters
vector
priority

◆ ~SustainBase()

sf::SustainBase::~SustainBase ( )
protected

oes not have to be virtual because this base class is not used must always be derived.

Member Function Documentation

◆ call()

bool sf::SustainBase::call ( const timespec &  time)
inlinevirtual

Must be overloaded to be able to call the sustain member function.

Parameters
time
Returns
When False is returned the sustain entry is disabled.

◆ callSustain()

static void sf::SustainBase::callSustain ( PtrVector vector = nullptr)
static

Calls all sustain table entry functions in the vector passed. The default is the static default vector.

Parameters
vector

◆ disable()

void sf::SustainBase::disable ( )
inline

Disables this entry.

◆ enable()

void sf::SustainBase::enable ( )
inline

Enables this entry.

◆ flushVector()

static void sf::SustainBase::flushVector ( PtrVector vector)
static

Flushes the vector and clears all Vector member of all entries first.

◆ getInterval()

const timespec & sf::SustainBase::getInterval ( ) const
inline

Gets the interval at which the hooked function is called.

Returns
Interval in milliseconds.

◆ getPriority()

int sf::SustainBase::getPriority ( ) const
inline

Gets the priority value of this instance;.

◆ isEnabled()

bool sf::SustainBase::isEnabled ( ) const
inline

Returns if the entry is enabled or not.

Returns
True when enabled.

◆ operator=()

SustainBase & sf::SustainBase::operator= ( const SustainBase )
delete

Prevent copying.

◆ setInterval()

void sf::SustainBase::setInterval ( const timespec &  interval)
inline

Sets the interval at which the hooked function is called. This is only valid when the priority for this entry is spTimer.

Parameters
intervalIn milliseconds.

Member Data Documentation

◆ _defaultVector

PtrVector* sf::SustainBase::_defaultVector
staticprotected

Pointer to the default vector which is automatically created when.

◆ _list

PtrVector* sf::SustainBase::_list
protected

Vector where this entry is part of.

◆ _priority

int sf::SustainBase::_priority
protected

Data member holing priority.

◆ _timer

IntervalTimer sf::SustainBase::_timer
protected

Timer for when priority spTimer has been set.


The documentation for this class was generated from the following file: