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 template <class T> static void
00848 syncFieldGlobaly( T& field, const SbName& name )
00849 {
00850 T* globalField = static_cast<T*>( getGlobalField( name ) );
00851 if ( !globalField )
00852 {
00853 globalField = static_cast<T*>( createGlobalField( name, T::getClassTypeId() ) );
00854 globalField->setValue( field.getValue() );
00855 }
00856 field.connectFrom( globalField );
00857 field.setOnValueChangedCallback( [name]( SoField* _field ) {
00858 T* field = static_cast<T*>( _field );
00859 T* globalField = static_cast<T*>( getGlobalField( name ) );
00860 if ( globalField && ( *field != *globalField ) )
00861 *globalField = *field;
00862 } );
00863 }
00864
00865
00866 SB_THREAD_TLS_HEADER();
00867
00868 private:
00869 #ifdef _WIN32
00870
00871 static HKEY s_vsgRegistryKeys;
00872 #endif
00873
00874 SoDB();
00875 virtual ~SoDB();
00876
00877
00878 static SbThreadMutex *notifyMutex;
00879
00880
00881
00882 static SoGroup *internalReadAll(SoInput *, SoGroup *);
00883
00884
00885
00886 static SoSeparator *readAllFromInputReaders(SoInput *in);
00887
00888
00889 static SbBool useGlobalFieldTime;
00890
00891
00892
00893 static bool s_notUseGPU;
00894
00895
00896 class SoGlobalDBInfos
00897 {
00898 public:
00899
00900 SoGlobalDBInfos();
00901
00902
00903 void init();
00904
00905 void cleanup();
00906
00907
00908 ~SoGlobalDBInfos();
00909
00910 SoSensorManager* m_sensorManager;
00911 SoGlobalField* m_globalField;
00912 SoTimerSensor* m_realTimeSensor;
00913 SoSFRealTime *m_realTime;
00914 bool m_isInit;
00915 };
00916
00917
00918 struct MTstruct
00919 {
00920 SoGlobalDBInfos* globalDBInfos;
00921 };
00922
00923
00924
00925
00926 static SoGlobalDBInfos* getGlobalDBInfos();
00927
00928
00929
00930 static SoGlobalDBInfos* s_globalInfos;
00931
00932
00933 static int notifyCount;
00934
00935 static void realTimeSensorCallback(void *data, SoSensor *sensor);
00936
00937
00938 static SbPList *headerList;
00939
00940
00941
00942
00943
00944 static SbDict *conversionDict;
00945
00946
00947 static uint32_t getConversionKey(SoType fromField, SoType toField);
00948
00949 static void iv2_1PreCallback(void *userData, SoInput *in);
00950 static void iv2_0PreCallback(void *userData, SoInput *in);
00951 static void iv1_0PreCallback(void *userData, SoInput *in);
00952 static void iv2_0PostCallback(void *userData, SoInput *in);
00953 static void iv1_0PostCallback(void *userData, SoInput *in);
00954
00955
00956
00957 static int s_numRenderCaches;
00958 static SbBool m_ivTuneAllowed;
00959
00960
00961
00962 static RenderCacheMode s_renderCacheMode;
00963
00964 static SbBool m_pickCullingEnabled;
00965
00966 static int s_initRefCount;
00967
00968 static SbThreadId_t m_mainThreadId;
00969
00970 static bool internalInit();
00971
00972 friend class SoGlobalField;
00973 friend class SoVRMLDB;
00974 friend class SoVRMLInline;
00975 };
00976
00977 #if defined(_WIN32)
00978 #pragma warning( pop )
00979 #endif
00980
00981 #endif
00982
00983
00984