Open Inventor Reference
SoDelayQueueSensor Class Reference

Abstract base class for sensors not dependent on time. More...

#include <Inventor/sensors/SoDelayQueueSensor.h>

Inheritance diagram for SoDelayQueueSensor:
SoSensor SoDataSensor SoIdleSensor SoOneShotSensor SoFieldSensor SoNodeSensor SoPathSensor SoFieldSensorCallback SoTypedFieldSensorCallback< Object, Method >

Public Member Functions

 SoDelayQueueSensor ()
 Constructors. The second form takes standard callback function and data. More...
 
 SoDelayQueueSensor (SoSensorCB *func, void *data)
 
virtual ~SoDelayQueueSensor ()
 Destructor. More...
 
void setPriority (uint32_t pri)
 Sets the priority of the sensor. More...
 
uint32_t getPriority () const
 Gets the priority of the sensor. More...
 
virtual void schedule ()
 If this sensor's priority is non-zero, adds this sensor to the list of delay queue sensors ready to be triggered. More...
 
virtual void unschedule ()
 If this sensor is scheduled, removes it from the delay queue so that it will not be triggered. More...
 
virtual bool isScheduled () const
 Returns TRUE if this sensor has been scheduled and is waiting in the delay queue to be triggered. More...
 
virtual bool isIdleOnly () const
 This method is overriden by IdleSensors to tell sensor manager that they should only be processed when there really is idle time (and not when the delay queue timeout expires). More...
 
void setCounter (uint32_t c)
 Set/inquire counter when sensor was last triggered. More...
 
uint32_t getCounter () const
 
- 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
 

Static Public Member Functions

static uint32_t getDefaultPriority ()
 Returns the default delay queue sensor priority, which is 100. More...
 
- Static Public Member Functions inherited from SoSensor
static void initClass ()
 Initialize static members, etc. More...
 

Protected Member Functions

virtual void trigger ()
 Triggers the sensor, calling its callback function. More...
 

Protected Attributes

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

Delay queue sensors are separate from timer queue sensors (see SoTimerQueueSensor) and provide methods for setting the relative priorities of the sensors in the delay queue (sensors with higher priorities will be triggered first).

Sensors with non-zero priorities are added to the delay queue when scheduled, and are all processed once, in order, when the delay queue is processed, which normally happens as part of your program's main loop. Typically, the delay queue is processed whenever there are no events waiting to be distributed and there are no timer queue sensors waiting to be triggered. The delay queue also has a timeout to ensure that delay queue sensors are triggered even if there are always events or timer sensors waiting; see SoDB::setDelaySensorTimeout().

Sensors with priority 0 are treated specially. Priority 0 sensors are triggered almost immediately after they are scheduled, before the program returns to the main loop. Priority 0 sensors are not necessarily triggered immediately when they are scheduled, however; if they are scheduled as part of the evaluation of a field connection network they may not be triggered until the evaluation of the network is complete. Also, if a priority 0 sensor is scheduled within the callback method of another priority 0 sensor, it will not be triggered until the callback method is complete (also note that if more than one priority 0 sensor is scheduled, the order in which they fire is undefined).

See Also
SoTimerQueueSensor, SoDataSensor, SoFieldSensor, SoIdleSensor, SoOneShotSensor, SoNodeSensor, SoPathSensor, SoSensorManager

Definition at line 110 of file SoDelayQueueSensor.h.

Constructor & Destructor Documentation

◆ SoDelayQueueSensor() [1/2]

SoDelayQueueSensor::SoDelayQueueSensor ( )

◆ SoDelayQueueSensor() [2/2]

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

◆ ~SoDelayQueueSensor()

virtual SoDelayQueueSensor::~SoDelayQueueSensor ( )
virtual

Member Function Documentation

◆ getCounter()

uint32_t SoDelayQueueSensor::getCounter ( ) const
inline

Definition at line 161 of file SoDelayQueueSensor.h.

◆ getDefaultPriority()

static uint32_t SoDelayQueueSensor::getDefaultPriority ( )
inlinestatic

Definition at line 129 of file SoDelayQueueSensor.h.

◆ getPriority()

uint32_t SoDelayQueueSensor::getPriority ( ) const
inline

Definition at line 126 of file SoDelayQueueSensor.h.

◆ isIdleOnly()

virtual bool SoDelayQueueSensor::isIdleOnly ( ) const
virtual

◆ isScheduled()

virtual bool SoDelayQueueSensor::isScheduled ( ) const
virtual

Sensors are removed from the queue before their callback function is triggered.

Implements SoSensor.

◆ schedule()

virtual void SoDelayQueueSensor::schedule ( )
virtual

This is a way of making a sensor fire without changing the thing it is sensing.

Calling schedule() within the callback function causes the sensor to be called repeatedly. Because sensors are processed only once every time the delay queue is processed (even if they reschedule themselves), timers and events will still be processed. This should not be done with a priority zero sensor because an infinite loop will result.

Implements SoSensor.

◆ setCounter()

void SoDelayQueueSensor::setCounter ( uint32_t  c)
inline

This allows the sensor manager to avoid triggering a sensor more than once during the same call to processDelayQueue().

Definition at line 160 of file SoDelayQueueSensor.h.

◆ setPriority()

void SoDelayQueueSensor::setPriority ( uint32_t  pri)

Priorities can be changed at any time; if the priority is changed to zero and it is already scheduled, the sensor is immediately triggered and removed from the queue.

◆ trigger()

virtual void SoDelayQueueSensor::trigger ( )
protectedvirtual

This overrides the method in SoSensor because it has to reset the schedule flag before triggering.

Reimplemented from SoSensor.

Reimplemented in SoFieldSensor, and SoDataSensor.

◆ unschedule()

virtual void SoDelayQueueSensor::unschedule ( )
virtual

Implements SoSensor.

Reimplemented in SoDataSensor.

Member Data Documentation

◆ scheduled

bool SoDelayQueueSensor::scheduled
protected

Definition at line 169 of file SoDelayQueueSensor.h.


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