osg::Referenced Class Reference

`#include <Referenced>`

Inheritance diagram for osg::Referenced:

## Public Member Functions

| Referenced ()
| Referenced (bool threadSafeRefUnref)
| Referenced (const Referenced &)
Referenced & | operator= (const Referenced &)
virtual void | setThreadSafeRefUnref (bool)
bool | getThreadSafeRefUnref () const
OpenThreads::Mutex * | getRefMutex () const
int | ref () const
int | unref () const
int | unref_nodelete () const
int | referenceCount () const
ObserverSet * | getObserverSet () const
ObserverSet * | getOrCreateObserverSet () const
void | addObserver (Observer *observer) const
void | removeObserver (Observer *observer) const

## Static Public Member Functions

static OpenThreads::Mutex * | getGlobalReferencedMutex ()
static void | setDeleteHandler (DeleteHandler *handler)
static DeleteHandler * | getDeleteHandler ()

## Protected Member Functions

virtual | ~Referenced ()
void | signalObserversAndDelete (bool signalDelete, bool doDelete) const
void | deleteUsingDeleteHandler () const

## Protected Attributes

OpenThreads::AtomicPtr | _observerSet
OpenThreads::Atomic | _refCount

## Friends

class | DeleteHandler

## Detailed Description

Base class for providing reference counted objects.

## Constructor & Destructor Documentation

## Referenced() [1/3]

osg::Referenced::Referenced | ( |  | ) |

Referenced by osg::ObserverSet::addRefLock(), osgWidget::Callback::Callback(), osg::CullingSet::CullingSet(), osgDB::DatabasePager::DatabaseRequest::DatabaseRequest(), osg::NodeVisitor::DatabaseRequestHandler::DatabaseRequestHandler(), osg::Image::DimensionsChangedCallback::DimensionsChangedCallback(), osg::DisplaySettings::DisplaySettings(), osg::DisplaySettings::DisplaySettings(), osgDB::DotOsgWrapper::DotOsgWrapper(), osgDB::DynamicLibrary::DynamicLibrary(), osgDB::DynamicLibrary::DynamicLibrary(), osgText::Font::FontImplementation::FontImplementation(), osg::ObserverSet::getObserverdObject(), osg::ObserverSet::getObserverdObject(), osg::Object::getUserData(), osg::Object::getUserData(), osgDB::ImagePager::ImageRequest::ImageRequest(), osg::NodeVisitor::ImageRequestHandler::ImageRequestHandler(), osg::LineSegment::LineSegment(), osg::Object::Object(), osg::Object::Object(), osg::ObserverSet::ObserverSet(), osg::ObserverSet::ObserverSet(), operator=(), osgGA::PointerData::PointerData(), osg::RefBlock::RefBlock(), osg::RefBlockCount::RefBlockCount(), Referenced(), osgUtil::RenderLeaf::RenderLeaf(), osg::Object::setUserData(), and osgFX::Technique::Technique().

## Referenced() [2/3]

osg::Referenced::Referenced | ( | bool | threadSafeRefUnref | ) |

explicit

Deprecated, Referenced is now always uses thread safe ref/unref, use default Referenced() constructor instead

## Referenced() [3/3]

osg::Referenced::Referenced | ( | const Referenced & |  | ) |

References Referenced().

## ~Referenced()

virtual osg::Referenced::~Referenced | ( |  | ) |

protected virtual

## Member Function Documentation

## addObserver()

void osg::Referenced::addObserver | ( | Observer * | observer | ) | const

Add a Observer that is observing this object, notify the Observer when this object gets deleted.

## deleteUsingDeleteHandler()

void osg::Referenced::deleteUsingDeleteHandler | ( |  | ) | const

protected

## getDeleteHandler()

DeleteHandler * osg::Referenced::getDeleteHandler | ( |  | ) |

static

Get a DeleteHandler.

References DeleteHandler.

## getGlobalReferencedMutex()

OpenThreads::Mutex * osg::Referenced::getGlobalReferencedMutex | ( |  | ) |

static

