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 : VSG (MMM YYYY) 00022 **=======================================================================*/ 00023 00024 #ifndef SO_CONTEXTED_OBJECT 00025 #define SO_CONTEXTED_OBJECT 00026 00027 #include <Inventor/SbBase.h> 00028 #include <Inventor/devices/SoDeviceContextSharedGroup.h> 00029 #include <Inventor/devices/SoDeviceContext.h> 00030 #include <Inventor/threads/SbThreadSpinlock.h> 00031 00043 SoEXTENDER_Documented class SoBaseContextObject 00044 { 00045 public: 00046 00052 SoBaseContextObject(SoDeviceContextSharedGroup *sharedContextGroup); 00053 00058 void ref(); 00059 00071 void unref(); 00072 00076 inline SoDeviceContextSharedGroup* getContextSharedGroup() const { return m_sharedContextGroup; } 00077 00081 inline int getRefCount() const { return refCount; } // useful for debugging 00082 00089 virtual void release() {}; 00090 00091 private: 00092 00099 virtual bool notifyDelete() 00100 { 00101 if ( m_sharedContextGroup ) 00102 { 00103 SoDeviceContext* ctx = m_sharedContextGroup->getPrimaryContext(); 00104 if ( ctx && ctx->isCurrent() ) 00105 return true; 00106 } 00107 00108 return false; 00109 }; 00110 00112 virtual ~SoBaseContextObject(); 00113 00114 private: 00116 int refCount; 00117 00119 SbThreadSpinlock m_refMutex; 00120 00122 SoDeviceContextSharedGroup* m_sharedContextGroup; 00123 00124 friend class SoDeviceContextSharedGroup; 00125 }; 00126 00127 #endif //SO_CONTEXTED_OBJECT 00128 00129 00130