Open Inventor Reference
SoSensor.h
Go to the documentation of this file.
1/*
2 *
3 * Copyright (C) 2000 Silicon Graphics, Inc. All Rights Reserved.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * Further, this software is distributed without any warranty that it is
16 * free of the rightful claim of any third person regarding infringement
17 * or the like. Any license provided herein, whether implied or
18 * otherwise, applies only to this software file. Patent licenses, if
19 * any, provided herein do not apply to combinations of this program with
20 * other software, or any other product whatsoever.
21 *
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with this library; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 *
26 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
27 * Mountain View, CA 94043, or:
28 *
29 * http://www.sgi.com
30 *
31 * For further information regarding this notice, see:
32 *
33 * http://oss.sgi.com/projects/GenInfo/NoticeExplan/
34 *
35 */
36
37
38/*
39 * Copyright (C) 1990,91,92 Silicon Graphics, Inc.
40 *
41 _______________________________________________________________________
42 ______________ S I L I C O N G R A P H I C S I N C . ____________
43 |
44 | $Revision: 1.1.1.1 $
45 |
46 | Description:
47 | Defines the SoSensor base class.
48 | The sensor hierarchy is:
49 |
50 | *SoSensor
51 | *SoDelayQueueSensor
52 | *SoDataSensor
53 | SoNodeSensor
54 | SoPathSensor
55 | SoFieldSensor
56 | SoIdleSensor
57 | SoOneShotSensor
58 | *SoTimerQueueSensor
59 | SoAlarmSensor
60 | SoTimerSensor
61 |
62 | * means the class is abstract.
63 |
64 | Sensors provide a callback mechanism based on some event: a
65 | particular time being reached, a change to a scene graph, or
66 | lack of other events to process.
67 |
68 | Author(s) : Nick Thompson, Paul Strauss, Gavin Bell
69 |
70 ______________ S I L I C O N G R A P H I C S I N C . ____________
71 _______________________________________________________________________
72 */
73
74#ifndef _SO_SENSOR_
75#define _SO_SENSOR_
76
77#include <Inventor/SbBasic.h>
78
79class SoField;
80class SoMField;
81class SoSensor;
82
88
89typedef void SoSensorCB(void *data, SoSensor *sensor);
90
93
107
109
110 public:
111
113 SoSensor() { func = NULL; funcData = NULL; }
114 SoSensor(SoSensorCB *f, void *d) { func = f; funcData = d; }
115
117 virtual ~SoSensor();
118
123 void setFunction(SoSensorCB *f) { func = f; }
125 void setData(void *d) { funcData = d; }
128 SoSensorCB * getFunction() const { return func; }
131 void * getData() const { return funcData; }
132
134 virtual void schedule() = 0;
135
137 virtual void unschedule() = 0;
138
140 virtual bool isScheduled() const = 0;
141
142 SoINTERNAL public:
144 static void initClass();
145
147 virtual void trigger();
148
151 virtual bool isBefore(const SoSensor *s) const = 0;
152
154 void setNextInQueue(SoSensor *next) { nextInQueue = next; }
155 SoSensor * getNextInQueue() const { return nextInQueue; }
156
157 protected:
159 void * funcData;
160
161 private:
162 SoSensor *nextInQueue;
163};
164
165#endif /* _SO_SENSOR_ */
#define SoINTERNAL
Definition SbBasic.h:155
#define INVENTOR_API
Disable some annoying warnings on MSVC 6.
Definition SbSystem.h:77
void SoSensorCB(void *data, SoSensor *sensor)
This typedef defines the calling sequence for all callbacks from sensors.
Definition SoSensor.h:89
Base class for all fields.
Definition SoField.h:185
Base class for all multiple-valued fields.
Definition SoField.h:628
Abstract base class for Inventor sensors.
Definition SoSensor.h:108
void setNextInQueue(SoSensor *next)
Sets/returns the next sensor in whichever queue the sensor is in.
Definition SoSensor.h:154
SoSensor(SoSensorCB *f, void *d)
Definition SoSensor.h:114
virtual void unschedule()=0
Unschedules sensor to keep it from being triggered.
virtual ~SoSensor()
Virtual destructor so that subclasses are deleted properly.
virtual void schedule()=0
Schedules the sensor for triggering at the appropriate time.
virtual bool isBefore(const SoSensor *s) const =0
This returns TRUE if this sensor should precede sensor s in whichever queue this sensor would be in.
void setFunction(SoSensorCB *f)
Sets the callback function that is called when the sensor is triggered.
Definition SoSensor.h:123
void * getData() const
Returns the user-supplied pointer that will be passed to the callback function.
Definition SoSensor.h:131
SoSensorCB * func
Callback function.
Definition SoSensor.h:158
static void initClass()
Initialize static members, etc.
SoSensorCB * getFunction() const
Returns the callback function that will be called when the sensor is triggered.
Definition SoSensor.h:128
SoSensor()
Constructors. The second form takes callback function and data.
Definition SoSensor.h:113
void setData(void *d)
Sets the callback data passed to the callback function.
Definition SoSensor.h:125
void * funcData
Data to pass to callback.
Definition SoSensor.h:159
virtual bool isScheduled() const =0
Returns whether the sensor is scheduled.
SoSensor * getNextInQueue() const
Definition SoSensor.h:155
virtual void trigger()
Triggers the sensor, calling its callback function.