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.
 
 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.
 
- Public Member Functions inherited from SoTimerQueueSensor
 SoTimerQueueSensor ()
 Constructors. The second form takes standard callback function and data.
 
 SoTimerQueueSensor (SoSensorCB *func, void *data)
 
virtual ~SoTimerQueueSensor ()
 Destructor.
 
const SbTimegetTriggerTime () const
 Returns the time at which this sensor is scheduled to be triggered.
 
virtual void schedule ()
 Adds this sensor to the timer queue.
 
virtual void unschedule ()
 If this sensor is scheduled, removes it from the timer queue so that it will not be triggered.
 
virtual bool isScheduled () const
 Returns TRUE if this sensor has been scheduled and is waiting in the timer queue to be triggered.
 
- Public Member Functions inherited from SoSensor
 SoSensor ()
 Constructors. The second form takes callback function and data.
 
 SoSensor (SoSensorCB *f, void *d)
 
virtual ~SoSensor ()
 Virtual destructor so that subclasses are deleted properly.
 
void setFunction (SoSensorCB *f)
 Sets the callback function that is called when the sensor is triggered.
 
void setData (void *d)
 Sets the callback data passed to the callback function.
 
SoSensorCBgetFunction () const
 Returns the callback function that will be called when the sensor is triggered.
 
void * getData () const
 Returns the user-supplied pointer that will be passed to the callback function.
 
virtual void schedule ()=0
 Schedules the sensor for triggering at the appropriate time.
 
virtual void unschedule ()=0
 Unschedules sensor to keep it from being triggered.
 
virtual bool isScheduled () const =0
 Returns whether the sensor is scheduled.
 
virtual void trigger ()
 Triggers the sensor, calling its callback function.
 
virtual bool isBefore (const SoSensor *s) const =0
 This returns TRUE if this sensor should precede sensor s in whichever queue this sensor would be in.
 
void setNextInQueue (SoSensor *next)
 Sets/returns the next sensor in whichever queue the sensor is in.
 
SoSensorgetNextInQueue () const
 

Additional Inherited Members

- Static Public Member Functions inherited from SoSensor
static void initClass ()
 Initialize static members, etc.
 
- 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.
 
virtual void trigger ()
 Triggers the sensor, calling its callback function.
 
- Protected Attributes inherited from SoTimerQueueSensor
bool scheduled
 Whether sensor is scheduled.
 
- Protected Attributes inherited from SoSensor
SoSensorCBfunc
 Callback function.
 
void * funcData
 Data to pass to callback.
 

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: