Coin  4.0.3
Coin3D core library
Loading...
Searching...
No Matches
SoTimerQueueSensor Class Reference

The SoTimerQueueSensor class is the abstract base class for sensors triggering on certain timer events. More...

#include <Inventor/sensors/SoTimerQueueSensor.h>

Inheritance diagram for SoTimerQueueSensor:
SoSensor SoAlarmSensor SoTimerSensor

Public Member Functions

 SoTimerQueueSensor (SoSensorCB *func, void *data)
 
 SoTimerQueueSensor (void)
 
virtual ~SoTimerQueueSensor (void)
 
const SbTimegetTriggerTime (void) const
 
virtual SbBool isScheduled (void) const
 
virtual void schedule (void)
 
virtual void trigger (void)
 
virtual void unschedule (void)
 
- Public Member Functions inherited from SoSensor
 SoSensor (SoSensorCB *func, void *data)
 
 SoSensor (void)
 
virtual ~SoSensor (void)
 
voidgetData (void) const
 
SoSensorCBPtr getFunction (void) const
 
SoSensorgetNextInQueue (void) const
 
void setData (void *callbackdata)
 
void setFunction (SoSensorCB *callbackfunction)
 
void setNextInQueue (SoSensor *next)
 

Protected Member Functions

void setTriggerTime (const SbTime &time)
 

Protected Attributes

SbBool scheduled
 
- Protected Attributes inherited from SoSensor
SoSensorCB * func
 
voidfuncData
 

Additional Inherited Members

- Static Public Member Functions inherited from SoSensor
static void initClass (void)
 

Detailed Description

The SoTimerQueueSensor class is the abstract base class for sensors triggering on certain timer events.

Timer sensors triggers upon specific points in time.

This class is an abstract superclass which collects the common interface of the various non-abstract timer sensor classes. See the documentation of the subclasses for information on what ways there are to specify base times, intervals, alarm-style single triggering, repeated triggers, etc.

Note that Coin timer sensors should in no way be considered "hard real time". That is, you cannot expect a timer to always trigger at the exact moment it was set up for. Delays in triggering could be due to other activities in Coin, a task suspended, or heavy load from other applications on the system. These situations could all cause the processing of sensor queues (from SoQt / SoWin / SoXt / whatever) to be slightly delayed, thereby causing delays in timer sensor triggering.

On modern systems, a timer will usually trigger within a few milliseconds of its designated time, though.

If a timer sensor cannot trigger at the exact moment it has been scheduled, it will be triggered at the first opportunity after the scheduled time has passed.

Here's a simple usage example. It's a standalone example, which only demonstrates how to set up a repeating timer sensor with a callback:

#include <Inventor/Xt/SoXt.h>
#include <Inventor/sensors/SoTimerSensor.h>
#include <cstdio>
static void
timeSensorCallback(void * data, SoSensor * sensor)
{
SbString string = time.format("%S.%i");
(void)printf("%s\n", string.getString());
}
int
main(int argc, char ** argv)
{
SoXt::init("test");
timeSensor->setInterval(1.0f);
timeSensor->schedule();
return 0;
}
The SbList class is a template container class for lists.
Definition SbList.h:70
SbList(const int sizehint=DEFAULTSIZE)
Definition SbList.h:78
The SbString class is a string class with convenience functions for string operations.
Definition SbString.h:52
The SbTime class instances represents time values.
Definition SbTime.h:50
static SbTime getTimeOfDay(void)
Definition SbTime.cpp:148
SbString format(const char *const fmt="%S.%i") const
Definition SbTime.cpp:396
The SoSensor class is the abstract base class for all sensors.
Definition SoSensor.h:43
The SoTimerSensor class is a sensor which will trigger at given intervals.
Definition SoTimerSensor.h:38

Constructor & Destructor Documentation

◆ SoTimerQueueSensor() [1/2]

SoTimerQueueSensor::SoTimerQueueSensor ( void )

Default constructor.

◆ SoTimerQueueSensor() [2/2]

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

Constructor taking as arguments the sensor callback function and the userdata which will be passed the callback.

See also
setFunction(), setData()

◆ ~SoTimerQueueSensor()

SoTimerQueueSensor::~SoTimerQueueSensor ( void )
virtual

Destructor.

Member Function Documentation

◆ getTriggerTime()

const SbTime & SoTimerQueueSensor::getTriggerTime ( void ) const

Returns the time at which the sensor will trigger.

See also
setTriggerTime()

◆ isScheduled()

SbBool SoTimerQueueSensor::isScheduled ( void ) const
virtual

Check if this sensor is scheduled for triggering.

See also
schedule(), unschedule()

Implements SoSensor.

◆ schedule()

void SoTimerQueueSensor::schedule ( void )
virtual

Put the sensor in the global timer queue.

See also
unschedule(), isScheduled()

Implements SoSensor.

Reimplemented in SoAlarmSensor, and SoTimerSensor.

◆ setTriggerTime()

void SoTimerQueueSensor::setTriggerTime ( const SbTime & time)
protected

Set absolute time at which to trigger the sensor.

See also
getTriggerTime()

◆ trigger()

void SoTimerQueueSensor::trigger ( void )
virtual

Trigger the sensor's callback function.

Reimplemented from SoSensor.

◆ unschedule()

void SoTimerQueueSensor::unschedule ( void )
virtual

Remove sensor from the timer queue, without triggering it first.

See also
schedule(), isScheduled()

Implements SoSensor.

Reimplemented in SoTimerSensor.

Member Data Documentation

◆ scheduled

SbBool SoTimerQueueSensor::scheduled
protected

TRUE if the sensor is currently scheduled.


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