#include <CStopwatch.h>
Public Member Functions | |
CStopwatch (bool triggered=false) | |
~CStopwatch () | |
manipulators | |
double | reset () |
Reset the timer to zero. | |
void | stop () |
Stop the timer. | |
void | start () |
Start the timer. | |
void | setTrigger () |
Stop the timer and set the trigger. | |
double | getTime () |
Get elapsed time. | |
operator double () | |
Same as getTime(). | |
accessors | |
bool | isStopped () const |
Check if timer is stopped. | |
double | getTime () const |
Get elapsed time. | |
operator double () const | |
Same as getTime() const. |
This class measures time intervals. All time interval measurement should use this class.
Definition at line 25 of file CStopwatch.h.
CStopwatch::CStopwatch | ( | bool | triggered = false |
) |
The default constructor does an implicit reset() or setTrigger(). If triggered == false then the clock starts ticking.
Definition at line 22 of file CStopwatch.cpp.
double CStopwatch::getTime | ( | ) | const |
Get elapsed time.
Returns the time since the last reset(). This cannot trigger the stopwatch to start and will not clear the trigger.
Definition at line 113 of file CStopwatch.cpp.
double CStopwatch::getTime | ( | ) |
Get elapsed time.
Returns the time since the last reset() (or calls reset() and returns zero if the trigger is set).
Definition at line 86 of file CStopwatch.cpp.
References start().
Referenced by CEventQueue::getEvent(), CEventQueue::newOneShotTimer(), CEventQueue::newTimer(), operator double(), CCondVarBase::wait(), and CSimpleEventQueueBuffer::waitForEvent().
bool CStopwatch::isStopped | ( | ) | const |
Check if timer is stopped.
Returns true if the stopwatch is stopped.
Definition at line 107 of file CStopwatch.cpp.
double CStopwatch::reset | ( | ) |
Reset the timer to zero.
Set the start time to the current time, returning the time since the last reset. This does not remove the trigger if it's set nor does it start a stopped clock. If the clock is stopped then subsequent reset()'s will return 0.
Definition at line 38 of file CStopwatch.cpp.
void CStopwatch::setTrigger | ( | ) |
Stop the timer and set the trigger.
setTrigger() stops the clock like stop() except there's an implicit start() the next time (non-const) getTime() is called. This is useful when you want the clock to start the first time you check it.
Definition at line 79 of file CStopwatch.cpp.
References stop().
void CStopwatch::start | ( | ) |
Start the timer.
Start the stopwatch. start() removes the trigger, even if the stopwatch was already started.
Definition at line 66 of file CStopwatch.cpp.
Referenced by getTime().
void CStopwatch::stop | ( | ) |
Stop the timer.
Stop the stopwatch. The time interval while stopped is not counted by the stopwatch. stop() does not remove the trigger. Has no effect if already stopped.
Definition at line 54 of file CStopwatch.cpp.
Referenced by setTrigger().