Open Inventor Release 2024.2.1
 
Loading...
Searching...
No Matches
SoBaseContextObject.h
1/*=======================================================================
2 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), ***
3 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. ***
4 *** ***
5 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS ***
6 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR ***
7 *** WRITTEN AUTHORIZATION OF FEI S.A.S. ***
8 *** ***
9 *** RESTRICTED RIGHTS LEGEND ***
10 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS ***
11 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN ***
12 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT ***
13 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN ***
14 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. ***
15 *** ***
16 *** COPYRIGHT (C) 1996-2024 BY FEI S.A.S, ***
17 *** BORDEAUX, FRANCE ***
18 *** ALL RIGHTS RESERVED ***
19**=======================================================================*/
20/*=======================================================================
21** Author : VSG (MMM YYYY)
22**=======================================================================*/
23
24#ifndef SO_CONTEXTED_OBJECT
25#define SO_CONTEXTED_OBJECT
26
27#include <Inventor/SbBase.h>
28#include <Inventor/devices/SoDeviceContextSharedGroup.h>
29#include <Inventor/devices/SoDeviceContext.h>
30#include <Inventor/threads/SbThreadSpinlock.h>
31
43SoEXTENDER_Documented class SoBaseContextObject
44{
45 public:
46
53
58 void ref();
59
71 void unref();
72
76 inline SoDeviceContextSharedGroup* getContextSharedGroup() const { return m_sharedContextGroup; }
77
81 inline int getRefCount() const { return refCount; } // useful for debugging
82
89 virtual void release() {};
90
91 private:
92
99 virtual bool notifyDelete()
100 {
101 if ( m_sharedContextGroup )
102 {
103 SoDeviceContext* ctx = m_sharedContextGroup->getPrimaryContext();
104 if ( ctx && ctx->isCurrent() )
105 return true;
106 }
107
108 return false;
109 };
110
112 virtual ~SoBaseContextObject();
113
114private:
116 int refCount;
117
119 SbThreadSpinlock m_refMutex;
120
122 SoDeviceContextSharedGroup* m_sharedContextGroup;
123
125};
126
127#endif //SO_CONTEXTED_OBJECT
128
129
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Portable spinloc...
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Context dependen...
void ref()
Increment reference count.
int getRefCount() const
Returns the reference count of this instance (initially zero).
SoBaseContextObject(SoDeviceContextSharedGroup *sharedContextGroup)
Constructor.
SoDeviceContextSharedGroup * getContextSharedGroup() const
Returns the OpenGL context in which the OpenGL objects were created.
void unref()
Decrement reference count.
virtual void release()
This function is called by the attached context when it has been requested to delete the context thro...
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Abstract base cl...
virtual bool isCurrent() const =0
Returns true if the context is valid and currently active.
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Shared context m...
SoDeviceContext * getPrimaryContext() const
Returns the first context found in the shared group.