00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052 #ifndef _SO_DB_
00053 #define _SO_DB_
00054
00055 #include <Inventor/SoType.h>
00056 #include <Inventor/SbTime.h>
00057 #include <Inventor/threads/SbThread.h>
00058 #include <Inventor/threads/SbThreadLocalStorage.h>
00059
00060 #ifndef LIBRARYBUILD
00061
00062 #include <Inventor/sensors/SoSensorManager.h>
00063 #include <Inventor/SbPList.h>
00064 #include <Inventor/SoPreferences.h>
00065 #endif
00066
00067 class SbPList;
00068 class SoBase;
00069 class SoSFRealTime;
00070 class SoGroup;
00071 class SoSeparator;
00072 class SoInput;
00073 class SoPath;
00074 class SoNode;
00075 class SoField;
00076 class SoVRMLGroup;
00077 class SoVRMLPROTODef;
00078 class SbColor;
00079 class SoGlobalField;
00080 class SoSensorManager;
00081 class SoTimerSensor;
00082 class SoSensor;
00083 class SoSystemTimer;
00084
00085 #ifdef _WIN32
00086 #pragma warning( push )
00087 #pragma warning(disable:4251)
00088 #endif
00089
00090 #include <Inventor/SoModule.h>
00091 SO_MODULE_HEADER(SoInventor, __INVDLL)
00092
00093 #if defined(_WIN32)
00094
00095 #if ((_MANAGED == 1) || (_M_CEE == 1))
00096 #if defined(SO_MODULE_CHECK)
00097 static SoModuleCheck myModule((bool)_SECURE_SCL);
00098 #endif
00099 #elif !defined HIDDEN_FROM_DOC && !defined(LIBRARYBUILD)
00100 static SoModuleCheck myModule((bool)_SECURE_SCL);
00101 #endif
00102 #endif
00103
00104 #if defined SO_VERSION_DEPRECATED_ERROR && !defined(LIBRARYBUILD)
00105 static SoModuleCheck soVersionDeprecatedErrorCheck(SO_VERSION_DEPRECATED_ERROR);
00106 #endif
00107
00108 typedef void SoDBHeaderCB(void *userData, SoInput *in);
00109
00111
00112
00113
00114
00115
00116
00117
00118
00119
00121
00234 class SoDB {
00235
00236 public:
00237
00239 enum RenderCacheMode {
00243 COMPILE,
00247 COMPILE_AND_EXECUTE,
00251 AUTO_RENDER_CACHE
00252 };
00253
00259 static void init();
00260
00272 static void finish();
00273
00286
00287
00288
00289
00290
00291
00292
00293 static void threadInit();
00294
00308 static void setSystemTimer(SoSystemTimer* timer);
00309
00310 #if 1 SoDEPRECATED
00320 static const char *getVersion();
00321 #endif
00347 static SbBool read(SoInput *in, SoNode *&rootNode);
00348
00374 static SbBool read(SoInput *in, SoPath *&path);
00375
00399 static SoSeparator *readAll(SoInput *in);
00400
00401 #if 1 SoDEPRECATED
00411 static SoVRMLGroup *readAllVRML(SoInput *in);
00412 #endif
00420 SoNONUNICODE static SbBool readPROTOFromFile(SoInput *in, char *name,
00421 SoVRMLPROTODef *&protoDef);
00422
00423
00429 static SbBool readPROTOFromFile(SoInput *in, const SbString& name,
00430 SoVRMLPROTODef *&protoDef);
00431
00442 static void createRoute(SoNode *pFromNode, const char *fromEventOutName,
00443 SoNode *pInNode, const char *toEventInName);
00448 static void removeRoute(SoNode *pFromNode, const char *fromEventOutName,
00449 SoNode *pInNode, const char *toEventInName);
00450
00463 static SbBool registerHeader(const SbString &headerString,
00464 SbBool isBinary,
00465 float ivVersion,
00466 SoDBHeaderCB *preCB,
00467 SoDBHeaderCB *postCB,
00468 void *userData = NULL);
00480 static SbBool getHeaderData(const SbString &string,
00481 SbBool &isBinary,
00482 float &ivVersion,
00483 SoDBHeaderCB *&preCB,
00484 SoDBHeaderCB *&postCB,
00485 void *&userData,
00486 SbBool substringOK = FALSE);
00491 static int getNumHeaders();
00492
00497 static SbString getHeaderString(int i);
00498
00504 static SbBool isValidHeader(const char *testString);
00505
00533 static SoField *createGlobalField(const SbName &name, SoType type);
00534
00540 static SoField *getGlobalField(const SbName &name);
00541
00549 static void renameGlobalField(const SbName &oldName, const SbName &newName);
00550
00586 static void setRealTimeInterval(const SbTime &deltaT);
00587
00596 static const SbTime &getRealTimeInterval();
00597
00614 static void setDelaySensorTimeout(const SbTime &t);
00615
00620 static const SbTime &getDelaySensorTimeout();
00621
00626 static void processEvents();
00627
00638 static int doSelect(int nfds, fd_set *readfds, fd_set *writefds,
00639 fd_set *exceptfds, struct timeval *userTimeOut);
00640
00645 static SbBool isMultiThread();
00646
00662 static void writelock();
00663
00668 static void writeunlock();
00669
00680 static void readlock();
00681
00686 static void readunlock();
00687
00709 static void setNumRenderCaches( int num )
00710 { s_numRenderCaches = num; }
00711
00716 static int getNumRenderCaches()
00717 { return s_numRenderCaches; }
00718
00729 static void setRenderCacheMode( RenderCacheMode mode );
00730
00735 static RenderCacheMode getRenderCacheMode();
00736
00740 static SbTime getCurrentTime();
00741
00767 static bool addPlugin( const SbString& fileName );
00768
00773 static bool removePlugin( const SbString& fileName );
00774
00779 static const std::vector<SbString>& getLoadedPlugins();
00780
00785 static const std::vector<SbString>& getUnloadedPlugins();
00786
00791 static bool addPluginsDirectory( const SbString& dirName );
00792
00797 static bool removePluginsDirectory( const SbString& dirName );
00798
00803 static const std::vector<SbString>& getPluginsDirectories();
00804
00805 #if 1 SoDEPRECATED
00821 static void prioritizeChildrenCaching(SbBool onOff);
00822 SoDEPRECATED
00827 static SbBool isPrioritizedChildrenCaching();
00828 #endif
00830 SoEXTENDER_Documented public:
00831
00837 static void addConverter(SoType fromField, SoType toField,
00838 SoType converterEngine);
00839
00845 static SoType getConverter(SoType fromField, SoType toField);
00846
00851 static void removeConverter(SoType fromField, SoType toField);
00852
00853 #if 1 SoDEPRECATED
00862 static float getLicensingVersionNumber();
00863 SoDEPRECATED
00887 static int LicenseCheck( const char* productName, float version,
00888 const char* licenseString = NULL,
00889 SbBool printWarning = TRUE, char** errReport = NULL );
00890 #endif
00896 static void setIvTuneAllowed(SbBool ivTuneAllowed);
00897
00902 static SbBool getIvTuneAllowed();
00903
00904 private:
00905
00906 #if 1 SoDEPRECATED
00909 static inline int TGSLicenseCheck(const char *productName, float version,
00910 const char *licenseString = NULL,
00911 SbBool printWarning = TRUE)
00912 { return LicenseCheck(productName, version, licenseString, printWarning, NULL); }
00913
00914 #endif
00916 #ifdef _WIN32
00917
00925 static long openRegistryKey(const SbBool readOnlyFlag=FALSE);
00926
00932 static long getRegistryKeyValue(LPTSTR keyName,
00933 LPTSTR lpValueName,
00934 LPDWORD lpType,
00935 LPBYTE lpData,
00936 LPDWORD lpcbData,
00937 const SbBool readOnlyFlag=FALSE
00938 );
00939
00943 static long closeRegistryKey();
00944
00945 #if 1 SoDEPRECATED
00948 static long openTGSRegistryKey(SbBool flag=FALSE)
00949 { return SoDB::openRegistryKey(flag); }
00950 SoDEPRECATED
00952 static long getTGSKeyValue(LPTSTR keyName, LPTSTR lpValueName, LPDWORD lpType, LPBYTE lpData, LPDWORD lpcbData, SbBool flag=FALSE)
00953 { return SoDB::getRegistryKeyValue(keyName, lpValueName, lpType, lpData, lpcbData, flag); }
00954 SoDEPRECATED
00956 static long closeTGSRegistryKey()
00957 { return SoDB::closeRegistryKey(); }
00958
00959 #endif
00961 #endif //_WIN32
00962
00963 private:
00964
00968 static void threadFinish();
00969
00970
00971
00972
00973
00974
00975 static SbBool trywritelock();
00976
00977
00978 static SbBool tryreadlock();
00979
00980
00981 static SbBool shouldCreateMutex();
00982
00983
00984
00985 static SbThreadRWMutex *getGlobalMutex()
00986 { return SoInventorBase::getGlobalMutex(); }
00987
00988
00989 static SoSensorManager *getSensorManager();
00990
00991
00992 SoSensorManager *getUnlockSensorManager();
00993
00994
00995 static bool isInitialized();
00996
00997
00998 static SbBool getPickCullingEnabled()
00999 { return m_pickCullingEnabled; }
01000
01001 static const char* profileName;
01002
01003
01004
01005
01006
01007
01008
01009 static void startNotify();
01010 static SbBool isNotifying();
01011 static void endNotify();
01012
01013
01014 static void enableRealTimeSensor(SbBool enable);
01015
01016
01017
01018 static SbBool read(SoInput *in, SoBase *&base);
01019
01020
01021 static SoTimerSensor *getRealTimeSensor();
01022
01023
01024 static void restoreRealTimeSensorCB();
01025
01026 static SbBool m_readingAll;
01027
01028
01029
01030
01031 static SbString getDirNameFromFullFileName(SoInput *in);
01032
01033
01034 static SbBool useNameCompat;
01035
01036
01037
01038 static SbThreadId_t getMainThreadId();
01039
01041 static bool isInMainThread();
01042
01043
01044 static void resetMainThreadId();
01045
01046
01047 SB_THREAD_TLS_HEADER();
01048
01049 private:
01050 #ifdef _WIN32
01051
01052 static HKEY s_vsgRegistryKeys;
01053 #endif
01054
01055 SoDB();
01056 virtual ~SoDB();
01057
01058
01059 static SbThreadMutex *notifyMutex;
01060
01061
01062
01063 static SoGroup *internalReadAll(SoInput *, SoGroup *);
01064
01065
01066
01067 static SoSeparator *readAllFromInputReaders(SoInput *in);
01068
01069
01070 static SbBool useGlobalFieldTime;
01071
01072
01073 static const char *s_versionString;
01074
01075
01076 class SoGlobalDBInfos
01077 {
01078 public:
01079
01080 SoGlobalDBInfos();
01081
01082
01083 void init();
01084
01085 void cleanup();
01086
01087
01088 ~SoGlobalDBInfos();
01089
01090 SoSensorManager* m_sensorManager;
01091 SoGlobalField* m_globalField;
01092 SoTimerSensor* m_realTimeSensor;
01093 SoSFRealTime *m_realTime;
01094 bool m_isInit;
01095 };
01096
01097
01098 struct MTstruct
01099 {
01100 SoGlobalDBInfos* globalDBInfos;
01101 };
01102
01103
01104
01105
01106 static SoGlobalDBInfos* getGlobalDBInfos();
01107
01108
01109
01110 static SoGlobalDBInfos* s_globalInfos;
01111
01112
01113 static int notifyCount;
01114
01115 static void realTimeSensorCallback(void *data, SoSensor *sensor);
01116
01117
01118 static SbPList *headerList;
01119
01120
01121
01122
01123
01124 static SbDict *conversionDict;
01125
01126
01127 static uint32_t getConversionKey(SoType fromField, SoType toField);
01128
01129 static void iv2_1PreCallback(void *userData, SoInput *in);
01130 static void iv2_0PreCallback(void *userData, SoInput *in);
01131 static void iv1_0PreCallback(void *userData, SoInput *in);
01132 static void iv2_0PostCallback(void *userData, SoInput *in);
01133 static void iv1_0PostCallback(void *userData, SoInput *in);
01134
01135
01136
01137 static int s_numRenderCaches;
01138 static SbBool m_ivTuneAllowed;
01139
01140
01141
01142 static RenderCacheMode s_renderCacheMode;
01143
01144 static SbBool m_pickCullingEnabled;
01145
01146 static SbBool m_cacheChildrenFirst;
01147
01148 static int s_initRefCount;
01149
01150 static SbThreadId_t m_mainThreadId;
01151
01152 static bool internalInit();
01153
01154 friend class SoGlobalField;
01155 };
01156
01157 #if defined(_WIN32)
01158 #pragma warning( pop )
01159 #endif
01160
01161 #endif
01162
01163
01164