OpenSceneGraph 2.8.3

osg::Referenced Class Reference

Base class from providing referencing counted objects. More...

Inherited by osg::ApplicationUsage, osg::BlendColor::Extensions, osg::BlendEquation::Extensions, osg::BlendFunc::Extensions, osg::BufferObject::Extensions, osg::ClampColor::Extensions, osg::CullingSet, osg::CullSettings::ClampProjectionMatrixCallback, osg::DisplaySettings, osg::Drawable::Extensions, osg::FBOExtensions, osg::FragmentProgram::Extensions, osg::FrameStamp, osg::GL2Extensions, osg::GraphicsContext::ResizedCallback, osg::GraphicsContext::Traits, osg::GraphicsContext::WindowingSystemInterface, osg::LineSegment, osg::Multisample::Extensions, osg::NodeVisitor [virtual], osg::NodeVisitor::DatabaseRequestHandler, osg::NodeVisitor::ImageRequestHandler, osg::Object, osg::Operation [virtual], osg::OperationQueue, osg::OperationThread, osg::Point::Extensions, osg::Program::PerContextProgram, osg::RefBlock [virtual], osg::RefBlockCount [virtual], osg::Shader::PerContextShader, osg::State, osg::State::DynamicObjectRenderingCompletedCallback, osg::Stats, osg::StencilTwoSided::Extensions, osg::Texture1D::SubloadCallback, osg::Texture2D::SubloadCallback, osg::Texture2DArray::Extensions, osg::Texture2DArray::SubloadCallback, osg::Texture3D::Extensions, osg::Texture3D::SubloadCallback, osg::Texture::Extensions, osg::Texture::TextureObject, osg::TextureCubeMap::Extensions, osg::TextureCubeMap::SubloadCallback, osg::TextureRectangle::SubloadCallback, osg::VertexProgram::Extensions, osgAnimation::ActionVisitor, osgAnimation::Channel, osgAnimation::KeyframeContainer, osgAnimation::Motion, osgAnimation::RigTransform, osgAnimation::Sampler, osgAnimation::Target, osgAnimation::TemplateCompositeSampler< VALUESAMPLERTYPE, TIMESAMPLERTYPE >, osgDB::AuthenticationDetails, osgDB::AuthenticationMap, osgDB::DatabasePager::DatabaseRequest, osgDB::DatabasePager::DatabaseThread, osgDB::DatabasePager::RequestQueue, osgDB::DotOsgWrapper, osgDB::DynamicLibrary, osgDB::FileCache, osgDB::ImageOptions::TexCoordRange, osgDB::ImagePager::ImageRequest, osgDB::ImagePager::ImageThread, osgDB::ImagePager::RequestQueue, osgDB::ReaderWriterInfo, osgDB::Registry, osgDB::Registry::ReadFileCallback [virtual], osgDB::Registry::WriteFileCallback [virtual], osgDB::Serializer, osgFX::Registry, osgFX::Technique, osgGA::EventQueue, osgGA::MatrixManipulator::CoordinateFrameCallback, osgManipulator::CommandManager, osgManipulator::Constraint, osgManipulator::MotionCommand, osgManipulator::Projector, osgShadow::ParallelSplitShadowMap::FragmentShaderGenerator, osgShadow::ViewDependentShadowTechnique::ViewData, osgSim::GeographicLocation, osgSim::ImpostorSpriteManager, osgSim::OverlayNode::OverlayData, osgSim::ScalarBar::ScalarPrinter, osgSim::ScalarsToColors, osgTerrain::TerrainTile::TileLoadedCallback, osgTerrain::ValidDataOperator, osgText::Font3D::Font3DImplementation, osgText::Font3D::Glyph3D, osgText::Font::FontImplementation, osgUtil::CubeMapGenerator, osgUtil::DelaunayTriangulator, osgUtil::EdgeCollector::Edge, osgUtil::EdgeCollector::Edgeloop, osgUtil::EdgeCollector::Point, osgUtil::EdgeCollector::Triangle, osgUtil::IntersectionVisitor::ReadCallback, osgUtil::Intersector, osgUtil::IntersectVisitor::IntersectState, osgUtil::Optimizer::IsOperationPermissibleForObjectCallback, osgUtil::Optimizer::TextureAtlasBuilder::Atlas, osgUtil::Optimizer::TextureAtlasBuilder::Source, osgUtil::RenderBin::DrawCallback, osgUtil::RenderBin::SortCallback, osgUtil::RenderLeaf, osgUtil::SceneView::ComputeStereoMatricesCallback, osgUtil::Simplifier::ContinueSimplificationCallback, osgUtil::StateGraph, osgUtil::TangentSpaceGenerator, osgUtil::Tessellator, osgUtil::Tessellator::Prim, osgViewer::GraphicsWindowWin32::WindowData, osgViewer::GraphicsWindowX11::WindowData, osgViewer::Scene, osgViewer::ScreenCaptureHandler::CaptureOperation, osgWidget::Callback, osgWidget::CallbackInterface, and osgWidget::ScriptEngine.

