#include <timer.h>
Inheritance diagram for ABA_TIMER:
Public Member Functions | |
ABA_TIMER (ABA_GLOBAL *glob) | |
The constructor for a timer with a pointer to the global object glob. | |
ABA_TIMER (ABA_GLOBAL *glob, long centiSeconds) | |
This constructor initializes the total time of the timer with centiSeconds and the pointer to the corresponding global object glob. The timer is not running, too. | |
virtual | ~ABA_TIMER () |
The destructor. | |
void | start (bool reset=false) |
The timer is started with the function start(). For safety starting a running timer is an error. | |
void | stop () |
Stops the timer and adds the difference between the current time and the starting time to the total time. | |
void | reset () |
bool | running () const |
long | centiSeconds () const |
long | seconds () const |
long | minutes () const |
long | hours () const |
bool | exceeds (const ABA_STRING &maxTime) const |
void | addCentiSeconds (long centiSeconds) |
Protected Member Functions | |
virtual long | theTime () const=0 |
Is required for measuring the time difference between the time of the call and some base point (e.g., the program start). | |
Protected Attributes | |
ABA_GLOBAL * | glob_ |
Private Attributes | |
long | startTime_ |
long | totalTime_ |
bool | running_ |
Friends | |
ostream & | operator<< (ostream &out, const ABA_TIMER &rhs) |
The output operator writes the time in the format { hours:minutes:seconds.seconds/100} on an output stream. |
Definition at line 47 of file timer.h.
ABA_TIMER::ABA_TIMER | ( | ABA_GLOBAL * | glob | ) |
The constructor for a timer with a pointer to the global object glob.
After the application of the constructor the timer is not running, i.e., to measure time it has to be started explicitly.
ABA_TIMER::ABA_TIMER | ( | ABA_GLOBAL * | glob, | |
long | centiSeconds | |||
) |
This constructor initializes the total time of the timer with centiSeconds and the pointer to the corresponding global object glob. The timer is not running, too.
virtual ABA_TIMER::~ABA_TIMER | ( | ) | [virtual] |
The destructor.
void ABA_TIMER::start | ( | bool | reset = false |
) |
The timer is started with the function start(). For safety starting a running timer is an error.
reset | If this flag is set to true, the timer is reset before it is started (default=false)} |
void ABA_TIMER::stop | ( | ) |
Stops the timer and adds the difference between the current time and the starting time to the total time.
Stopping a non-running timer is an error.
void ABA_TIMER::reset | ( | ) |
Stops the timer and sets the totalTime to 0.
bool ABA_TIMER::running | ( | ) | const |
false otherwise.
long ABA_TIMER::centiSeconds | ( | ) | const |
long ABA_TIMER::seconds | ( | ) | const |
long ABA_TIMER::minutes | ( | ) | const |
long ABA_TIMER::hours | ( | ) | const |
bool ABA_TIMER::exceeds | ( | const ABA_STRING & | maxTime | ) | const |
false otherwise.
maxTime | A string of the form [[h:]m:]s, where h are the hours, m the minutes, and s the seconds. Hours and minutes are optional. h can be an arbitrary nonnegative integer, s and m have to be integers in ![]() |
void ABA_TIMER::addCentiSeconds | ( | long | centiSeconds | ) |
centiSeconds | The number of centiseconds to be added. |
virtual long ABA_TIMER::theTime | ( | ) | const [protected, pure virtual] |
Is required for measuring the time difference between the time of the call and some base point (e.g., the program start).
We measure time according to the following principle.
The pure virtual function theTime() returns the CPU time since the start of the program for the class CPUABA_TIMER or the elapsed time since some point in the past for the class ABA_COWTIMER. When the timer is started startTime_ is initialized with the a value returned by theTime() and when it is stopped the difference between theTime() and startTime_ is added to the total time.
Implemented in ABA_COWTIMER, and ABA_CPUTIMER.
ostream& operator<< | ( | ostream & | out, | |
const ABA_TIMER & | rhs | |||
) | [friend] |
The output operator writes the time in the format { hours:minutes:seconds.seconds/100} on an output stream.
After the time has been divided in hours, minutes and seconds we have to take care that an additional leading zero is output if minutes or seconds have a value less than ten.
out | The output stream. | |
rhs | The timer being output. |
ABA_GLOBAL* ABA_TIMER::glob_ [protected] |
long ABA_TIMER::startTime_ [private] |
long ABA_TIMER::totalTime_ [private] |
bool ABA_TIMER::running_ [private] |