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 | |
Timer & | setTimeout (Time delay, Callback< Timer & > callback) |
Schedule a one time callback. More... | |
Timer & | setTimeout (Time delay, Callback<> callback) |
Schedule a one time callback. More... | |
Timer & | setInterval (Time delay, Callback< Timer & > callback, int repeatCount=-1) |
Schedule a repeated callback. More... | |
Timer & | 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 () |
Manages multiple Timer instances.
This class is not meant to be instantiated directly, use ime::Scene::getTimer or ime::Engine::getTimer
Definition at line 42 of file TimerManager.h.
using ime::TimerManager::Callback = std::function<void(Args...)> |
Event listener.
Definition at line 45 of file TimerManager.h.
void ime::TimerManager::clear | ( | ) |
Remove all timers.
std::size_t ime::TimerManager::getTimerCount | ( | ) | const |
Get the total number of timers.
Timer & ime::TimerManager::setInterval | ( | Time | delay, |
Callback< Timer & > | callback, | ||
int | repeatCount = -1 |
||
) |
Schedule a repeated callback.
delay | The time to wait before executing the callback |
callback | The callback to be executed |
repeatCount | The number of times to repeat the callback |
InvalidArgumentException | if the specified callback argument is a nullptr |
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
Schedule a repeated callback.
delay | The time to wait before executing the callback |
callback | The callback to be executed |
repeatCount | The number of times to repeat the callback |
InvalidArgumentException | if the specified callback argument is a nullptr |
By default, if repeatCounter is left unspecified then the callback will be executed forever every delay. The callback must not be a nullptr
Schedule a one time callback.
delay | The time to wait before executing the callback |
callback | The function to be executed |
InvalidArgumentException | if the specified callback argument is a nullptr |
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...
Schedule a one time callback.
delay | The time to wait before executing the callback |
callback | The function to be executed |
InvalidArgumentException | if the specified callback argument is a nullptr |