Open Inventor Reference
|
00001 /* 00002 * 00003 * Copyright (C) 2000 Silicon Graphics, Inc. All Rights Reserved. 00004 * 00005 * This library is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU Lesser General Public 00007 * License as published by the Free Software Foundation; either 00008 * version 2.1 of the License, or (at your option) any later version. 00009 * 00010 * This library is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 * Lesser General Public License for more details. 00014 * 00015 * Further, this software is distributed without any warranty that it is 00016 * free of the rightful claim of any third person regarding infringement 00017 * or the like. Any license provided herein, whether implied or 00018 * otherwise, applies only to this software file. Patent licenses, if 00019 * any, provided herein do not apply to combinations of this program with 00020 * other software, or any other product whatsoever. 00021 * 00022 * You should have received a copy of the GNU Lesser General Public 00023 * License along with this library; if not, write to the Free Software 00024 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00025 * 00026 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, 00027 * Mountain View, CA 94043, or: 00028 * 00029 * http://www.sgi.com 00030 * 00031 * For further information regarding this notice, see: 00032 * 00033 * http://oss.sgi.com/projects/GenInfo/NoticeExplan/ 00034 * 00035 */ 00036 00037 00038 /* 00039 * Copyright (C) 1990,91 Silicon Graphics, Inc. 00040 * 00041 _______________________________________________________________________ 00042 ______________ S I L I C O N G R A P H I C S I N C . ____________ 00043 | 00044 | $Revision: 1.1.1.1 $ 00045 | 00046 | Description: 00047 | Defines the SoDB class 00048 | 00049 | Author(s) : Paul S. Strauss, Nick Thompson, Gavin Bell 00050 | 00051 ______________ S I L I C O N G R A P H I C S I N C . ____________ 00052 _______________________________________________________________________ 00053 */ 00054 00055 #ifndef _SO_DB_ 00056 #define _SO_DB_ 00057 00058 #include <Inventor/system/SbSystem.h> 00059 #include <Inventor/sensors/SoSensorManager.h> 00060 #include <Inventor/SoType.h> 00061 #include <Inventor/SbPList.h> 00062 00063 class SoBase; 00064 class SoSFRealTime; 00065 class SoSeparator; 00066 class SoInput; 00067 class SoPath; 00068 class SoNode; 00069 class SoField; 00070 00071 typedef void SoDBHeaderCB(void *userData, SoInput *in); 00072 00073 00076 00113 00114 00115 class INVENTOR_API SoDB { 00116 00117 public: 00118 00122 static void init(); 00123 00126 static const char *getVersion(); 00127 00129 static SbBool read(SoInput *in, SoNode *&rootNode); 00130 00145 static SbBool read(SoInput *in, SoPath *&path); 00146 00154 static SoSeparator *readAll(SoInput *in); 00155 00171 static SbBool registerHeader(const SbString &headerString, 00172 SbBool isBinary, 00173 float ivVersion, 00174 SoDBHeaderCB *preCB, 00175 SoDBHeaderCB *postCB, 00176 void *userData = NULL); 00177 00189 static SbBool getHeaderData(const SbString &string, 00190 SbBool &isBinary, 00191 float &ivVersion, 00192 SoDBHeaderCB *&preCB, 00193 SoDBHeaderCB *&postCB, 00194 void *&userData, 00195 SbBool substringOK = FALSE); 00198 static int getNumHeaders(); 00200 static SbString getHeaderString(int i); 00201 00206 static SbBool isValidHeader(const char *testString); 00207 00225 static SoField * createGlobalField(const SbName &name, 00226 SoType type); 00227 00233 static SoField * getGlobalField(const SbName &name); 00234 00240 static void renameGlobalField(const SbName &oldName, 00241 const SbName &newName); 00242 00265 static void setRealTimeInterval(const SbTime &deltaT); 00267 static const SbTime &getRealTimeInterval(); 00268 00276 static void setDelaySensorTimeout(const SbTime &t); 00278 static const SbTime &getDelaySensorTimeout(); 00279 00287 static int doSelect(int nfds, fd_set *readfds, fd_set *writefds, 00288 fd_set *exceptfds, 00289 struct timeval *userTimeOut); 00290 00291 SoEXTENDER public: 00296 static void addConverter(SoType fromField, SoType toField, 00297 SoType converterEngine); 00298 00302 static SoType getConverter(SoType fromField, SoType toField); 00303 00304 SoINTERNAL public: 00306 static SoSensorManager * getSensorManager(); 00307 00309 static SbBool isInitialized() { return (globalDB != NULL); } 00310 00317 static void startNotify() { notifyCount++; } 00318 static SbBool isNotifying() { return (notifyCount > 0); } 00319 static void endNotify() 00320 { if (--notifyCount == 0) 00321 globalDB->sensorManager.processImmediateQueue(); } 00322 00324 static void enableRealTimeSensor(SbBool enable); 00325 00328 static SbBool read(SoInput *in, SoBase *&base); 00329 00330 private: 00331 static const char *versionString; 00332 static SoDB *globalDB; 00333 SoSensorManager sensorManager; 00334 00335 static int notifyCount; 00336 00337 static SoTimerSensor *realTimeSensor; 00338 static void realTimeSensorCallback(); 00339 static SoSFRealTime *realTime; 00340 00342 static SbPList *headerList; 00343 00348 static SbDict *conversionDict; 00349 00351 static uint32_t getConversionKey(SoType fromField, SoType toField) 00352 { return (fromField.getKey() << 16) | toField.getKey(); } 00353 00354 static void iv2_1PreCallback(void *userData, SoInput *in); 00355 static void iv2_0PreCallback(void *userData, SoInput *in); 00356 static void iv1_0PreCallback(void *userData, SoInput *in); 00357 static void iv2_0PostCallback(void *userData, SoInput *in); 00358 static void iv1_0PostCallback(void *userData, SoInput *in); 00359 00360 }; 00361 00362 #endif /* _SO_DB_ */