chai3d::cPrecisionClock Class Reference

This class implements a high precision clock. More...

#include <CPrecisionClock.h>

Public Member Functions

 cPrecisionClock ()
 Constructor of cPrecisionClock. More...
virtual ~cPrecisionClock ()
 Destructor of cPrecisionClock. More...
void reset (const double a_currentTime=0.0)
 This method resets the clock. More...
double start (bool a_resetClock=false)
 This method starts the clock with optional reset. More...
double stop ()
 This method stops the clock and return the elapsed time. More...
bool on () const
 This method returns true if the clock is running (ON), otherwise false if the clock is paused (OFF). More...
double getCurrentTimeSeconds () const
 This method returns the current clock time in seconds. More...
void setTimeoutPeriodSeconds (const double a_timeoutPeriod)
 This method sets the period in seconds before a timeout occurs (you need to poll for this). More...
double getTimeoutPeriodSeconds () const
 This method reads the programmed timeout period is seconds. More...
bool timeoutOccurred () const
 This method returns true if timeout has occurred, otherwise return false. More...
bool highResolution () const
 This method returns true if the high resolution CPU clock is available on this computer, false. otherwise. More...

Static Public Member Functions

static double getCPUTimeSeconds ()
 This method returns the raw CPU time in seconds. More...

Static Protected Member Functions

static void initialize ()
 This method initializes all static variables of cPrecisionClock. More...

Protected Attributes

double m_timeAccumulated
 Time accumulated between previous calls to start() and stop(). More...
double m_timeStart
 CPU time in seconds when clock was started. More...
double m_timeoutPeriod
 Timeout period in seconds. More...
double m_timeoutStart
 Clock time in seconds when timer was started. More...
bool m_on
 If true, then clock is currently ON. More...

Static Protected Attributes

static LARGE_INTEGER m_freq
 Stores information about CPU high precision clock. More...
static bool m_highres = false
 If true, then high precision CPU clock is available. More...
static bool m_initialized = false
 If true, then static members of cPrecisionClock have been initialized. More...

Detailed Description

cPrecisionClock implements a high-precision clock. All measurements are computed in seconds unless otherwise-specified.
cPrecisionClock behaves just like a real chronograph: It can be started, stopped and restarted at a later time. When a clock is running (ON), time is accumulated until the next stop event (OFF). The value of a clock can be read by calling method getCurrentTimeSeconds(). When a clock is disabled (OFF), time is no longer accumulated.

Constructor & Destructor Documentation

chai3d::cPrecisionClock::cPrecisionClock ( )

Constructor of cPrecisionClock. The clock is initialized to zero.

virtual chai3d::cPrecisionClock::~cPrecisionClock ( )

Member Function Documentation

void chai3d::cPrecisionClock::reset ( const double  a_currentTime = 0.0)

This method resets clock with an initial time value in seconds. (Default value is 0 seconds).

a_currentTimeTime in seconds to initialize clock.
double chai3d::cPrecisionClock::start ( bool  a_resetClock = false)

This method starts or restarts the clock. To read the clock time, call method getCurrentTimeSeconds().

a_resetClockIf true clock is initialized, otherwise resume counting.
Current clock time in seconds.
double chai3d::cPrecisionClock::stop ( )

This method stops the clock and returns elapsed time. To resume counting call method start().

Time in seconds.
bool chai3d::cPrecisionClock::on ( ) const
double chai3d::cPrecisionClock::getCurrentTimeSeconds ( ) const

This method returns the current time of clock in seconds.

Current time in seconds.
void chai3d::cPrecisionClock::setTimeoutPeriodSeconds ( const double  a_timeoutPeriod)

This method sets the period in seconds before timeout occurs. Do not forget to enable the timer ON by calling method start(). Monitoring for timeout is performed by calling timeoutOccurred().

a_timeoutPeriodTimeout period in seconds.
double chai3d::cPrecisionClock::getTimeoutPeriodSeconds ( ) const
bool chai3d::cPrecisionClock::timeoutOccurred ( ) const

This method check if the clock has expired its timeout period.

true if timeout occurred, otherwise false.
bool chai3d::cPrecisionClock::highResolution ( ) const
double chai3d::cPrecisionClock::getCPUTimeSeconds ( )

This method returns the raw CPU time in seconds.

Raw CPU clock time in seconds.
void chai3d::cPrecisionClock::initialize ( )

This method initializes all static variables of cPrecisionClock.

Member Data Documentation

LARGE_INTEGER chai3d::cPrecisionClock::m_freq
bool chai3d::cPrecisionClock::m_highres = false
bool chai3d::cPrecisionClock::m_initialized = false
double chai3d::cPrecisionClock::m_timeAccumulated
double chai3d::cPrecisionClock::m_timeStart
double chai3d::cPrecisionClock::m_timeoutPeriod
double chai3d::cPrecisionClock::m_timeoutStart
bool chai3d::cPrecisionClock::m_on

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