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 SbColor;
00077 class SoGlobalField;
00078 class SoSensorManager;
00079 class SoTimerSensor;
00080 class SoSensor;
00081 class SoSystemTimer;
00082
00083 #ifdef _WIN32
00084 #pragma warning( push )
00085 #pragma warning(disable:4251)
00086 #endif
00087
00088 #include <Inventor/SoInventorLibName.h>
00089
00090 #include <Inventor/SoModule.h>
00091 SO_MODULE_HEADER(SoInventor, __INVENTORDLL)
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
00219 class SoDB {
00220
00221 public:
00222
00223 SoDEPRECATED enum
00226 RenderCacheMode {
00230 COMPILE,
00234 COMPILE_AND_EXECUTE,
00238 AUTO_RENDER_CACHE
00239 };
00240
00246 static void init();
00247
00259 static void finish();
00260
00261 #if 1 SoDEPRECATED
00270 static void threadInit();
00271 #endif
00283 static void setSystemTimer(SoSystemTimer* timer);
00284
00308 static SbBool read(SoInput *in, SoNode *&rootNode);
00309
00335 static SbBool read(SoInput *in, SoPath *&path);
00336
00353 static SoSeparator *readAll(SoInput *in);
00354
00367 static SbBool registerHeader(const SbString &headerString,
00368 SbBool isBinary,
00369 float ivVersion,
00370 SoDBHeaderCB *preCB,
00371 SoDBHeaderCB *postCB,
00372 void *userData = NULL);
00384 static SbBool getHeaderData(const SbString &string,
00385 SbBool &isBinary,
00386 float &ivVersion,
00387 SoDBHeaderCB *&preCB,
00388 SoDBHeaderCB *&postCB,
00389 void *&userData,
00390 SbBool substringOK = FALSE);
00395 static int getNumHeaders();
00396
00401 static SbString getHeaderString(int i);
00402
00408 static SbBool isValidHeader(const char *testString);
00409
00437 static SoField *createGlobalField(const SbName &name, SoType type);
00438
00444 static SoField *getGlobalField(const SbName &name);
00445
00453 static void renameGlobalField(const SbName &oldName, const SbName &newName);
00454
00490 static void setRealTimeInterval(const SbTime &deltaT);
00491
00500 static const SbTime &getRealTimeInterval();
00501
00518 static void setDelaySensorTimeout(const SbTime &t);
00519
00524 static const SbTime &getDelaySensorTimeout();
00525
00530 static void processEvents();
00531
00542 static int doSelect(int nfds, fd_set *readfds, fd_set *writefds,
00543 fd_set *exceptfds, struct timeval *userTimeOut);
00544
00545 #if 1 SoDEPRECATED
00550 static SbBool isMultiThread();
00551 #endif
00568 static void writelock();
00569
00574 static void writeunlock();
00575
00586 static void readlock();
00587
00592 static void readunlock();
00593
00594 #if 1 SoDEPRECATED
00600 static void setNumRenderCaches( int )
00601 {}
00602 #endif
00604 #if 1 SoDEPRECATED
00609 static int getNumRenderCaches()
00610 { return s_numRenderCaches; }
00611 #endif
00613 #if 1 SoDEPRECATED
00619 static void setRenderCacheMode( RenderCacheMode mode );
00620 #endif
00622 #if 1 SoDEPRECATED
00627 static RenderCacheMode getRenderCacheMode();
00628 #endif
00633 static SbTime getCurrentTime();
00634
00660 static bool addPlugin( const SbString& fileName );
00661
00666 static bool removePlugin( const SbString& fileName );
00667
00672 static const std::vector<SbString>& getLoadedPlugins();
00673
00678 static const std::vector<SbString>& getUnloadedPlugins();
00679
00684 static bool addPluginsDirectory( const SbString& dirName );
00685
00690 static bool removePluginsDirectory( const SbString& dirName );
00691
00696 static const std::vector<SbString>& getPluginsDirectories();
00697
00698 SoEXTENDER_Documented public:
00705 static void addConverter(SoType fromField, SoType toField,
00706 SoType converterEngine);
00707
00713 static SoType getConverter(SoType fromField, SoType toField);
00714
00719 static void removeConverter(SoType fromField, SoType toField);
00720
00725 static void setIvTuneAllowed(SbBool ivTuneAllowed);
00726
00731 static SbBool getIvTuneAllowed();
00732
00733 private:
00734
00735 #ifdef _WIN32
00736
00744 static long openRegistryKey(const SbBool readOnlyFlag=FALSE);
00745
00751 static long getRegistryKeyValue(LPTSTR keyName,
00752 LPTSTR lpValueName,
00753 LPDWORD lpType,
00754 LPBYTE lpData,
00755 LPDWORD lpcbData,
00756 const SbBool readOnlyFlag=FALSE
00757 );
00758
00762 static long closeRegistryKey();
00763
00764 #endif //_WIN32
00765
00766 private:
00767
00768 #if 1 SoDEPRECATED
00773 static void threadFinish();
00774 #endif
00776 // The following two functions are internal-only for now because we do
00777
00778
00779
00780
00781 static SbBool trywritelock();
00782
00783
00784 static SbBool tryreadlock();
00785
00786
00787
00788 static SbThreadRWMutex *getGlobalMutex()
00789 { return SoInventorBase::getGlobalMutex(); }
00790
00791
00792 static SoSensorManager *getSensorManager();
00793
00794
00795 static SoSensorManager *getUnlockSensorManager();
00796
00797
00798 static bool isInitialized();
00799
00800
00801 static SbBool getPickCullingEnabled()
00802 { return m_pickCullingEnabled; }
00803
00804 static const char* profileName;
00805
00806
00807
00808
00809
00810
00811
00812 static void startNotify();
00813 static SbBool isNotifying();
00814 static void endNotify();
00815
00816
00817 static void enableRealTimeSensor(SbBool enable);
00818
00819
00820
00821 static SbBool read(SoInput *in, SoBase *&base);
00822
00823 static SbBool m_readingAll;
00824
00825
00826
00827
00828 static SbString getDirNameFromFullFileName(SoInput *in);
00829
00830
00831 static SbBool useNameCompat;
00832
00833
00834
00835 static SbThreadId_t getMainThreadId();
00836
00838 static bool isInMainThread();
00839
00840
00841 static void resetMainThreadId();
00842
00843
00844 static SbBool unregisterHeader(const SbString &headerString);
00845
00846
00847 SB_THREAD_TLS_HEADER();
00848
00849 private:
00850 #ifdef _WIN32
00851
00852 static HKEY s_vsgRegistryKeys;
00853 #endif
00854
00855 SoDB();
00856 virtual ~SoDB();
00857
00858
00859 static SbThreadMutex *notifyMutex;
00860
00861
00862
00863 static SoGroup *internalReadAll(SoInput *, SoGroup *);
00864
00865
00866
00867 static SoSeparator *readAllFromInputReaders(SoInput *in);
00868
00869
00870 static SbBool useGlobalFieldTime;
00871
00872
00873 class SoGlobalDBInfos
00874 {
00875 public:
00876
00877 SoGlobalDBInfos();
00878
00879
00880 void init();
00881
00882 void cleanup();
00883
00884
00885 ~SoGlobalDBInfos();
00886
00887 SoSensorManager* m_sensorManager;
00888 SoGlobalField* m_globalField;
00889 SoTimerSensor* m_realTimeSensor;
00890 SoSFRealTime *m_realTime;
00891 bool m_isInit;
00892 };
00893
00894
00895 struct MTstruct
00896 {
00897 SoGlobalDBInfos* globalDBInfos;
00898 };
00899
00900
00901
00902
00903 static SoGlobalDBInfos* getGlobalDBInfos();
00904
00905
00906
00907 static SoGlobalDBInfos* s_globalInfos;
00908
00909
00910 static int notifyCount;
00911
00912 static void realTimeSensorCallback(void *data, SoSensor *sensor);
00913
00914
00915 static SbPList *headerList;
00916
00917
00918
00919
00920
00921 static SbDict *conversionDict;
00922
00923
00924 static uint32_t getConversionKey(SoType fromField, SoType toField);
00925
00926 static void iv2_1PreCallback(void *userData, SoInput *in);
00927 static void iv2_0PreCallback(void *userData, SoInput *in);
00928 static void iv1_0PreCallback(void *userData, SoInput *in);
00929 static void iv2_0PostCallback(void *userData, SoInput *in);
00930 static void iv1_0PostCallback(void *userData, SoInput *in);
00931
00932
00933
00934 static int s_numRenderCaches;
00935 static SbBool m_ivTuneAllowed;
00936
00937
00938
00939 static RenderCacheMode s_renderCacheMode;
00940
00941 static SbBool m_pickCullingEnabled;
00942
00943 static int s_initRefCount;
00944
00945 static SbThreadId_t m_mainThreadId;
00946
00947 static bool internalInit();
00948
00949 friend class SoGlobalField;
00950 friend class SoVRMLDB;
00951 friend class SoVRMLInline;
00952 };
00953
00954 #if defined(_WIN32)
00955 #pragma warning( pop )
00956 #endif
00957
00958 #endif
00959
00960
00961