VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Protected Attributes
DtTimer Class Reference

Instances of DtTimer are used to maintain the information needed to represent some kind of scheduled event. The key information it maintains is a callback function to be invoked when the timer fires. It is intended to be used in conjunction with the DtScheduler class, which is responsible for determining when to fire the timer.

Note: A timer can be created, ticked, reset, etc without use of the DtScheduler.

Note: If the DtTimer is used with a DtScheduler, it is the responsibility of the destroyer of a timer to remove it from the DtScheduler before deleting it.

Inheritance diagram for DtTimer:
Inheritance graph
[legend]

Public Member Functions

 DtTimer (const unsigned int type, const DtTime fireTime, const DtTimerCallbackFcn callback, void *usr)
 
 DtTimer (const DtTimer &orig)
 
DtTimeroperator= (const DtTimer &orig)
 
virtual ~DtTimer ()
 
virtual bool tick (const DtTime simTime)
 
virtual void reset (const DtTime fireTime)
 
virtual void cancel ()
 
virtual void fire ()
 
virtual bool fired () const
 
virtual DtTime fireTime () const
 
virtual unsigned int timerType () const
 
virtual void * usrData ()
 
virtual bool cancelled () const
 
virtual void setResortPending ()
 
virtual void clearResortPending ()
 
virtual bool resortPending () const
 
virtual void setDeleteAfterFire ()
 
virtual void clearDeleteAfterFire ()
 
virtual bool deleteAfterFire () const
 
virtual bool managed () const
 
virtual void setScheduler (DtScheduler *scheduler)
 
virtual bool periodIsRealTime () const
 

Protected Attributes

DtSchedulermyScheduler
 
const DtTimerCallbackFcn myCallback
 
const unsigned int myType
 
void * myUsrData
 
bool myFired
 
bool myDeleteAfterFire
 
bool myCancelled
 
DtTime myFireTime
 
bool myResortPending
 

Constructor & Destructor Documentation

DtTimer::DtTimer ( const unsigned int  type,
const DtTime  fireTime,
const DtTimerCallbackFcn  callback,
void *  usr 
)

constructor The type parameter is an integer assigned by the caller for debugging purposes. You can use this type when debugging to identify for what purpose the timer was intended. See timerTypes.h for a list of integers already in use by VR-Forces. fireTime is the simulation time the timer should be fired. The usr pointer points to some user-specified data that will be passed into the given callback when the timer fires. The usr pointer is owned by the caller (who is therefore responsible for destroying it) and it should not be modified by this class in any way.

DtTimer::DtTimer ( const DtTimer orig)

copy constructor

virtual DtTimer::~DtTimer ( )
virtual

destructor

Member Function Documentation

DtTimer& DtTimer::operator= ( const DtTimer orig)

assignment operator

virtual bool DtTimer::tick ( const DtTime  simTime)
virtual

If time to fire, calls fire and returns true.

virtual void DtTimer::reset ( const DtTime  fireTime)
virtual

Resets the time to fire. If myScheduler has been set, calls the scheduler's reSort() member passing in this object as the argument. Sets cancelled and fired state to false.

virtual void DtTimer::cancel ( )
virtual

Sets cancelled state to true, fired state to false. If myScheduler has been set, calls scheduler's reSort() member passing in this object as the argument.

virtual void DtTimer::fire ( )
virtual

Sets off (fires) the timer. Sets the fired state to true. If a callback exists, invokes the callback. If myScheduler has been set, calls scheduler's reSort() member passing in this object as the argument.

Reimplemented in DtRecurringTimer, and DtPeriodicTimer.

virtual bool DtTimer::fired ( ) const
virtual

Returns whether or not timer has fired.

virtual DtTime DtTimer::fireTime ( ) const
virtual

Simulation time that timer is scheduled to fire.

virtual unsigned int DtTimer::timerType ( ) const
virtual

User-specified integer used to identify the purpose of the timer. See timerTypes.h for the set of timerType integers aready in use within VR-Forces.

virtual void* DtTimer::usrData ( )
virtual

Pointer to user-specified data to be passed into callback when timer fires.

virtual bool DtTimer::cancelled ( ) const
virtual

Returns whether or not timer has been cancelled (if its cancel() member has been called).

virtual void DtTimer::setResortPending ( )
virtual

Resort pending state is used by a DtScheduler as it manages when it wants to resort the timers it is maintaining.

virtual void DtTimer::clearResortPending ( )
virtual
virtual bool DtTimer::resortPending ( ) const
virtual
virtual void DtTimer::setDeleteAfterFire ( )
virtual

Designates timer whether or not should be automatically deleted after it has fired. By default, it is up to the creator of the timer to delete the timer after it has fired. Note that if the creator of the timer assumes responsiblity for deleting timer, they cannot delete the timer in the callback (they must do it at some point after the callback has returned).

virtual void DtTimer::clearDeleteAfterFire ( )
virtual
virtual bool DtTimer::deleteAfterFire ( ) const
virtual

Indicates if timer has been configured to be automatically deleted upon firing or not (in which case creator of timer is responsible for deleting timer after it has fired). Note that if the creator of the timer assumes responsiblity for deleting timer, they cannot delete the timer in the callback (they must do it at some point after the callback has returned).

virtual bool DtTimer::managed ( ) const
virtual

Indicates whether or not timer is being managed by a DtScheduler or not. (i.e. was setScheduler ever called for this timer object)

virtual void DtTimer::setScheduler ( DtScheduler scheduler)
virtual

Sets the DtScheduler responsible for managing this timer.

virtual bool DtTimer::periodIsRealTime ( ) const
virtual

Whether or not to measure period in real time (vs. sim time). Default is false.

Reimplemented in DtPeriodicTimer.

Member Data Documentation

DtScheduler* DtTimer::myScheduler
protected
const DtTimerCallbackFcn DtTimer::myCallback
protected
const unsigned int DtTimer::myType
protected
void* DtTimer::myUsrData
protected

This pointer is the property of the DtTimer user and should not be modified in any way by DtTimer.

bool DtTimer::myFired
protected
bool DtTimer::myDeleteAfterFire
protected
bool DtTimer::myCancelled
protected
DtTime DtTimer::myFireTime
protected
bool DtTimer::myResortPending
protected

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

Document ID: Generated on Tue Sep 24 19:28:17 EDT 2024 from SVN revision 269799
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)