List of all members.

Public Member Functions

 Referenced ()
 Referenced (bool threadSafeRefUnref)
 Referenced (const Referenced &)
Referencedoperator= (const Referenced &)
virtual void setThreadSafeRefUnref (bool threadSafe)
 Set whether to use a mutex to ensure ref() and unref() are thread safe.
bool getThreadSafeRefUnref () const
 Get whether a mutex is used to ensure ref() and unref() are thread safe.
OpenThreads::Mutex * getRefMutex () const
 Get the mutex used to ensure thread safety of ref()/unref().
void ref () const
 Increment the reference count by one, indicating that this object has another pointer which is referencing it.
void unref () const
 Decrement the reference count by one, indicating that a pointer to this object is referencing it.
void unref_nodelete () const
 Decrement the reference count by one, indicating that a pointer to this object is referencing it.
int referenceCount () const
 Return the number pointers currently referencing this object.
void addObserver (Observer *observer) const
 Add a Observer that is observing this object, notify the Observer when this object gets deleted.
void removeObserver (Observer *observer) const
 Add a Observer that is observing this object, notify the Observer when this object gets deleted.

Static Public Member Functions

static OpenThreads::Mutex * getGlobalReferencedMutex ()
 Get the optional global Referenced mutex, this can be shared between all osg::Referenced.
static void setThreadSafeReferenceCounting (bool enableThreadSafeReferenceCounting)
 Set whether reference counting should be use a mutex to create thread reference counting.
static bool getThreadSafeReferenceCounting ()
 Get whether reference counting is active.
static void setDeleteHandler (DeleteHandler *handler)
 Set a DeleteHandler to which deletion of all referenced counted objects will be delegated to.
static DeleteHandlergetDeleteHandler ()
 Get a DeleteHandler.

Protected Member Functions

virtual ~Referenced ()
void deleteUsingDeleteHandler () const

Protected Attributes

OpenThreads::AtomicPtr _observerSetDataPtr
OpenThreads::Atomic _refCount

Friends

class DeleteHandler

Detailed Description

Base class from providing referencing counted objects.


Constructor & Destructor Documentation

osg::Referenced::Referenced ( )
osg::Referenced::Referenced ( bool  threadSafeRefUnref) [explicit]
osg::Referenced::Referenced ( const Referenced )
virtual osg::Referenced::~Referenced ( ) [protected, virtual]

Member Function Documentation

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]

Referenced by unref().

static DeleteHandler* osg::Referenced::getDeleteHandler ( ) [static]

Get a DeleteHandler.

Referenced by unref().

static OpenThreads::Mutex* osg::Referenced::getGlobalReferencedMutex ( ) [static]

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

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]

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

Referenced& osg::Referenced::operator= ( const Referenced ) [inline]
void 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 pointers currently referencing this object.

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

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

static void osg::Referenced::setDeleteHandler ( DeleteHandler handler) [static]

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

static void osg::Referenced::setThreadSafeReferenceCounting ( bool  enableThreadSafeReferenceCounting) [static]

Set whether reference counting should be use a mutex to create thread reference counting.

virtual void osg::Referenced::setThreadSafeRefUnref ( bool  threadSafe) [virtual]
void 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, deleteUsingDeleteHandler(), and getDeleteHandler().

Referenced by osg::intrusive_ptr_release().

void 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 later can lead to memory leaks.


Friends And Related Function Documentation

friend class DeleteHandler [friend]

Member Data Documentation

OpenThreads::AtomicPtr osg::Referenced::_observerSetDataPtr [mutable, protected]
OpenThreads::Atomic osg::Referenced::_refCount [mutable, protected]

Referenced by ref(), and unref().


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

osg logo
Generated at Tue Mar 22 2011 13:20:23 for the OpenSceneGraph by doxygen 1.7.3.