Open Inventor Reference
SoTimerSensor Class Reference

Sensor that triggers callback repeatedly at regular intervals. More...

#include <Inventor/sensors/SoTimerSensor.h>

Inheritance diagram for SoTimerSensor:
SoTimerQueueSensor SoSensor

List of all members.

Public Member Functions

 SoTimerSensor ()
 Creation methods.
 SoTimerSensor (SoSensorCB *func, void *data)
 Creation methods.
virtual ~SoTimerSensor ()
 Destroys the sensor, freeing up any memory associated with it after unscheduling it.
void setBaseTime (const SbTime &base)
 Sets the base time.
void setInterval (const SbTime &intvl)
 Get the interval.
const SbTimegetBaseTime () const
 Get the base time.
const SbTimegetInterval () const
 Get the interval.
virtual void schedule ()
 Overrides the regular schedule() method because we have to set up the trigger time first.
virtual void unschedule ()
 Overrides the regular unschedule() because the timer could be in either the timer queue or the waiting-to-be-rescheduled queue, depending on the state of the 'triggering' flag.
void reschedule (const SbTime &)
 Reschedule this timer relative to the given time.

Detailed Description

Timer sensors trigger their callback function at regular intervals. For example, a timer might be setup to call its callback function every second on the second by setting the base time to SbTime(0.0) and the interval to SbTime(1.0). Timers are guaranteed to be triggered only once when the timer queue is processed, so if the application only processes the timer queue once every 5 seconds (because it is busy doing something else) the once-a-second sensor's callback will be called only once every 5 seconds.

Note also that SoTimers always schedule themselves to be triggered the next even multiple of the interval time after the base time; so, for example, if the once-a-second sensor is triggered at time 2.9 (because the application way busy doing something at time 2.0 and didn't get around to processing the sensor queue for a while) it will reschedule itself to go off at time 3.0, not at time 3.9. If the base time was never set, the sensor would be scheduled for time 3.9.

See Also
SoOneShotSensor, SoAlarmSensor, SoTimerQueueSensor, SbTime

Definition at line 100 of file SoTimerSensor.h.


Constructor & Destructor Documentation

SoTimerSensor::SoTimerSensor ( )

The second method takes the callback function and data to be called when the sensor is triggered.

SoTimerSensor::SoTimerSensor ( SoSensorCB func,
void *  data 
)

The second method takes the callback function and data to be called when the sensor is triggered.

virtual SoTimerSensor::~SoTimerSensor ( ) [virtual]

Member Function Documentation

const SbTime& SoTimerSensor::getBaseTime ( ) const [inline]

Definition at line 124 of file SoTimerSensor.h.

const SbTime& SoTimerSensor::getInterval ( ) const [inline]

Definition at line 126 of file SoTimerSensor.h.

void SoTimerSensor::reschedule ( const SbTime )
virtual void SoTimerSensor::schedule ( ) [virtual]

Reimplemented from SoTimerQueueSensor.

void SoTimerSensor::setBaseTime ( const SbTime base) [inline]

The default base time is the time when the sensor is scheduled or rescheduled.

Definition at line 117 of file SoTimerSensor.h.

References TRUE.

void SoTimerSensor::setInterval ( const SbTime intvl) [inline]

The default interval is 1/30th of a second.

Definition at line 121 of file SoTimerSensor.h.

virtual void SoTimerSensor::unschedule ( ) [virtual]

Reimplemented from SoTimerQueueSensor.


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