PWToolBox::Timer Class Reference

A high resolution timer. More...

#include <Timer.h>

List of all members.

Public Types

typedef float TimeType
 This is the underlying type of the timer.

Public Member Functions

 Timer (bool const pause=false)
 Creates a new timer.
 ~Timer ()
void pause (bool const pause=true)
 Pauses and unpauses the timer.
void reset (bool const pause=false)
 Resets the timer to 0.
TimeType const getElapsedTime ()
bool const isPaused () const


Detailed Description

A high resolution timer.

The timer provides at least microsecond resolution. On Windows the QueryPerformanceCounter function is used. On Linux the gettimeofday function is used.


Member Typedef Documentation

typedef float PWToolBox::Timer::TimeType

This is the underlying type of the timer.


Constructor & Destructor Documentation

PWToolBox::Timer::Timer ( bool const  pause = false  ) 

Creates a new timer.

The timer is high-precision, with at least microsecond resolution.

Parameters:
pause If paused is true, the timer will not begin until pause(false) is called
Exceptions:
Throws IllegalOperationException if the timer cannot be initialized

PWToolBox::Timer::~Timer (  )  [inline]


Member Function Documentation

void PWToolBox::Timer::pause ( bool const  pause = true  ) 

Pauses and unpauses the timer.

There is no effect if the timer is already in the target state.

Parameters:
pause true will pause the timer, false will unpause it

void PWToolBox::Timer::reset ( bool const  pause = false  ) 

Resets the timer to 0.

Parameters:
pause If paused is true, the timer will not begin until pause(false) is called

TimeType const PWToolBox::Timer::getElapsedTime (  ) 

Remarks:
Floating point precision is usually enough for games. It wouldn't be hard to make this a template class (or function or specialization) to return a float or double, but then we'd have to worry about exposing multiple version to Python.
Returns:
The elapsed time, in seconds, as a float

bool const PWToolBox::Timer::isPaused (  )  const [inline]

Returns:
true if the timer is paused


The documentation for this class was generated from the following file:
Generated on Sun Jul 13 14:18:26 2008 for PWToolBox by  doxygen 1.5.1