Public Types | Public Member Functions | List of all members
ime::TimerManager Class Reference

Manages multiple Timer instances. More...

#include <TimerManager.h>

Public Types

template<typename... Args>
using Callback = std::function< void(Args...)>
 Event listener. More...
 

Public Member Functions

void setTimeout (Time delay, Callback< Timer & > callback)
 Schedule a one time callback. More...
 
void setTimeout (Time delay, Callback<> callback)
 Schedule a one time callback. More...
 
void setInterval (Time delay, Callback< Timer & > callback, int repeatCount=-1)
 Schedule a repeated callback. More...
 
void setInterval (Time delay, Callback<> callback, int repeatCount=-1)
 Schedule a repeated callback. More...
 
std::size_t getTimerCount () const
 Get the total number of timers. More...
 
void clear ()
 Remove all timers. More...
 
void update (Time time)
 
void preUpdate ()
 

Detailed Description

Manages multiple Timer instances.

Definition at line 38 of file TimerManager.h.

Member Typedef Documentation

◆ Callback

template<typename... Args>
using ime::TimerManager::Callback = std::function<void(Args...)>

Event listener.

Definition at line 41 of file TimerManager.h.

Member Function Documentation

◆ clear()

void ime::TimerManager::clear ( )

Remove all timers.

◆ getTimerCount()

std::size_t ime::TimerManager::getTimerCount ( ) const

Get the total number of timers.

Returns
The total number of timers

◆ setInterval() [1/2]

void ime::TimerManager::setInterval ( Time  delay,
Callback< Timer & >  callback,
int  repeatCount = -1 
)

Schedule a repeated callback.

Parameters
delayThe time to wait before executing the callback
callbackThe callback to be executed
repeatCountThe number of times to repeat the callback

On invocation, the callback is passed the Timer that is responsible for the callback execution, the timer can be used to extend the duration, stop the schedule and so on... However note that the timer will be destroyed after the callback is invoked or if it is stopped before the callback is invoked.

By default, if repeatCounter is left unspecified then the callback will be executed forever every delay

Warning
Do not call the update(ime::Time) function of the given Timer as it is called internally by IME. The callback must not be a nullptr

◆ setInterval() [2/2]

void ime::TimerManager::setInterval ( Time  delay,
Callback<>  callback,
int  repeatCount = -1 
)

Schedule a repeated callback.

Parameters
delayThe time to wait before executing the callback
callbackThe callback to be executed
repeatCountThe number of times to repeat the callback

By default, if repeatCounter is left unspecified then the callback will be executed forever every delay. The callback must not be a nullptr

◆ setTimeout() [1/2]

void ime::TimerManager::setTimeout ( Time  delay,
Callback< Timer & >  callback 
)

Schedule a one time callback.

Parameters
delayThe time to wait before executing the callback
callbackThe function to be executed

On invocation, the callback is passed the Timer that is responsible for the callback execution, the timer can be used to extend the duration, stop the schedule and so on...

Warning
Do not call the update(ime::Time) function of the given Timer as it is called internally by IME. The callback must not be a nullptr

◆ setTimeout() [2/2]

void ime::TimerManager::setTimeout ( Time  delay,
Callback<>  callback 
)

Schedule a one time callback.

Parameters
delayThe time to wait before executing the callback
callbackThe function to be executed
Warning
The callback must not be a nullptr

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