Countdown helper tracking elapsed ratio and timeout state.
More...
#include <spk_timer.hpp>
|
| enum class | State { Idle
, Running
, Paused
, TimedOut
} |
| | Lifecycle state of the countdown.
|
|
| | Timer (const Duration &p_expectedDuration) |
| | Builds a timer with the expected duration preconfigured.
|
|
| Timer () |
| | Builds an idle timer with zero expected duration.
|
| State | state () const |
| | Reports the current timer state.
|
| Duration | elapsed () const |
| | Measures time accumulated since last start, excluding pauses.
|
| Duration | expectedDuration () const |
| | Returns the configured timeout duration.
|
| float | elapsedRatio () const |
| | Ratio of elapsed time over expected duration in [0,1] or above when overdue.
|
| bool | hasTimedOut () const |
| | Indicates whether the timer exceeded its expected duration.
|
|
void | start () |
| | Starts or restarts the timer from zero.
|
|
void | stop () |
| | Stops the timer and clears accumulated time.
|
|
void | pause () |
| | Suspends the timer without discarding elapsed time.
|
|
void | resume () |
| | Resumes counting after a pause.
|
Countdown helper tracking elapsed ratio and timeout state.
{
}
Countdown helper tracking elapsed ratio and timeout state.
Definition spk_timer.hpp:24
bool hasTimedOut() const
Indicates whether the timer exceeded its expected duration.
Definition spk_timer.cpp:48
void start()
Starts or restarts the timer from zero.
Definition spk_timer.cpp:54
◆ Timer()
| spk::Timer::Timer |
( |
const Duration & | p_expectedDuration | ) |
|
|
explicit |
Builds a timer with the expected duration preconfigured.
- Parameters
-
| p_expectedDuration | Duration required to reach timeout. |
◆ elapsed()
Measures time accumulated since last start, excluding pauses.
- Returns
- Elapsed duration.
◆ elapsedRatio()
| float spk::Timer::elapsedRatio |
( |
| ) |
const |
Ratio of elapsed time over expected duration in [0,1] or above when overdue.
- Returns
- Elapsed fraction as floating value.
◆ expectedDuration()
| Duration spk::Timer::expectedDuration |
( |
| ) |
const |
Returns the configured timeout duration.
- Returns
- Expected duration.
◆ hasTimedOut()
| bool spk::Timer::hasTimedOut |
( |
| ) |
const |
Indicates whether the timer exceeded its expected duration.
- Returns
- true when elapsed duration is greater or equal to expected duration.
◆ state()
Reports the current timer state.
- Returns
- Current countdown lifecycle state.
The documentation for this class was generated from the following files:
- includes/structure/system/time/spk_timer.hpp
- srcs/structure/system/time/spk_timer.cpp