00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #if !defined SO_DEVICE_CONTEXT_SHARE_GROUP_H
00025 #define SO_DEVICE_CONTEXT_SHARE_GROUP_H
00026
00027 #include <Inventor/misc/SoRefCounter.h>
00028 #include <Inventor/STL/set>
00029 #include <Inventor/threads/SbThreadMutex.h>
00030 #include <Inventor/devices/SoSharedGroupReferenceList.h>
00031
00032 class SoDeviceContext;
00033 class SoBaseContextCache;
00034 class SoBaseContextObject;
00035
00036 #ifdef _MSC_VER
00037 #pragma warning( push )
00038 #pragma warning(disable:4251)
00039 #endif
00040
00051 class SoDeviceContextSharedGroup : public SoRefCounter
00052 {
00053 public:
00055 typedef std::set<SoDeviceContext*> SoDeviceContextSet;
00056
00058 SoDeviceContextSharedGroup();
00059
00061 SoDeviceContextSharedGroup(int id);
00062
00064 void add(SoDeviceContext* ctx);
00065
00067 void remove(SoDeviceContext* ctx);
00068
00070 void setId( int id );
00071
00073 int getId() const;
00074
00076 const SoDeviceContextSet& getContexts() const;
00077
00079 SoDeviceContext* getPrimaryContext() const;
00080
00082 bool contains(const SoDeviceContext* ctx) const;
00083
00089 void ref(SoBaseContextCache* object = NULL);
00090
00101 void unref(SoBaseContextCache* object = NULL);
00102
00103
00107 bool contains(SoBaseContextCache* object) const;
00108
00113 virtual void dispose();
00114
00115 private:
00116
00117 void setTargetMergedGroup(SoDeviceContextSharedGroup* sharedGroup);
00118
00122 void addToPendingDeleteList(SoBaseContextObject *obj);
00123
00127 static void checkRefIssues(SoBaseContextObject* object);
00128 static void checkRefIssues(SoBaseContextCache* cache);
00129
00131 void clearPendingDeleteList();
00132
00133 void setDisposing( bool b );
00134
00136 SbThreadId_t getThreadId() const;
00137
00139 static int getNewSharedIdGroup();
00140
00142 static void printSharedGroups();
00143
00147 bool hasValidContext() const;
00148
00150 SoDeviceContext* getPrimaryValidContext() const;
00151
00152
00153 static int getDebuggingLevel()
00154 { return s_debuggingLevel; }
00155
00156 private:
00157
00159 virtual ~SoDeviceContextSharedGroup();
00160
00165 void forceReleaseAttachedObject();
00166
00167 bool m_isDisposing;
00168
00169 private:
00170
00171 void commonConstructor();
00172
00173
00174
00175
00176 SoDeviceContext* getDeviceContextToBindForDelete() const;
00177
00178 SoDeviceContextSet m_ctxSet;
00179 int m_id;
00180 SoDeviceContextSharedGroup* m_mergedGroup;
00181
00183 typedef std::list<SoDeviceContextSharedGroup*> SoDeviceContexSharedGroupList;
00184 static SbThreadSpinlock s_sharedGroupListLock;
00185 static SoDeviceContexSharedGroupList s_sharedGroupList;
00186 static int s_sharedGroupId;
00187
00189 typedef std::list<SoBaseContextCache*> SoBaseContextCacheList;
00190 SoBaseContextCacheList m_listContextedObject;
00191 bool m_isClearingPendingList;
00192
00194 SoSharedGroupReferenceList m_intrusivelistContextedObject;
00195
00197 typedef std::set<SoBaseContextObject*> SoBaseContextObjectList;
00198 SoBaseContextObjectList m_waitingToBeFreed;
00199
00201 SbThreadId_t m_threadId;
00202
00209 mutable SbThreadMutex m_sharedGroupMembersMutex;
00210
00211
00212
00213
00214
00215 static int s_debuggingLevel;
00216 };
00217
00218
00219 inline void SoDeviceContextSharedGroup::setDisposing( bool b )
00220 {
00221 m_isDisposing = b;
00222 }
00223
00224 inline SbThreadId_t SoDeviceContextSharedGroup::getThreadId() const
00225 {
00226 return m_threadId;
00227 }
00228
00229 #ifdef _MSC_VER
00230 #pragma warning( pop )
00231 #endif
00232
00233 #endif // SO_DEVICE_CONTEXT_SHARE_GROUP_H
00234
00235
00236