| 1 |
NAME SoDelayQueueSensor SoDelQSens "" { |
| 2 |
abstract base class for sensors not dependent on time |
| 3 |
} |
| 4 |
INCLUDE sensors/SoDelayQueueSensor.h |
| 5 |
DESC { |
| 6 |
Delay queue sensors are separate from timer queue sensors (see |
| 7 |
\cSoTimerQueueSensor\.) and provide methods for setting the relative |
| 8 |
priorities of the sensors in the delay queue (sensors with higher |
| 9 |
priorities will be triggered first). |
| 10 |
\p |
| 11 |
Sensors with non-zero priorities are added to the delay queue when |
| 12 |
scheduled, and are all processed once, in order, when the delay queue |
| 13 |
is processed, which normally happens as part of your program's main |
| 14 |
loop (see \m\+SoXt::mainLoop()\.\-SoXtMainLoop()\.\. or |
| 15 |
\m\+SoDB::doSelect()\.\-SoDBDoSelect()\.\.). Typically, the delay |
| 16 |
queue is processed whenever there are no events waiting to be |
| 17 |
distributed and there are no timer queue sensors waiting to be |
| 18 |
triggered. The delay queue also has a timeout to ensure that delay |
| 19 |
queue sensors are triggered even if there are always events or timer |
| 20 |
sensors waiting; see |
| 21 |
\m\+SoDB::setDelaySensorTimeout()\.\-SoDBSetDelaySensorTimeout()\.\.. |
| 22 |
\p |
| 23 |
Sensors with priority 0 are treated specially. Priority 0 sensors are |
| 24 |
triggered almost immediately after they are scheduled, before the |
| 25 |
program returns to the main loop. Priority 0 sensors are not |
| 26 |
necessarily triggered immediately when they are scheduled, however; if |
| 27 |
they are scheduled as part of the evaluation of a field connection |
| 28 |
network they may not be triggered until the evaluation of the network |
| 29 |
is complete. Also, if a priority 0 sensor is scheduled within the |
| 30 |
callback method of another priority 0 sensor, it will not be triggered |
| 31 |
until the callback method is complete (also note that if more than one |
| 32 |
priority 0 sensor is scheduled, the order in which they fire is |
| 33 |
undefined). |
| 34 |
} |
| 35 |
|
| 36 |
METHOD setPri void setPriority(uint32_t pri) {} |
| 37 |
METHOD getPri uint32_t getPriority() { |
| 38 |
Sets/gets the priority of the sensor. Priorities can be changed at |
| 39 |
any time; if the priority is changed to zero and it is already |
| 40 |
scheduled, the sensor is immediately triggered and removed from the |
| 41 |
queue. |
| 42 |
} |
| 43 |
|
| 44 |
METHOD "" static uint32_t getDefaultPriority() { |
| 45 |
Returns the default delay queue sensor priority, which is 100. |
| 46 |
} |
| 47 |
|
| 48 |
METHOD sched virtual void schedule() { |
| 49 |
If this sensor's priority is non-zero, adds this sensor to the list of |
| 50 |
delay queue sensors ready to be triggered. |
| 51 |
This is a way of making a sensor fire without changing the thing it is |
| 52 |
sensing. |
| 53 |
\p |
| 54 |
Calling \m\+schedule()\.\-sched()\.\. within the callback function |
| 55 |
causes the sensor to be called repeatedly. Because sensors are |
| 56 |
processed only once every time the delay queue is processed (even if |
| 57 |
they reschedule themselves), timers and events will still be |
| 58 |
processed. This should not be done with a priority zero sensor |
| 59 |
because an infinite loop will result. |
| 60 |
} |
| 61 |
METHOD unsched virtual void unschedule() { |
| 62 |
If this sensor is scheduled, removes it from the delay queue so that |
| 63 |
it will not be triggered. |
| 64 |
} |
| 65 |
METHOD isSched virtual SbBool isScheduled() { |
| 66 |
Returns TRUE if this sensor has been scheduled and is waiting in the |
| 67 |
delay queue to be triggered. Sensors are removed from the queue |
| 68 |
before their callback function is triggered. |
| 69 |
} |
| 70 |
|
| 71 |
ALSO { SoTimerQueueSensor, SoDataSensor, SoFieldSensor, SoIdleSensor, |
| 72 |
SoOneShotSensor, SoNodeSensor, SoPathSensor, SoSensorManager } |
| 73 |
|