Tempo
Tempo is an app that allows users to create and manage timers, stopwatches, and alarms.
Stopwatch.hpp
Go to the documentation of this file.
1 #ifndef STOPWATCH_HPP
2 #define STOPWATCH_HPP
3 
4 #include <chrono>
5 #include <iostream>
6 #include <vector>
7 
8 using namespace std;
9 
13 class Stopwatch
14 {
15 public:
19  Stopwatch();
20 
28  Stopwatch(int hours, int minutes, int seconds);
29 
35  void start();
36 
43  void addSplit();
44 
48  void clearSplits();
49 
54  vector<int> getSplits();
55 
61  void pause();
62 
66  void resume();
67 
71  void reset();
72 
78  bool isRunning();
79 
88  int currentMilliseconds();
89 
90 private:
92  bool _running;
93 
94  vector<int> _splits;
95 
96  chrono::time_point<chrono::steady_clock> _startTime;
97  chrono::time_point<chrono::steady_clock> _pauseTime;
98 };
99 
100 #endif // STOPWATCH_HPP
The Stopwatch class provides a simple timer with start, pause, resume, and reset functionalities.
Definition: Stopwatch.hpp:13
STL namespace.
chrono::time_point< chrono::steady_clock > _pauseTime
The time point when the stopwatch was paused.
Definition: Stopwatch.hpp:97
int _currMilliseconds
The current elapsed time in milliseconds.
Definition: Stopwatch.hpp:91
chrono::time_point< chrono::steady_clock > _startTime
The time point when the stopwatch was started.
Definition: Stopwatch.hpp:96
vector< int > _splits
Vector of all splits for the stopwatch.
Definition: Stopwatch.hpp:94
bool _running
Indicates whether the stopwatch is currently running.
Definition: Stopwatch.hpp:92