Open Inventor Release 2024.1.3
 
Loading...
Searching...
No Matches
SoOneShotSensor Class Reference

Sensor for one-time only callbacks. More...

#include <Inventor/sensors/SoOneShotSensor.h>

+ Inheritance diagram for SoOneShotSensor:

Public Member Functions

 SoOneShotSensor ()
 Default constructor.
 
 SoOneShotSensor (SoSensorCB *func, void *data)
 Constructor that takes the callback function and data to be called when the sensor is triggered.
 
virtual ~SoOneShotSensor ()
 Destroys the sensor, freeing up any memory associated with it after unscheduling it.
 
- Public Member Functions inherited from SoDelayQueueSensor
 SoDelayQueueSensor ()
 Constructor.
 
 SoDelayQueueSensor (SoSensorCB *func, void *data)
 Constructor that takes standard callback and data.
 
void setPriority (uint32_t pri)
 Sets the priority of the sensor.
 
uint32_t getPriority () const
 Gets the priority of the sensor.
 
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.
 
virtual void unschedule ()
 If this sensor is scheduled, removes it from the delay queue so that it will not be triggered.
 
virtual SbBool isIdleOnly () const
 
- Public Member Functions inherited from SoSensor
 SoSensor ()
 Constructor.
 
 SoSensor (SoSensorCB *f, void *d)
 Constructor that takes standard callback function and data.
 
void setFunction (SoSensorCB *f, void *userData)
 
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 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 SbBool isScheduled () const
 Returns TRUE if this sensor has been scheduled and is waiting in a sensor queue to be triggered.
 

Additional Inherited Members

- Public Types inherited from SoSensor
typedef void SoSensorCB(void *data, SoSensor *sensor)
 This typedef defines the calling sequence for all callbacks from sensors.
 
- Static Public Member Functions inherited from SoDelayQueueSensor
static uint32_t getDefaultPriority ()
 Returns the default delay queue sensor priority, which is 100.
 

Detailed Description

Sensor for one-time only callbacks.

A one-shot sensor is triggered once after it is scheduled, when the delay queue is processed. Like all delay queue sensors, one-shot sensors with a non-zero priority are just added to the delay queue when scheduled; if they are scheduled again before the delay queue is processed nothing happens, and they are guaranteed to be called only once when the delay queue is processed. For example, a one-shot sensor whose callback redraws the scene might be scheduled whenever the scene graph changes and whenever a window-system event reporting that the window changed size occurs. By using a one-shot, the scene will only be redrawn once even if a window-changed-size event occurs just after the scene graph is modified (or if several window-changed-size events occur in a row).

Calling schedule() in the callback is a useful way of getting something to happen repeatedly as often as possible, while still handling events and timeouts.

A priority 0 one-shot sensor isn't very useful, since scheduling it is exactly the same as directly calling its callback .

SEE ALSO

SoIdleSensor, SoDelayQueueSensor

Definition at line 87 of file SoOneShotSensor.h.

Constructor & Destructor Documentation

◆ SoOneShotSensor() [1/2]

SoOneShotSensor::SoOneShotSensor ( )

Default constructor.

◆ SoOneShotSensor() [2/2]

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

Constructor that takes the callback function and data to be called when the sensor is triggered.

◆ ~SoOneShotSensor()

virtual SoOneShotSensor::~SoOneShotSensor ( )
virtual

Destroys the sensor, freeing up any memory associated with it after unscheduling it.


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