- Main Page
- Classes
- Files
- Directories

- Class List
- Class Hierarchy
- Class Members

# cPrecisionTimer Class Reference

The cPrecisionTimer class manages high-rate callbacks using win32 multimedia timers. Rates up to 1kHz should be supported. More...

`#include <CPrecisionTimer.h>`

List of all members.

## Public Member Functions
| cPrecisionTimer ()
| Constructor of cPrecisionTimer.
| ~cPrecisionTimer ()
| Destructor of cPrecisionTimer. Stops the timer implicitly.
int | set (int a_interval, PRECISION_TIMER_CALLBACK *a_fpCallback, void *a_pUserData=0)
| Request that a callback function be queued for repeated callbacks.
bool | stop ()
| Stop current timer.
## Public Attributes
double | m_averageExecutionTime
| This is the average time (in seconds) that your callback function has required for execution.
## Private Member Functions
void | defaults ()
## Private Attributes
string | m_lastErrorMessage
| Last error message.
long | m_interval
| Our current timing interval in milliseconds.

## Detailed Description

The cPrecisionTimer class manages high-rate callbacks using win32 multimedia timers. Rates up to 1kHz should be supported.

This class also maintains statistics about how long your callbacks are taking to execute, how much time has elapsed since the previous callback, etc.

## Constructor & Destructor Documentation

cPrecisionTimer::cPrecisionTimer | ( |  | ) |

Constructor of cPrecisionTimer.

Constructor of cPrecisionTimer.

cPrecisionTimer::~cPrecisionTimer | ( |  | ) |

Destructor of cPrecisionTimer. Stops the timer implicitly.

Destructor of cPrecisionTimer.

## Member Function Documentation

int cPrecisionTimer::set | ( | int | a_interval,
|  | PRECISION_TIMER_CALLBACK * | a_fpCallback,
|  | void * | a_pUserData = `0` |
| ) |  |  |

Request that a callback function be queued for repeated callbacks.

Request that a callback function be queued for repeated callbacks. Calling this function replaces any timer previously associated with this object (i.e., you need two cPrecisionTimers if you want two separate callbacks).

Parameters:

  | a_interval | The interval (in milliseconds) between successive callbacks.

If iInterval is zero, the callback occurs at the fastest rate supported by the system.

Parameters:

  | a_fpCallback | Pointer to a callback function. The callback should be a function of type PRECISION_TIMER_CALLBACK, which is defined above. Your function should look like :

void callback(void* user_data);

When your function gets called, you'll get back whatever value you supplied as the user_data value in the set(...) function.

Parameters:

  | a_pUserData | This value is handed back to your callback function every time it gets called.

One useful thing to supply here might be the timer itself, so you can easily access timing statistics during your callback.

Returns:
  Returns 0 if all goes well. If the specified interval is not supported by the system, the return value is the minimum interval (in milliseconds) supported by the system. Any other error results in a return value of -1.

bool cPrecisionTimer::stop | ( |  | ) |

Stop current timer.

Stop an active timer.

void cPrecisionTimer::defaults | ( |  | ) | `[private]`

Assign default values to variables; used for internal initialization only.

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

- chai3d/src/timers/CPrecisionTimer.h
- chai3d/src/timers/CPrecisionTimer.cpp