Timer

Functions

CID

GetClassID

void *

As

const void *

As

class T_As

As

class T_As

As

Timer

~Timer

RED_RC

Start

float

MSElapsed

float

SecondsElapsed

bool

IsStarted

Detailed Description

class Timer : public RED::Object

Timer class.

@related Backbone

Use RED::Timer::Start to initialize a measure. Use RED::Timer::MSElapsed to get the elapsed time since the last call to Start in milliseconds (or RED::Timer::SecondsElapsed in seconds). Note that there’s no threading management in this class.

It’s possible that the timer fails to initialize on certain CPUs (on windows platforms: Those that do not support high resolution performance counters). If this case occurs, any call to RED::Timer::Start will return a RED_INIT_FAILED, and measurement methods are all to return negative invalid values.

Public Functions

virtual void *As(const RED::CID &iCID)

Converts the object to an instance of the given type.

Parameters

iCID – Requested class.

Returns

An object pointer of the given class on success, NULL otherwise.

virtual const void *As(const RED::CID &iCID) const

Converts the object to an instance of the given type.

Parameters

iCID – Requested class.

Returns

An object pointer of the given class on success, NULL otherwise.

template<class T_As>
inline T_As *As()
template<class T_As>
inline const T_As *As() const
Timer()

Timer construction method.

This constructor calibrates the timer.

virtual ~Timer()

Timer destruction method.

RED_RC Start()

Measures time starting now.

Sets the timer’s time reference to the moment of the call.

Returns

RED_INIT_FAILED if the timer failed to initialize,

RED_OK when the operation succeeded,

RED_FAIL in case of an unexpected failure.

float MSElapsed() const

Gives time elapsed since last RED::Timer::Start call, in milliseconds.

This method returns the time elapsed since last call to RED::Timer::Start, in milliseconds. If Start has not ever been called before, the method returns 0.0f.

Returns

The number of milliseconds elapsed.

float SecondsElapsed() const

Gives time elapsed since last RED::Timer::Start call, in seconds.

This method returns the time elapsed since last call to RED::Timer::Start, in seconds. If Start has not ever been called before, the method returns 0.0f.

Returns

The number of seconds elapsed.

inline bool IsStarted() const

Do we have started a time record?

Returns

true if we are between a RED::Timer::Start and an xxxElapsed call, false otherwise.

Public Static Functions

static inline RED::CID GetClassID()