An instance of Clock that counts down a given amount of time
| 80 | |
| 81 | // An instance of Clock that counts down a given amount of time |
| 82 | class Timer : private Clock { |
| 83 | public: |
| 84 | static Timer withTime(double timeLeft, bool start = true); |
| 85 | static Timer withMilliseconds(int64_t millis, bool start = true); |
| 86 | |
| 87 | // Constructs a stopped timer whose time is up. |
| 88 | Timer(); |
| 89 | Timer(Timer const& timer); |
| 90 | Timer& operator=(Timer const& timer); |
| 91 | |
| 92 | // Start the timer with the given time left. |
| 93 | void restart(double timeLeft); |
| 94 | void restartWithMilliseconds(int64_t millisecondsLeft); |
| 95 | |
| 96 | // Time remaining on the timer. If negative is true, will return negative |
| 97 | // time values after the timer is up, if false it stops at zero. |
| 98 | double timeLeft(bool negative = false) const; |
| 99 | int64_t millisecondsLeft(bool negative = false) const; |
| 100 | |
| 101 | // Is the time remaining <= 0.0? |
| 102 | bool timeUp() const; |
| 103 | |
| 104 | using Clock::stop; |
| 105 | using Clock::start; |
| 106 | using Clock::running; |
| 107 | }; |
| 108 | |
| 109 | } |
no outgoing calls
no test coverage detected