Rehti MMORPG  1.0.0
Rehti MMORPG is a free and open source MMORPG game.
TimerCallbackSystem Class Reference

Class for handling smooth interpolation of events. A callback can be registered with a given id and time. The callback will be called with the given delta time until the time is depleted. More...

#include <TimerCallbackSystem.hpp>

Collaboration diagram for TimerCallbackSystem:
Collaboration graph

Public Member Functions

void elapseTime (float dt)
 Elapses time by the given delta time, meaning calling the callbacks with the given delta time. More...
 
void addTimerCallback (int id, float time, std::function< void(float dt)> callback, float factor=1.f)
 Adds a new timer callback for the given id. More...
 
bool forceQuitCallback (int id)
 Immediately forces the removal of the callback with the given id, without finishing the remaining time. More...
 
bool finishCallback (int id)
 Forces the callback to be completed with the time left in the timer and removes it from the system. More...
 

Private Attributes

std::mutex mutexM
 
std::map< int, CallBackTimertimersM
 

Detailed Description

Class for handling smooth interpolation of events. A callback can be registered with a given id and time. The callback will be called with the given delta time until the time is depleted.

Member Function Documentation

◆ addTimerCallback()

void TimerCallbackSystem::addTimerCallback ( int  id,
float  time,
std::function< void(float dt)>  callback,
float  factor = 1.f 
)

Adds a new timer callback for the given id.

Parameters
idis the identification for the given callback
timeis the time it takes to finish the action set to the callback in seconds
callbackis the function that can be called with given delta time
Here is the caller graph for this function:

◆ elapseTime()

void TimerCallbackSystem::elapseTime ( float  dt)

Elapses time by the given delta time, meaning calling the callbacks with the given delta time.

Parameters
dtis the delta time to elapse in seconds.
Here is the caller graph for this function:

◆ finishCallback()

bool TimerCallbackSystem::finishCallback ( int  id)

Forces the callback to be completed with the time left in the timer and removes it from the system.

Parameters
idof the object to be finished
Returns
true if the callback was found and finished, false if the callback was not found
Here is the caller graph for this function:

◆ forceQuitCallback()

bool TimerCallbackSystem::forceQuitCallback ( int  id)

Immediately forces the removal of the callback with the given id, without finishing the remaining time.

Parameters
idto remove the callback
Returns
true if the callback was removed, false, if the given id was not found
Here is the caller graph for this function:

Member Data Documentation

◆ mutexM

std::mutex TimerCallbackSystem::mutexM
private

◆ timersM

std::map<int, CallBackTimer> TimerCallbackSystem::timersM
private

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