00001 /*======================================================================= 00002 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), *** 00003 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. *** 00004 *** *** 00005 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS *** 00006 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR *** 00007 *** WRITTEN AUTHORIZATION OF FEI S.A.S. *** 00008 *** *** 00009 *** RESTRICTED RIGHTS LEGEND *** 00010 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS *** 00011 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN *** 00012 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT *** 00013 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN *** 00014 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. *** 00015 *** *** 00016 *** COPYRIGHT (C) 1996-2020 BY FEI S.A.S, *** 00017 *** BORDEAUX, FRANCE *** 00018 *** ALL RIGHTS RESERVED *** 00019 **=======================================================================*/ 00020 /*======================================================================= 00021 ** Author : T. ANDRIEU (AUG 2014) 00022 **=======================================================================*/ 00023 00024 00025 #ifndef _SO_CACHE_OBJECT 00026 #define _SO_CACHE_OBJECT 00027 00028 #include <Inventor/caches/SoCache.h> 00029 #include <Inventor/misc/SoRefCounter.h> 00030 #include <Inventor/sensors/SoFieldSensor.h> 00031 00032 #if defined(_WIN32) 00033 #pragma warning(push) 00034 #pragma warning(disable: 4251) // 'identifier' : class 'type' needs to have dll-interface to be used by clients of class 'type2' 00035 #endif 00036 00048 class SoNodeDependencies : public SoRefCounter 00049 { 00050 public: 00051 SoNodeDependencies(); 00052 00053 ~SoNodeDependencies(); 00054 00056 bool isValid(SoState* state) const; 00057 00062 void updateCache(SoState* state); 00063 00067 void invalidate(); 00068 00073 template <typename SO_ELEMENT> 00074 void addDependency() 00075 { 00076 addDependency( SO_ELEMENT::getClassTypeId(), SO_ELEMENT::getClassStackIndex() ); 00077 } 00078 00082 void addDependency( SoField& field ); 00083 00085 void addDependency(SoType type, int classStackIndex); 00086 00087 private: 00088 struct CachedElement 00089 { 00090 CachedElement(SoType& type_, int classStackIndex_) : type(type_), classStackIndex(classStackIndex_) {} 00091 SoType type; // type of element 00092 int classStackIndex; // stackIndex of element in state cache stack. 00093 }; 00094 00100 std::vector<CachedElement> m_elementsDependencies; 00101 00103 std::vector<SoFieldSensor*> m_fieldSensors; 00104 00106 bool m_fieldsValid; 00107 00109 static void fieldSensorCB( void* data, SoSensor* sensor ); 00110 00111 SoRef<SoCache> m_cache; 00112 00113 mutable SbThreadSpinlock m_mutex; 00114 }; 00115 00116 #if defined(_WIN32) 00117 #pragma warning(pop) 00118 #endif 00119 00120 #endif /* _SO_CACHE_OBJECT */ 00121 00122 00123