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

TimersetTimeout (Time delay, Callback< Timer & > callback)
 Schedule a one time callback. More...
 
TimersetTimeout (Time delay, Callback<> callback)
 Schedule a one time callback. More...
 
TimersetInterval (Time delay, Callback< Timer & > callback, int repeatCount=-1)
 Schedule a repeated callback. More...
 
TimersetInterval (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.

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.

Member Typedef Documentation

◆ Callback

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

Event listener.

Definition at line 45 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]

Timer & 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
Returns
A reference to the callback execution timer
Exceptions
InvalidArgumentExceptionif 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

Note
The returned reference will be invalidated when the timer stops, either explicitly or when it expires
Warning
The callback must not be a nullptr

◆ setInterval() [2/2]

Timer & 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
Returns
A reference to the callback execution timer
Exceptions
InvalidArgumentExceptionif 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

Note
The returned reference will be invalidated when the timer stops, either explicitly or when it expires

◆ setTimeout() [1/2]

Timer & 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
Returns
A reference to the callback execution timer
Exceptions
InvalidArgumentExceptionif 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...

Note
The returned reference will be invalidated when the timer stops, either explicitly or when it expires
Warning
The callback must not be a nullptr

◆ setTimeout() [2/2]

Timer & 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
Returns
A reference to the callback execution timer
Exceptions
InvalidArgumentExceptionif the specified callback argument is a nullptr
Note
The returned reference will be invalidated when the timer stops, either explicitly or when it expires
Warning
The callback must not be a nullptr

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