UnCoVer (Using Coverability for Verification)
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
Public Member Functions | Private Attributes | List of all members
Timer Class Reference

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.
 

Detailed Description

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.

Author
Jan Stückrath

Constructor & Destructor Documentation

Timer ( unsigned int  timeout = 0)

Generates a new Timer with the given timeout.

If no timeout is given, 0 is used (no timeout).

Parameters
timeoutthe timeout to be stored (a value of 0 deactivates timeout check)

Member Function Documentation

double getElapsedTime ( ) const

Returns the time elapsed since the Timer was started (in seconds).

Returns
the time elapsed since the Timer was started (in seconds)
Exceptions
TimerStateExceptionif the Timer was never started
time_t getStartTime ( ) const

Returns the time when this Timer was started.

Returns
the time when this Timer was started
Exceptions
TimerStateExceptionif the Timer was never started
unsigned int getTimeout ( ) const

Returns the timeout stored in this Timer.

Returns
the stored timeout
bool isRunning ( ) const

Returns true iff the Timers start-method was called.

Returns
true iff the Timers start-method was called
bool isTimeoutSet ( ) const

Returns true iff the timeout has a positive value.

Returns
true iff the timeout is not 0
bool outOfTime ( ) const

Returns true, iff the elapsed time is larger than the set timeout.

Returns
true, iff the elapsed time is larger than the set timeout
Exceptions
TimerStateExceptionif 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.

Parameters
timeoutthe 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.


The documentation for this class was generated from the following files: