openscenegraph
|
Base class for providing reference counted objects.
osg::Referenced::Referenced | ( | ) |
osg::Referenced::Referenced | ( | bool | threadSafeRefUnref | ) | [explicit] |
osg::Referenced::Referenced | ( | const Referenced & | ) |
virtual osg::Referenced::~Referenced | ( | ) | [protected, virtual] |
void osg::Referenced::addObserver | ( | Observer * | observer | ) | const |
Add a Observer that is observing this object, notify the Observer when this object gets deleted.
Referenced by osg::State::setLastAppliedProgramObject().
void osg::Referenced::deleteUsingDeleteHandler | ( | ) | const [protected] |
static DeleteHandler* osg::Referenced::getDeleteHandler | ( | ) | [static] |
Get a DeleteHandler.
static OpenThreads::Mutex* osg::Referenced::getGlobalReferencedMutex | ( | ) | [static] |
Get the optional global Referenced mutex, this can be shared between all osg::Referenced.
ObserverSet* osg::Referenced::getObserverSet | ( | ) | const [inline] |
Get the ObserverSet if one is attached, otherwise return NULL.
ObserverSet* osg::Referenced::getOrCreateObserverSet | ( | ) | const |
Get the ObserverSet if one is attached, otherwise create an ObserverSet, attach it, then return this newly created ObserverSet.
OpenThreads::Mutex* osg::Referenced::getRefMutex | ( | ) | const [inline] |
Get the mutex used to ensure thread safety of ref()/unref().
static bool osg::Referenced::getThreadSafeReferenceCounting | ( | ) | [static] |
Get whether reference counting is active.
bool osg::Referenced::getThreadSafeRefUnref | ( | ) | const [inline] |
Referenced& osg::Referenced::operator= | ( | const Referenced & | ) | [inline] |
int osg::Referenced::ref | ( | ) | const [inline] |
Increment the reference count by one, indicating that this object has another pointer which is referencing it.
References _refCount.
Referenced by osg::intrusive_ptr_add_ref().
int osg::Referenced::referenceCount | ( | ) | const [inline] |
Return the number of pointers currently referencing this object.
void osg::Referenced::removeObserver | ( | Observer * | observer | ) | const |
Remove Observer that is observing this object.
static void osg::Referenced::setDeleteHandler | ( | DeleteHandler * | handler | ) | [static] |
Set a DeleteHandler to which deletion of all referenced counted objects will be delegated.
static void osg::Referenced::setThreadSafeReferenceCounting | ( | bool | enableThreadSafeReferenceCounting | ) | [static] |
Set whether reference counting should use a mutex for thread safe reference counting.
virtual void osg::Referenced::setThreadSafeRefUnref | ( | bool | threadSafe | ) | [virtual] |
Set whether to use a mutex to ensure ref() and unref() are thread safe.
Reimplemented in osg::Drawable, osg::Geode, osg::Group, osg::LightSource, osg::Node, osg::Object, osg::Program, osg::StateSet, osg::TexGenNode, osgSim::OverlayNode, osgSim::OverlayNode::OverlayData, osgText::Font, osgText::GlyphGeometry, osgText::Glyph3D, osgText::GlyphTexture, osgText::Text, osgText::Text3D, and osgText::TextBase.
void osg::Referenced::signalObserversAndDelete | ( | bool | signalDelete, |
bool | doDelete | ||
) | const [protected] |
Referenced by unref().
int osg::Referenced::unref | ( | ) | const [inline] |
Decrement the reference count by one, indicating that a pointer to this object is referencing it. If the reference count goes to zero, it is assumed that this object is no longer referenced and is automatically deleted.
References _refCount, and signalObserversAndDelete().
Referenced by osg::intrusive_ptr_release().
int osg::Referenced::unref_nodelete | ( | ) | const |
Decrement the reference count by one, indicating that a pointer to this object is referencing it. However, do not delete it, even if ref count goes to 0. Warning, unref_nodelete() should only be called if the user knows exactly who will be responsible for, one should prefer unref() over unref_nodelete() as the latter can lead to memory leaks.
Referenced by osg::observer_ptr< Skeleton >::lock().
friend class DeleteHandler [friend] |
OpenThreads::AtomicPtr osg::Referenced::_observerSet [mutable, protected] |
OpenThreads::Atomic osg::Referenced::_refCount [mutable, protected] |