RtTimer Class Reference

A class for periodic timer handling. More...

#include <RtTimer.h>

List of all members.

Public Types

typedef void(* RtTimerCallback )(double delta, double timeStamp, void *userData)
 User callback function type definition.

Public Member Functions

void setCallback (RtTimerCallback callback, void *userData=0)
 Sets a callback function to be invoked for timer events.
void cancelCallback ()
 Cancel use of the current callback function (if one exists).
void start (unsigned int period)
 Starts the periodic timer.
void stop (void)
 Stops the periodic timer.
double getTimestamp ()
 Returns the current timestamp.

Static Public Attributes

static const int MIN_PERIOD = 1
 Minimum supported period time in millisecods.
static const int MAX_PERIOD = 5000
 Maximum supported period time in millisecods.

Classes

struct  RtTimerData


Detailed Description

A class for periodic timer handling.

This class implements a periodic timer.

Copyright (c) 2008-2009 Pedro Lopez-Cabanillas <plcl@users.sf.net>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

Any person wishing to distribute modifications to the Software is requested to send the modifications to the original developer so that they can be incorporated into the canonical version.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


Member Typedef Documentation

typedef void(* RtTimer::RtTimerCallback)(double delta, double timeStamp, void *userData)

User callback function type definition.

This is the function prototype for the event callback that will be invoked periodically by the timer.

Parameters:
delta time in milliseconds since the last timer event
timeStamp time in millisecods since the timer was started
userData pointer provided in setCallback()


Member Function Documentation

void RtTimer::setCallback ( RtTimerCallback  callback,
void *  userData = 0 
)

Sets a callback function to be invoked for timer events.

The callback function will be called whenever the timer expires.

Parameters:
callback funcion to handle the timer events
userData pointer that will be passed to the callback

void RtTimer::cancelCallback (  ) 

Cancel use of the current callback function (if one exists).

Subsequent timer events will be lost.

void RtTimer::start ( unsigned int  period  ) 

Starts the periodic timer.

Parameters:
period time given in millisecods

void RtTimer::stop ( void   ) 

Stops the periodic timer.

It stops the timer if running. Does nothing otherwise.

double RtTimer::getTimestamp (  ) 

Returns the current timestamp.

This funcion returns the elapsed time in milliseconds since the first timer event after calling start().

Returns:
the elapsed time in milliseconds


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