![]() |
Tempo
Tempo is an app that allows users to create and manage timers, stopwatches, and alarms.
|
The Stopwatch class provides a simple timer with start, pause, resume, and reset functionalities. More...
#include <Stopwatch.hpp>

Public Member Functions | |
| Stopwatch () | |
| Default constructor initializes a Stopwatch with 0 milliseconds and not running. More... | |
| Stopwatch (int hours, int minutes, int seconds) | |
| Constructor initializes a Stopwatch with a specified time (in hours, minutes, and seconds). More... | |
| void | start () |
| Starts the stopwatch. More... | |
| void | addSplit () |
| Records and prints the current split time in milliseconds. More... | |
| void | clearSplits () |
| Clears the splits vector. More... | |
| vector< int > | getSplits () |
| Returns the splits vector. More... | |
| void | pause () |
| Pauses the stopwatch. More... | |
| void | resume () |
| Resumes the stopwatch from the last paused time. More... | |
| void | reset () |
| Resets the stopwatch to 0 milliseconds and stops it. More... | |
| bool | isRunning () |
| Checks if the stopwatch is currently running. More... | |
| int | currentMilliseconds () |
| Returns the current elapsed time in milliseconds. More... | |
Private Attributes | |
| int | _currMilliseconds |
| The current elapsed time in milliseconds. More... | |
| bool | _running |
| Indicates whether the stopwatch is currently running. More... | |
| vector< int > | _splits |
| Vector of all splits for the stopwatch. More... | |
| chrono::time_point< chrono::steady_clock > | _startTime |
| The time point when the stopwatch was started. More... | |
| chrono::time_point< chrono::steady_clock > | _pauseTime |
| The time point when the stopwatch was paused. More... | |
The Stopwatch class provides a simple timer with start, pause, resume, and reset functionalities.
Definition at line 13 of file Stopwatch.hpp.
| Stopwatch::Stopwatch | ( | ) |
Default constructor initializes a Stopwatch with 0 milliseconds and not running.
Definition at line 12 of file Stopwatch.cpp.
| Stopwatch::Stopwatch | ( | int | hours, |
| int | minutes, | ||
| int | seconds | ||
| ) |
Constructor initializes a Stopwatch with a specified time (in hours, minutes, and seconds).
| hours | The number of hours to set. |
| minutes | The number of minutes to set. |
| seconds | The number of seconds to set. |
Definition at line 25 of file Stopwatch.cpp.
| void Stopwatch::addSplit | ( | ) |
Records and prints the current split time in milliseconds.
A split time is a snapshot of the time elapsed, which can be useful for time intervals without stopping the stopwatch.
Definition at line 64 of file Stopwatch.cpp.
Referenced by Menu::checkStopwatchInput().

| void Stopwatch::clearSplits | ( | ) |
Clears the splits vector.
Definition at line 82 of file Stopwatch.cpp.
| int Stopwatch::currentMilliseconds | ( | ) |
Returns the current elapsed time in milliseconds.
If the stopwatch is running, this includes the time since it was started; otherwise, it returns the last recorded time.
Definition at line 44 of file Stopwatch.cpp.
Referenced by Menu::checkStopwatchInput(), and Display::tickStopwatch().

| vector< int > Stopwatch::getSplits | ( | ) |
Returns the splits vector.
Definition at line 90 of file Stopwatch.cpp.
Referenced by Display::tickStopwatch().

| bool Stopwatch::isRunning | ( | ) |
Checks if the stopwatch is currently running.
Definition at line 163 of file Stopwatch.cpp.
Referenced by Menu::checkStopwatchInput(), and Display::tickStopwatch().

| void Stopwatch::pause | ( | ) |
Pauses the stopwatch.
Stops the time count until resumed. The current time is recorded.
Definition at line 119 of file Stopwatch.cpp.
Referenced by Menu::checkStopwatchInput().

| void Stopwatch::reset | ( | ) |
Resets the stopwatch to 0 milliseconds and stops it.
Definition at line 148 of file Stopwatch.cpp.
Referenced by Menu::checkStopwatchInput().

| void Stopwatch::resume | ( | ) |
Resumes the stopwatch from the last paused time.
Definition at line 134 of file Stopwatch.cpp.
Referenced by Menu::checkStopwatchInput().

| void Stopwatch::start | ( | ) |
Starts the stopwatch.
If the stopwatch is already running, this function does nothing.
Definition at line 103 of file Stopwatch.cpp.
|
private |
The current elapsed time in milliseconds.
Definition at line 91 of file Stopwatch.hpp.
|
private |
The time point when the stopwatch was paused.
Definition at line 97 of file Stopwatch.hpp.
|
private |
Indicates whether the stopwatch is currently running.
Definition at line 92 of file Stopwatch.hpp.
|
private |
Vector of all splits for the stopwatch.
Definition at line 94 of file Stopwatch.hpp.
|
private |
The time point when the stopwatch was started.
Definition at line 96 of file Stopwatch.hpp.
1.8.13