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 #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; 
00092     int classStackIndex; 
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 
00121 
00122 
00123