OpenTTD Source: TimerManager< TTimerType > Class Template Reference

OpenTTD Source 14.0-RC3

Data Structures | Public Types | Public Member Functions | Static Public Member Functions | Static Private Member Functions
TimerManager< TTimerType > Class Template Reference

The TimerManager manages a single Timer-type. More...

`#include <timer_manager.h>`

## Data Structures
struct | base_timer_sorter
| Sorter for timers. More...

## Public Types
using | TPeriod = typename TTimerType::TPeriod
using | TElapsed = typename TTimerType::TElapsed

## Public Member Functions
| TimerManager (TimerManager const &)=delete
TimerManager & | operator= (TimerManager const &)=delete
bool | Elapsed ([[maybe_unused]] TimerGameCalendar::TElapsed delta)
bool | Elapsed ([[maybe_unused]] TimerGameEconomy::TElapsed delta)
bool | Elapsed (TimerGameRealtime::TElapsed delta)
bool | Elapsed (TimerGameTick::TElapsed delta)
bool | Elapsed (TimerWindow::TElapsed delta)

## Static Public Member Functions
static void | RegisterTimer (BaseTimer< TTimerType > &timer)
| Register a timer. More...
static void | UnregisterTimer (BaseTimer< TTimerType > &timer)
| Unregister a timer. More...
static bool | Elapsed (TElapsed value)
| Called when time for this timer elapsed. More...

## Static Private Member Functions
static std::set< BaseTimer< TTimerType > *, base_timer_sorter > & | GetTimers ()
| Singleton list, to store all the active timers.

## Detailed Description

### template<typename TTimerType>
class TimerManager< TTimerType >

The TimerManager manages a single Timer-type.

It allows for automatic registration and unregistration of timers like Interval and OneShot.

Each Timer-type needs to implement the Elapsed() method, and distribute that to the timers if needed.

Definition at line 27 of file timer_manager.h.

## Member Function Documentation

## ◆ Elapsed()

template<typename TTimerType >

static bool TimerManager< TTimerType >::Elapsed | ( | TElapsed | value | ) |
| static

Called when time for this timer elapsed.

The implementation per type is different, but they all share a similar goal: Call the Elapsed() method of all active timers.

Parameters

  value | The amount of time that has elapsed.

Returns
  True iff time has progressed.

Referenced by UpdateWindows().

## ◆ RegisterTimer()

template<typename TTimerType >

static void TimerManager< TTimerType >::RegisterTimer | ( | BaseTimer< TTimerType > & | timer | ) |
| inlinestatic

Register a timer.

Parameters

  timer | The timer to register.

Definition at line 41 of file timer_manager.h.

References TimerManager< TTimerType >::GetTimers(), and BaseTimer< TTimerType >::period.

Referenced by BaseTimer< TimerGameCalendar >::BaseTimer().

## ◆ UnregisterTimer()

template<typename TTimerType >

static void TimerManager< TTimerType >::UnregisterTimer | ( | BaseTimer< TTimerType > & | timer | ) |
| inlinestatic

Unregister a timer.

Parameters

  timer | The timer to unregister.

Definition at line 54 of file timer_manager.h.

References TimerManager< TTimerType >::GetTimers().

Referenced by BaseTimer< TimerGameCalendar >::~BaseTimer().

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

- src/timer/timer_manager.h