| 1 |
NAME SoOneShotSensor SoOneShotSens "" { |
| 2 |
sensor for one-time only callbacks |
| 3 |
} |
| 4 |
|
| 5 |
INCLUDE sensors/SoOneShotSensor.h |
| 6 |
|
| 7 |
DESC { |
| 8 |
A one-shot sensor is triggered once after it is scheduled, when the |
| 9 |
delay queue is processed. Like all delay queue sensors, one-shot |
| 10 |
sensors with a non-zero priority are just added to the delay queue |
| 11 |
when scheduled; if they are scheduled again before the delay queue is |
| 12 |
processed nothing happens, and they are guaranteed to be called only |
| 13 |
once when the delay queue is processed. For example, a one-shot |
| 14 |
sensor whose callback function redraws the scene might be scheduled |
| 15 |
whenever the scene graph changes and whenever a window-system event |
| 16 |
reporting that the window changed size occurs. By using a one-shot, |
| 17 |
the scene will only be redrawn once even if a window-changed-size |
| 18 |
event occurs just after the scene graph is modified (or if several |
| 19 |
window-changed-size events occur in a row). |
| 20 |
\p |
| 21 |
Calling \mschedule()\. in the callback function is a useful way of |
| 22 |
getting something to happen repeatedly as often as possible, while |
| 23 |
still handling events and timeouts. |
| 24 |
\p |
| 25 |
A priority 0 one-shot sensor isn't very useful, since scheduling it is |
| 26 |
exactly the same as directly calling its callback function. |
| 27 |
} |
| 28 |
|
| 29 |
METHOD "" SoOneShotSensor() {} |
| 30 |
METHOD CreateCB SoOneShotSensor(SoSensorCB *func, void *data) { |
| 31 |
Creation methods. The second method takes the callback function and |
| 32 |
data to be called when the sensor is triggered. |
| 33 |
} |
| 34 |
METHOD "" ~SoOneShotSensor() { |
| 35 |
Destroys the sensor, freeing up any memory associated with it after |
| 36 |
unscheduling it. |
| 37 |
} |
| 38 |
|
| 39 |
ALSO { SoIdleSensor, SoDelayQueueSensor } |