![]() |
VR-Forces 5.0.1 Developer's Guide
|
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.

Public Member Functions | |
| DtTimer (const unsigned int type, const DtTime fireTime, const DtTimerCallbackFcn callback, void *usr) | |
| DtTimer (const DtTimer &orig) | |
| DtTimer & | operator= (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 | |
| DtScheduler * | myScheduler |
| const DtTimerCallbackFcn | myCallback |
| const unsigned int | myType |
| void * | myUsrData |
| bool | myFired |
| bool | myDeleteAfterFire |
| bool | myCancelled |
| DtTime | myFireTime |
| bool | myResortPending |
| 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 |
destructor
If time to fire, calls fire and returns true.
|
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 |
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 |
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 |
Returns whether or not timer has fired.
|
virtual |
Simulation time that timer is scheduled to fire.
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 |
Pointer to user-specified data to be passed into callback when timer fires.
|
virtual |
Returns whether or not timer has been cancelled (if its cancel() member has been called).
|
virtual |
Resort pending state is used by a DtScheduler as it manages when it wants to resort the timers it is maintaining.
|
virtual |
|
virtual |
|
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 |
|
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 |
Indicates whether or not timer is being managed by a DtScheduler or not. (i.e. was setScheduler ever called for this timer object)
|
virtual |
Sets the DtScheduler responsible for managing this timer.
|
virtual |
Whether or not to measure period in real time (vs. sim time). Default is false.
Reimplemented in DtPeriodicTimer.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |