OpenTTD Source 20241224-master-gee860a5c8e
BaseTimer< TTimerType > Class Template Referenceabstract

The base where every other type of timer is derived from. More...

#include <timer.h>

Inheritance diagram for BaseTimer< TTimerType >:
IntervalTimer< TimerWindow > IntervalTimer< TimerGameCalendar > IntervalTimer< TimerGameTick > TimeoutTimer< TimerWindow > IntervalTimer< TTimerType > TimeoutTimer< TTimerType >

Public Types

using TPeriod = typename TTimerType::TPeriod
 
using TElapsed = typename TTimerType::TElapsed
 
using TStorage = typename TTimerType::TStorage
 

Public Member Functions

 BaseTimer (const TPeriod period)
 Create a new timer.
 
virtual ~BaseTimer ()
 Delete the timer.
 

Data Fields

TPeriod period
 The period of the timer.
 
TStorage storage = {}
 The storage of the timer.
 

Protected Member Functions

virtual void Elapsed (TElapsed delta)=0
 Called by the timer manager to notify the timer that the given amount of time has elapsed.
 

Friends

class TimerManager< TTimerType >
 

Detailed Description

template<typename TTimerType>
class BaseTimer< TTimerType >

The base where every other type of timer is derived from.

Never use this class directly yourself.

Note
don't include this file; include "timer.h".

Definition at line 22 of file timer.h.

Member Typedef Documentation

◆ TElapsed

template<typename TTimerType >
using BaseTimer< TTimerType >::TElapsed = typename TTimerType::TElapsed

Definition at line 25 of file timer.h.

◆ TPeriod

template<typename TTimerType >
using BaseTimer< TTimerType >::TPeriod = typename TTimerType::TPeriod

Definition at line 24 of file timer.h.

◆ TStorage

template<typename TTimerType >
using BaseTimer< TTimerType >::TStorage = typename TTimerType::TStorage

Definition at line 26 of file timer.h.

Constructor & Destructor Documentation

◆ BaseTimer()

template<typename TTimerType >
BaseTimer< TTimerType >::BaseTimer ( const TPeriod  period)
inline

Create a new timer.

Parameters
periodThe period of the timer.

Definition at line 33 of file timer.h.

References TimerManager< TTimerType >::RegisterTimer().

◆ ~BaseTimer()

template<typename TTimerType >
virtual BaseTimer< TTimerType >::~BaseTimer ( )
inlinevirtual

Delete the timer.

Definition at line 42 of file timer.h.

References TimerManager< TTimerType >::UnregisterTimer().

Member Function Documentation

◆ Elapsed()

template<typename TTimerType >
virtual void BaseTimer< TTimerType >::Elapsed ( TElapsed  delta)
protectedpure virtual

Called by the timer manager to notify the timer that the given amount of time has elapsed.

Parameters
deltaDepending on the time type, this is either in milliseconds or in ticks.

Implemented in IntervalTimer< TTimerType >, IntervalTimer< TimerGameCalendar >, IntervalTimer< TimerGameTick >, IntervalTimer< TimerWindow >, TimeoutTimer< TTimerType >, and TimeoutTimer< TimerWindow >.

Friends And Related Symbol Documentation

◆ TimerManager< TTimerType >

template<typename TTimerType >
friend class TimerManager< TTimerType >
friend

Definition at line 58 of file timer.h.

Field Documentation

◆ period

template<typename TTimerType >
TPeriod BaseTimer< TTimerType >::period

The period of the timer.

Definition at line 49 of file timer.h.

Referenced by TimerManager< TTimerType >::ChangeRegisteredTimerPeriod(), and TimerManager< TTimerType >::RegisterTimer().

◆ storage

template<typename TTimerType >
TStorage BaseTimer< TTimerType >::storage = {}

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