A game timer identified by a TimerId. More...
Declaration
class helios::engine::runtime::timing::Timer { ... }
Public Constructors Index
| Timer (const helios::engine::runtime::timing::types::TimerId timerId) |
|
Constructs a Timer with the given identifier. More...
|
|
Public Member Functions Index
Private Member Attributes Index
Description
A game timer identified by a TimerId.
Tracks elapsed time while in the Running state. Each update increments a revision counter that observers can use to detect changes.
- See Also
TimerManager
- See Also
TimerBindingComponent
Definition at line 27 of file Timer.ixx.
Public Constructors
Timer()
Constructs a Timer with the given identifier.
- Parameters
-
| timerId | The unique identifier for this timer. |
Definition at line 61 of file Timer.ixx.
Public Member Functions
cancel()
| void helios::engine::runtime::timing::Timer::cancel () |
|
inline
noexcept
|
Cancels this timer by setting its state to TimerState::Cancelled.
- See Also
reset
Definition at line 98 of file Timer.ixx.
99 reset(TimerState::Cancelled);
100 }
Reference reset.
duration()
| float helios::engine::runtime::timing::Timer::duration () |
|
inline
noexcept
|
Returns the duration limit.
- Returns
The duration in seconds.
Definition at line 116 of file Timer.ixx.
117 return duration_;
118 }
Referenced by setDuration.
elapsed()
| float helios::engine::runtime::timing::Timer::elapsed () |
|
inline
noexcept
|
Returns the accumulated elapsed time.
- Returns
Elapsed time in seconds.
Definition at line 125 of file Timer.ixx.
126 return elapsed_;
127 }
isFinished()
| bool helios::engine::runtime::timing::Timer::isFinished () |
|
inline
noexcept
|
Returns whether this timer's internal state represents the Finished-state.
- Returns
True if the timer is finished.
Definition at line 162 of file Timer.ixx.
163 return (timerState_ == TimerState::Finished);
164 }
reset()
| void helios::engine::runtime::timing::Timer::reset (const TimerState state=TimerState::Undefined) |
|
inline
noexcept
|
Resets the elapsed time to zero and sets timer state to Undefined.
- Parameters
-
| state | The new TimerState the timer should be resetted to. |
Definition at line 78 of file Timer.ixx.
References setState and state.
Referenced by cancel and restart.
restart()
| void helios::engine::runtime::timing::Timer::restart () |
|
inline
noexcept
|
Resets timer by resetting its internal counter and setting its state to TimerState::Running.
- See Also
reset
Definition at line 89 of file Timer.ixx.
90 reset(TimerState::Running);
91 }
Reference reset.
setDuration()
| void helios::engine::runtime::timing::Timer::setDuration (float duration) |
|
inline
|
Sets the duration limit.
- Parameters
-
| duration | Duration in seconds. |
Definition at line 107 of file Timer.ixx.
Reference duration.
setState()
| void helios::engine::runtime::timing::Timer::setState (const TimerState state) |
|
inline
noexcept
|
Sets the timer state.
- Parameters
-
Definition at line 143 of file Timer.ixx.
145 timerRevision_++;
146 }
Reference state.
Referenced by reset.
shouldUpdate()
| bool helios::engine::runtime::timing::Timer::shouldUpdate () |
|
inline
noexcept
|
Returns whether this timer should accumulate time.
- Returns
True if the timer is in the Running state.
Definition at line 153 of file Timer.ixx.
154 return (timerState_ == TimerState::Running);
155 }
Referenced by update.
state()
| TimerState helios::engine::runtime::timing::Timer::state () |
|
inline
noexcept
|
Returns the current timer state.
- Returns
The current TimerState.
Definition at line 134 of file Timer.ixx.
135 return timerState_;
136 }
Referenced by reset and setState.
timerId()
| helios::engine::runtime::timing::types::TimerId helios::engine::runtime::timing::Timer::timerId () |
|
inline
noexcept
|
Returns the timer identifier.
- Returns
The TimerId assigned to this timer.
Definition at line 69 of file Timer.ixx.
timerRevision()
| TimerRevision helios::engine::runtime::timing::Timer::timerRevision () |
|
inline
noexcept
|
Returns the current revision counter.
- Returns
The TimerRevision value.
Definition at line 171 of file Timer.ixx.
172 return timerRevision_;
173 }
update()
| void helios::engine::runtime::timing::Timer::update (const float ft) |
|
inline
|
Advances the timer by the given frame time.
Only accumulates time when the timer is in the Running state. Increments the revision counter on each successful update.
- Parameters
-
Definition at line 183 of file Timer.ixx.
185 return;
186 }
187 timerRevision_++;
189 }
References helios::engine::runtime::registerComponents and shouldUpdate.
Private Member Attributes
duration_
| float helios::engine::runtime::timing::Timer::duration_ = 0.0f |
|
Optional duration limit in seconds.
Definition at line 52 of file Timer.ixx.
52 float duration_ = 0.0f;
elapsed_
| float helios::engine::runtime::timing::Timer::elapsed_ {} |
|
Accumulated elapsed time in seconds.
Definition at line 42 of file Timer.ixx.
timerId_
| TimerId helios::engine::runtime::timing::Timer::timerId_ |
|
Unique identifier for this timer.
Definition at line 37 of file Timer.ixx.
timerRevision_
| TimerRevision helios::engine::runtime::timing::Timer::timerRevision_ {} |
|
Monotonically increasing revision counter, incremented on each update.
Definition at line 32 of file Timer.ixx.
timerState_
| TimerState helios::engine::runtime::timing::Timer::timerState_ {} |
|
Current state of the timer.
Definition at line 47 of file Timer.ixx.
The documentation for this class was generated from the following file:
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.9.8.