Open Inventor Reference
SoDB.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 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 SoDB class
48 |
49 | Author(s) : Paul S. Strauss, Nick Thompson, Gavin Bell
50 |
51 ______________ S I L I C O N G R A P H I C S I N C . ____________
52 _______________________________________________________________________
53 */
54
55#ifndef _SO_DB_
56#define _SO_DB_
57
60#include <Inventor/SoType.h>
61#include <Inventor/SbPList.h>
62
63class SoBase;
64class SoSFRealTime;
65class SoSeparator;
66class SoInput;
67class SoPath;
68class SoNode;
69class SoField;
70
71typedef void SoDBHeaderCB(void *userData, SoInput *in);
72
73
76
114
116
117 public:
118
122 static void init();
123
126 static const char *getVersion();
127
129 static bool read(SoInput *in, SoNode *&rootNode);
130
145 static bool read(SoInput *in, SoPath *&path);
146
155
171 static bool registerHeader(const SbString &headerString,
172 bool isBinary,
173 float ivVersion,
174 SoDBHeaderCB *preCB,
175 SoDBHeaderCB *postCB,
176 void *userData = NULL);
177
189 static bool getHeaderData(const SbString &string,
190 bool &isBinary,
191 float &ivVersion,
192 SoDBHeaderCB *&preCB,
193 SoDBHeaderCB *&postCB,
194 void *&userData,
195 bool substringOK = FALSE);
198 static int getNumHeaders();
201
206 static bool isValidHeader(const char *testString);
207
225 static SoField * createGlobalField(const SbName &name,
226 SoType type);
227
233 static SoField * getGlobalField(const SbName &name);
234
240 static void renameGlobalField(const SbName &oldName,
241 const SbName &newName);
242
265 static void setRealTimeInterval(const SbTime &deltaT);
268
276 static void setDelaySensorTimeout(const SbTime &t);
279
287 static int doSelect(int nfds, fd_set *readfds, fd_set *writefds,
288 fd_set *exceptfds,
289 struct timeval *userTimeOut);
290
291 SoEXTENDER public:
296 static void addConverter(SoType fromField, SoType toField,
297 SoType converterEngine);
298
302 static SoType getConverter(SoType fromField, SoType toField);
303
304 SoINTERNAL public:
307
309 static bool isInitialized() { return (globalDB != NULL); }
310
317 static void startNotify() { notifyCount++; }
318 static bool isNotifying() { return (notifyCount > 0); }
319 static void endNotify()
320 { if (--notifyCount == 0)
321 globalDB->sensorManager.processImmediateQueue(); }
322
324 static void enableRealTimeSensor(bool enable);
325
328 static bool read(SoInput *in, SoBase *&base);
329
330 private:
331 static const char *versionString;
332 static SoDB *globalDB;
333 SoSensorManager sensorManager;
334
335 static int notifyCount;
336
337 static SoTimerSensor *realTimeSensor;
338 static void realTimeSensorCallback();
339 static SoSFRealTime *realTime;
340
342 static SbPList *headerList;
343
348 static SbDict *conversionDict;
349
351 static uint32_t getConversionKey(SoType fromField, SoType toField)
352 { return (fromField.getKey() << 16) | toField.getKey(); }
353
354 static void iv2_1PreCallback(void *userData, SoInput *in);
355 static void iv2_0PreCallback(void *userData, SoInput *in);
356 static void iv1_0PreCallback(void *userData, SoInput *in);
357 static void iv2_0PostCallback(void *userData, SoInput *in);
358 static void iv1_0PostCallback(void *userData, SoInput *in);
359
360};
361
362#endif /* _SO_DB_ */
#define SoEXTENDER
Provide inline template functions for abs, swap, min, max, and clamp.
Definition SbBasic.h:154
#define FALSE
Definition SbBasic.h:79
#define SoINTERNAL
Definition SbBasic.h:155
#define INVENTOR_API
Disable some annoying warnings on MSVC 6.
Definition SbSystem.h:77
unsigned int uint32_t
Definition SbTypeDefs.h:44
void SoDBHeaderCB(void *userData, SoInput *in)
Definition SoDB.h:71
This is a dictionary mapping (size_t) integer keys to (void *) data pointers.
Definition SbDict.h:101
Character string stored in a hash table.
Definition SbString.h:264
List of generic (void *) pointers.
Definition SbPList.h:78
Class for smart character strings.
Definition SbString.h:85
Class for representation of a time.
Definition SbTime.h:89
Base class for all nodes, paths, and engines.
Definition SoBase.h:90
Scene graph database class.
Definition SoDB.h:115
static bool isValidHeader(const char *testString)
This returns TRUE if the given character string is one of the valid Inventor file headers,...
static void renameGlobalField(const SbName &oldName, const SbName &newName)
Renames the global field named oldName.
static SoField * createGlobalField(const SbName &name, SoType type)
The database maintains a namespace for global fields, making sure that there is at most one instance ...
static bool isNotifying()
Definition SoDB.h:318
static const char * getVersion()
Returns a character string identifying the version of the Inventor library in use.
static void endNotify()
Definition SoDB.h:319
static bool read(SoInput *in, SoNode *&rootNode)
static void setDelaySensorTimeout(const SbTime &t)
This sets the timeout value for sensors that are delay queue sensors (one-shot sensors,...
static int doSelect(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *userTimeOut)
In order to keep timer and idle sensors running as expected, it is necessary that an Inventor applica...
static SoType getConverter(SoType fromField, SoType toField)
Returns the field conversion engine registered for the two given field types.
static bool read(SoInput *in, SoPath *&path)
Reads a graph from the file specified by the given SoInput, returning a pointer to the resulting root...
static SoSensorManager * getSensorManager()
Accesses sensor manager.
static void setRealTimeInterval(const SbTime &deltaT)
The database automatically creates one global field when SoDB::init() is called.
static int getNumHeaders()
Returns the number of valid headers, including standard Inventor headers, and user-registered headers...
static void addConverter(SoType fromField, SoType toField, SoType converterEngine)
Registers a field conversion engine that can be used to convert from one type of field to another.
static bool read(SoInput *in, SoBase *&base)
Reads a base of any type, returning a pointer to it.
static void startNotify()
This is called when some instance begins or ends a notification process.
Definition SoDB.h:317
static bool registerHeader(const SbString &headerString, bool isBinary, float ivVersion, SoDBHeaderCB *preCB, SoDBHeaderCB *postCB, void *userData=NULL)
Registers the given string as a valid header for input files.
static SbString getHeaderString(int i)
Returns the i'th header.
static void enableRealTimeSensor(bool enable)
Enables/disables realTime sensor processing.
static bool isInitialized()
Returns TRUE if database is initialized (for error checking)
Definition SoDB.h:309
static bool getHeaderData(const SbString &string, bool &isBinary, float &ivVersion, SoDBHeaderCB *&preCB, SoDBHeaderCB *&postCB, void *&userData, bool substringOK=FALSE)
Passes back the data registered with the given header string, including the flag specifying whether t...
static const SbTime & getDelaySensorTimeout()
Returns the current delay queue timeout value.
static SoField * getGlobalField(const SbName &name)
Returns the global field with the given name, or NULL if there is none.
static SoSeparator * readAll(SoInput *in)
Reads all graphs and paths from the file specified by the given SoInput.
static const SbTime & getRealTimeInterval()
Returns how often the database is updating realTime .
static void init()
Initializes the database.
Base class for all fields.
Definition SoField.h:185
Used to read Inventor data files.
Definition SoInput.h:128
Abstract base class for all database nodes.
Definition SoNode.h:103
Path that points to a list of hierarchical nodes.
Definition SoPath.h:109
Group node that saves and restores traversal state.
Sensor that triggers callback repeatedly at regular intervals.
SoType has no virtual functions to keep it small...
Definition SoType.h:103
short getKey() const
Returns the type key as a short.
Definition SoType.h:180