Get the optional global Referenced mutex, this can be shared between all osg::Referenced.

References ref(), and unref().

Referenced by getRefMutex().

## getObserverSet()

ObserverSet * osg::Referenced::getObserverSet | ( |  | ) | const

inline

Get the ObserverSet if one is attached, otherwise return NULL.

References _observerSet.

## getOrCreateObserverSet()

ObserverSet * osg::Referenced::getOrCreateObserverSet | ( |  | ) | const

Get the ObserverSet if one is attached, otherwise create an ObserverSet, attach it, then return this newly created ObserverSet.

## getRefMutex()

OpenThreads::Mutex * osg::Referenced::getRefMutex | ( |  | ) | const

inline

Get the mutex used to ensure thread safety of ref()/unref().

References getGlobalReferencedMutex().

## getThreadSafeRefUnref()

bool osg::Referenced::getThreadSafeRefUnref | ( |  | ) | const

inline

Get whether a mutex is used to ensure ref() and unref() are thread safe.

## operator=()

Referenced & osg::Referenced::operator= | ( | const Referenced & |  | ) |

inline

References Referenced().

## ref()

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::AlphaFunc::AlphaFunc(), getGlobalReferencedMutex(), osg::intrusive_ptr_add_ref(), osgPresentation::PropertyManager::ref(), osg::AlphaFunc::setFunction(), osg::Stencil::setFunction(), osg::StencilTwoSided::setFunction(), osg::Stencil::setFunctionRef(), and osg::StencilTwoSided::setFunctionRef().

## referenceCount()

int osg::Referenced::referenceCount | ( |  | ) | const

inline

Return the number of pointers currently referencing this object.

References _refCount.

Referenced by osgAnimation::Target::getCount().

## removeObserver()

void osg::Referenced::removeObserver | ( | Observer * | observer | ) | const

Remove Observer that is observing this object.

References osg::resizeGLObjectBuffers().

## setDeleteHandler()

void osg::Referenced::setDeleteHandler | ( | DeleteHandler * | handler | ) |

static

Set a DeleteHandler to which deletion of all referenced counted objects will be delegated.

References DeleteHandler.

## setThreadSafeRefUnref()

virtual void osg::Referenced::setThreadSafeRefUnref | ( | bool |  | ) |

inline virtual

Deprecated, Referenced is always theadsafe so there method now has no effect and does not need to be called.

Reimplemented in osg::Drawable, osg::Group, osg::LightSource, osg::Node, osg::Object, osg::Program, osg::StateSet, osg::TexGenNode, osgSim::OverlayNode::OverlayData, osgSim::OverlayNode, osgText::Font, osgText::Glyph3D, osgText::GlyphGeometry, and osgText::GlyphTexture.

Referenced by osg::TestResult::TestResult().

## signalObserversAndDelete()

void osg::Referenced::signalObserversAndDelete | ( | bool | signalDelete,
|  | bool | doDelete ) const

protected

Referenced by unref().

## unref()

int osg::Referenced::unref | ( |  | ) | const

inline

Decrement the reference count by one, indicating that a pointer to this object is no longer 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 getGlobalReferencedMutex(), osg::intrusive_ptr_release(), and osgPresentation::PropertyManager::unref().

## unref_nodelete()

int osg::Referenced::unref_nodelete | ( |  | ) | const

Decrement the reference count by one, indicating that a pointer to this object is no longer 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< object_type >::lock(), and osg::ref_ptr< osg::Vec3Array >::release().

## Friends And Related Symbol Documentation

## DeleteHandler

friend class DeleteHandler

friend

References DeleteHandler.

Referenced by DeleteHandler, getDeleteHandler(), and setDeleteHandler().

## Member Data Documentation

## _observerSet

OpenThreads::AtomicPtr osg::Referenced::_observerSet

mutable protected

Referenced by getObserverSet().

## _refCount

OpenThreads::Atomic osg::Referenced::_refCount

mutable protected

Referenced by ref(), referenceCount(), and unref().

The documentation for this class was generated from the following file:

- Referenced