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

Public Member Functions

 SoTimerSensor ()
 Creation methods. More...
 
 SoTimerSensor (SoSensorCB *func, void *data)
 Creation methods. More...
 
virtual ~SoTimerSensor ()
 Destroys the sensor, freeing up any memory associated with it after unscheduling it. More...
 
void setBaseTime (const SbTime &base)
 Sets the base time. More...
 
void setInterval (const SbTime &intvl)
 Get the interval. More...
 
const SbTimegetBaseTime () const
 Get the base time. More...
 
const SbTimegetInterval () const
 Get the interval. More...
 
virtual void schedule ()
 Overrides the regular schedule() method because we have to set up the trigger time first. More...
 
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. More...
 
void reschedule (const SbTime &)
 Reschedule this timer relative to the given time. More...
 
- Public Member Functions inherited from SoTimerQueueSensor
 SoTimerQueueSensor ()
 Constructors. The second form takes standard callback function and data. More...
 
 SoTimerQueueSensor (SoSensorCB *func, void *data)
 
virtual ~SoTimerQueueSensor ()
 Destructor. More...
 
const SbTimegetTriggerTime () const
 Returns the time at which this sensor is scheduled to be triggered. More...
 
virtual bool isScheduled () const
 Returns TRUE if this sensor has been scheduled and is waiting in the timer queue to be triggered. More...
 
- Public Member Functions inherited from SoSensor
 SoSensor ()
 Constructors. The second form takes callback function and data. More...
 
 SoSensor (SoSensorCB *f, void *d)
 
virtual ~SoSensor ()
 Virtual destructor so that subclasses are deleted properly. More...
 
void setFunction (SoSensorCB *f)
 Sets the callback function that is called when the sensor is triggered. More...
 
void setData (void *d)
 Sets the callback data passed to the callback function. More...
 
SoSensorCBgetFunction () const
 Returns the callback function that will be called when the sensor is triggered. More...
 
void * getData () const
 Returns the user-supplied pointer that will be passed to the callback function. More...
 
void setNextInQueue (SoSensor *next)
 Sets/returns the next sensor in whichever queue the sensor is in. More...
 
SoSensorgetNextInQueue () const
 

Additional Inherited Members

- Static Public Member Functions inherited from SoSensor
static void initClass ()
 Initialize static members, etc. More...
 
- Protected Member Functions inherited from SoTimerQueueSensor
void setTriggerTime (const SbTime &time)
 Used by subclasses to set the time at which the sensor is to be triggered. More...
 
- Protected Attributes inherited from SoTimerQueueSensor
bool scheduled
 Whether sensor is scheduled. More...
 
- Protected Attributes inherited from SoSensor
SoSensorCBfunc
 Callback function. More...
 
void * funcData
 Data to pass to callback. More...
 

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() [1/2]

SoTimerSensor::SoTimerSensor ( )

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

◆ SoTimerSensor() [2/2]

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

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

◆ ~SoTimerSensor()

virtual SoTimerSensor::~SoTimerSensor ( )
virtual

Member Function Documentation

◆ getBaseTime()

const SbTime& SoTimerSensor::getBaseTime ( ) const
inline

Definition at line 124 of file SoTimerSensor.h.

◆ getInterval()

const SbTime& SoTimerSensor::getInterval ( ) const
inline

Definition at line 126 of file SoTimerSensor.h.

◆ reschedule()

void SoTimerSensor::reschedule ( const SbTime )

◆ schedule()

virtual void SoTimerSensor::schedule ( )
virtual

Reimplemented from SoTimerQueueSensor.

◆ setBaseTime()

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.

◆ setInterval()

void SoTimerSensor::setInterval ( const SbTime intvl)
inline

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

Definition at line 121 of file SoTimerSensor.h.

◆ unschedule()

virtual void SoTimerSensor::unschedule ( )
virtual

Reimplemented from SoTimerQueueSensor.


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