UnCoVer (Using Coverability for Verification)
|
Provides a timer, which can be started and used to measure elapsed time. More...
#include <Timer.h>
Public Member Functions | |
Timer (unsigned int timeout=0) | |
Generates a new Timer with the given timeout. More... | |
virtual | ~Timer () |
Destroys this instance of a Timer. | |
unsigned int | getTimeout () const |
Returns the timeout stored in this Timer. More... | |
void | setTimeout (unsigned int timeout) |
Sets the timeout for this Timer. More... | |
bool | isTimeoutSet () const |
Returns true iff the timeout has a positive value. More... | |
time_t | getStartTime () const |
Returns the time when this Timer was started. More... | |
double | getElapsedTime () const |
Returns the time elapsed since the Timer was started (in seconds). More... | |
void | start () |
Starts the timer. More... | |
bool | outOfTime () const |
Returns true, iff the elapsed time is larger than the set timeout. More... | |
bool | isRunning () const |
Returns true iff the Timers start-method was called. More... | |
Private Attributes | |
unsigned int | timeout |
Stores the timeout for "out of time"-checks. | |
time_t | startTime |
Stores the starting time of this Timer. | |
bool | running |
Stores whether this timer was started at least once. | |
Provides a timer, which can be started and used to measure elapsed time.
Additionally a timeout can be set and function is provided for checking if the timeout was reached.
Timer | ( | unsigned int | timeout = 0 | ) |
Generates a new Timer with the given timeout.
If no timeout is given, 0 is used (no timeout).
timeout | the timeout to be stored (a value of 0 deactivates timeout check) |
double getElapsedTime | ( | ) | const |
time_t getStartTime | ( | ) | const |
unsigned int getTimeout | ( | ) | const |
Returns the timeout stored in this Timer.
bool isRunning | ( | ) | const |
Returns true iff the Timers start-method was called.
bool isTimeoutSet | ( | ) | const |
Returns true iff the timeout has a positive value.
bool outOfTime | ( | ) | const |
Returns true, iff the elapsed time is larger than the set timeout.
TimerStateException | if the Timer was never started |
void setTimeout | ( | unsigned int | timeout | ) |
Sets the timeout for this Timer.
A given value of 0 deactivates the timeout check. This function does not affect the timers running state.
timeout | the new timeout |
void start | ( | ) |
Starts the timer.
This enables checking for elapsed time, etc. Calling this method multiple times will reset the Timers starting time.