VR-Forces 4.0.4 Class Documentation
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. More...

Inheritance diagram for DtTimer:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 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.
 DtTimer (const DtTimer &orig)
 copy constructor
DtTimeroperator= (const DtTimer &orig)
 assignment operator
virtual ~DtTimer ()
 destructor
virtual bool tick (const DtTime simTime)
 If time to fire, calls fire and returns true.
virtual void reset (const DtTime fireTime)
 Resets the time to fire.
virtual void cancel ()
 Sets cancelled state to true, fired state to false.
virtual void fire ()
 Sets off (fires) the timer.
virtual bool fired () const
 Returns whether or not timer has fired.
virtual DtTime fireTime () const
 Simulation time that timer is scheduled to fire.
virtual unsigned int timerType () const
 User-specified integer used to identify the purpose of the timer.
virtual void * usrData ()
 Pointer to user-specified data to be passed into callback when timer fires.
virtual bool cancelled () const
 Returns whether or not timer has been cancelled (if its cancel() member has been called).
virtual void setResortPending ()
 Resort pending state is used by a DtScheduler as it manages when it wants to resort the timers it is maintaining.
virtual void clearResortPending ()
virtual bool resortPending () const
virtual void setDeleteAfterFire ()
 Designates timer whether or not should be automatically deleted after it has fired.
virtual void clearDeleteAfterFire ()
virtual bool deleteAfterFire () const
 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).
virtual bool managed () const
 Indicates whether or not timer is being managed by a DtScheduler or not.
virtual void setScheduler (DtScheduler *scheduler)
 Sets the DtScheduler responsible for managing this timer.

Protected Attributes

DtSchedulermyScheduler
const DtTimerCallbackFcn myCallback
const unsigned int myType
void * myUsrData
 This pointer is the property of the DtTimer user and should not be modified in any way by DtTimer.
bool myFired
bool myDeleteAfterFire
bool myCancelled
DtTime myFireTime
bool myResortPending

Detailed Description

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.


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 DtPeriodicTimer, and DtRecurringTimer.

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.


Member Data Documentation

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]
DtTime DtTimer::myFireTime [protected]

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

Document ID: Generated on Fri Jun 29 16:33:32 EDT 2012 from SVN revision 116588
Copyright © 2005-2012 VT MÄK Inc. All Rights Reserved (www.mak.com)