OpenSceneGraph  3.0.1
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes
osg::Object Class Reference

Base class/standard interface for objects which require IO support, cloning and reference counting. More...

Inherits osg::Referenced.

Inherited by osg::AnimationPath [virtual], osg::AudioSink, osg::AudioStream, osg::BufferData, osg::BufferData::ModifiedCallback [virtual], osg::BufferObject, osg::Camera::DrawCallback [virtual], osg::ConvexPlanarOccluder, osg::Drawable, osg::Drawable::ComputeBoundingBoxCallback, osg::Drawable::CullCallback [virtual], osg::Drawable::DrawCallback [virtual], osg::Drawable::EventCallback [virtual], osg::Drawable::UpdateCallback [virtual], osg::EllipsoidModel, osg::GraphicsContext, osg::Node, osg::Node::ComputeBoundingSphereCallback, osg::NodeCallback [virtual], osg::Program::ProgramBinary, osg::RefMatrixd, osg::RefMatrixf, osg::RenderBuffer, osg::Shader, osg::ShaderBinary, osg::ShaderComponent, osg::ShaderComposer, osg::Shape, osg::StateAttribute, osg::StateAttributeCallback [virtual], osg::StateSet, osg::StateSet::Callback [virtual], osg::TessellationHints, osg::TransferFunction, osg::Uniform, osg::Uniform::Callback [virtual], osg::UserDataContainer, osg::ValueObject, osg::View [virtual], osgAnimation::Action, osgAnimation::Action::Callback, osgAnimation::Animation, osgAnimation::AnimationUpdateCallbackBase [virtual], osgAnimation::StackedTransformElement, osgAnimation::VertexInfluenceMap, osgDB::DatabaseRevision, osgDB::DatabaseRevisions, osgDB::FileList, osgDB::ImageProcessor, osgDB::Options, osgDB::ReaderWriter, osgGA::GUIEventAdapter, osgManipulator::DraggerCallback [virtual], osgParticle::Counter, osgParticle::Interpolator, osgParticle::Operator, osgParticle::Placer, osgParticle::Shooter, osgShadow::ShadowTechnique, osgSim::BlinkSequence, osgSim::LightPointSystem, osgSim::ObjectRecordData, osgSim::Sector, osgSim::SequenceGroup, osgSim::ShapeAttributeList, osgTerrain::Layer, osgTerrain::Locator, osgTerrain::TerrainTechnique, osgText::Bevel, osgText::Font, osgText::Style, osgUtil::PositionalStateContainer, osgUtil::RenderBin, osgUtil::SceneView, osgViewer::ViewerBase [virtual], osgVolume::ImageDetails, osgVolume::Layer, osgVolume::Locator, osgVolume::Locator::LocatorCallback [virtual], osgVolume::Property, osgVolume::VolumeTechnique, osgWidget::BrowserManager, osgWidget::Style, and osgWidget::StyleManager.

List of all members.

Public Types

enum  DataVariance { DYNAMIC, STATIC, UNSPECIFIED }

Public Member Functions

 Object ()
 Construct an object.
 Object (bool threadSafeRefUnref)
 Object (const Object &, const CopyOp &copyop=CopyOp::SHALLOW_COPY)
 Copy constructor, optional CopyOp object can be used to control shallow vs deep copying of dynamic data.
virtual ObjectcloneType () const =0
 Clone the type of an object, with Object* return type.
virtual Objectclone (const CopyOp &) const =0
 Clone an object, with Object* return type.
virtual bool isSameKindAs (const Object *) const
virtual const char * libraryName () const =0
 return the name of the object's library.
virtual const char * className () const =0
 return the name of the object's class type.
virtual void setThreadSafeRefUnref (bool threadSafe)
 Set whether to use a mutex to ensure ref() and unref() are thread safe.
virtual void setName (const std::string &name)
 Set the name of object using C++ style string.
void setName (const char *name)
 Set the name of object using a C style string.
const std::string & getName () const
 Get the name of object.
void setDataVariance (DataVariance dv)
 Set the data variance of this object.
DataVariance getDataVariance () const
 Get the data variance of this object.
virtual void computeDataVariance ()
 Compute the DataVariance based on an assessment of callback etc.
void setUserDataContainer (osg::UserDataContainer *udc)
 set the UserDataContainer object.
osg::UserDataContainergetUserDataContainer ()
 get the UserDataContainer attached to this object.
const osg::UserDataContainergetUserDataContainer () const
 get the const UserDataContainer attached to this object.
osg::UserDataContainergetOrCreateUserDataContainer ()
 Convinience method that returns the UserDataContainer, and if one doesn't already exist creates and assigns a DefaultUserDataContainer to the Object and then return this new UserDataContainer.
virtual void setUserData (Referenced *obj)
 Set user data, data must be subclassed from Referenced to allow automatic memory handling.
virtual ReferencedgetUserData ()
 Get user data.
virtual const ReferencedgetUserData () const
 Get const user data.
template<typename T >
bool getUserValue (const std::string &name, T &value) const
 Convinience method that casts the named UserObject to osg::TemplateValueObject<T> and gets the value.
template<typename T >
void setUserValue (const std::string &name, const T &value)
 Convinience method that creates the osg::TemplateValueObject<T> to store the specified value and adds it as a named UserObject.
virtual void resizeGLObjectBuffers (unsigned int)
 Resize any per context GLObject buffers to specified size.
virtual void releaseGLObjects (osg::State *=0) const
 If State is non-zero, this function releases any associated OpenGL objects for the specified graphics context.

Protected Member Functions

virtual ~Object ()
 Object destructor.

Protected Attributes

std::string _name
DataVariance _dataVariance
osg::UserDataContainer_userDataContainer

Detailed Description

Base class/standard interface for objects which require IO support, cloning and reference counting.

Based on GOF Composite, Prototype and Template Method patterns.


Member Enumeration Documentation

Enumerator:
DYNAMIC 
STATIC 
UNSPECIFIED 

Constructor & Destructor Documentation

osg::Object::Object ( ) [inline]

Construct an object.

Note Object is a pure virtual base class and therefore cannot be constructed on its own, only derived classes which override the clone and className methods are concrete classes and can be constructed.

osg::Object::Object ( bool  threadSafeRefUnref) [inline, explicit]
osg::Object::Object ( const Object ,
const CopyOp copyop = CopyOp::SHALLOW_COPY 
)

Copy constructor, optional CopyOp object can be used to control shallow vs deep copying of dynamic data.

virtual osg::Object::~Object ( ) [protected, virtual]

Object destructor.

Note, is protected so that Objects cannot be deleted other than by being dereferenced and the reference count being zero (see osg::Referenced), preventing the deletion of nodes which are still in use. This also means that Nodes cannot be created on stack i.e Node node will not compile, forcing all nodes to be created on the heap i.e Node* node = new Node().


Member Function Documentation

virtual const char* osg::Object::className ( ) const [pure virtual]

return the name of the object's class type.

Must be defined by derived classes.

Implemented in osg::BufferData, osg::DrawElementsUInt, osg::RefMatrixf, osg::BufferObject, osg::GraphicsContext, osg::DrawElementsUShort, osg::DrawElementsUByte, osg::RefMatrixd, osg::DrawArrayLengths, osg::Texture, osg::DrawArrays, osgText::GlyphTexture, osgViewer::GraphicsWindowEmbedded, osg::StateAttribute, osgShadow::ShadowVolumeGeometry, osg::PrimitiveSet, osg::ShapeDrawable, osg::TemplateValueObject, osg::Drawable, osg::Image, osg::Array, osg::Node, osgText::Font, osgViewer::GraphicsWindowX11, osg::Shape, osgFX::Effect, osgUtil::RenderBin, osgAnimation::MorphGeometry, osg::Light, osgGA::UFOManipulator, osg::AudioStream, osg::ClipPlane, osg::StateSet, osgSim::ImpostorSprite, osgGA::StandardManipulator, osgParticle::ParticleProcessor, osgUtil::RenderStage, osgViewer::GraphicsWindow, osgGA::CameraManipulator, osgShadow::OccluderGeometry, osg::Hint, osgGA::AnimationPathManipulator, osgParticle::Program, osg::DrawPixels, osgParticle::Emitter, osgParticle::Operator, osgParticle::ParticleEffect, osg::Geometry, osg::ImageSequence, osg::UserDataContainer, osgParticle::Interpolator, osgUtil::PositionalStateContainer, osgGA::KeySwitchMatrixManipulator, osgGA::StateSetManipulator, osgSim::Sector, osgViewer::GraphicsWindowWin32, osgViewer::PixelBufferWin32, osg::AutoTransform, osg::ImageStream, osgParticle::Placer, osgText::Text, osg::ShaderAttribute, osgDB::Archive, osgParticle::PrecipitationEffect, osgParticle::Shooter, osgText::TextBase, osgViewer::PixelBufferX11, osgGA::DriveManipulator, osgParticle::CenteredPlacer, osgParticle::VariableRateCounter, osg::AudioSink, osgParticle::Counter, osgGA::SphericalManipulator, and osgGA::CameraViewSwitchManipulator.

virtual Object* osg::Object::clone ( const CopyOp ) const [pure virtual]
virtual Object* osg::Object::cloneType ( ) const [pure virtual]
virtual void osg::Object::computeDataVariance ( ) [inline, virtual]

Compute the DataVariance based on an assessment of callback etc.

Reimplemented in osg::Drawable, and osg::StateSet.

DataVariance osg::Object::getDataVariance ( ) const [inline]

Get the data variance of this object.

Referenced by osgUtil::RenderLeaf::RenderLeaf(), and osgUtil::StateGraph::StateGraph().

const std::string& osg::Object::getName ( ) const [inline]
osg::UserDataContainer* osg::Object::getOrCreateUserDataContainer ( )

Convinience method that returns the UserDataContainer, and if one doesn't already exist creates and assigns a DefaultUserDataContainer to the Object and then return this new UserDataContainer.

virtual Referenced* osg::Object::getUserData ( ) [virtual]
virtual const Referenced* osg::Object::getUserData ( ) const [virtual]

Get const user data.

Reimplemented in osg::DefaultUserDataContainer, and osg::UserDataContainer.

osg::UserDataContainer* osg::Object::getUserDataContainer ( ) [inline]

get the UserDataContainer attached to this object.

const osg::UserDataContainer* osg::Object::getUserDataContainer ( ) const [inline]

get the const UserDataContainer attached to this object.

template<typename T >
BoolValueObject UCharValueObject UShortValueObject UIntValueObject DoubleValueObject Vec3fValueObject Vec2dValueObject Vec4dValueObject PlaneValueObject MatrixdValueObject bool osg::Object::getUserValue ( const std::string &  name,
T &  value 
) const

Convinience method that casts the named UserObject to osg::TemplateValueObject<T> and gets the value.

provide implementation of osg::Object::getUserValue(..) template

To use this template method you need to include the osg/ValueObject header.

References osg::UserDataContainer::getUserObject().

virtual bool osg::Object::isSameKindAs ( const Object ) const [inline, virtual]
virtual const char* osg::Object::libraryName ( ) const [pure virtual]

return the name of the object's library.

Must be defined by derived classes. The OpenSceneGraph convention is that the namespace of a library is the same as the library name.

Implemented in osg::BufferData, osg::DrawElementsUInt, osg::RefMatrixf, osg::BufferObject, osg::GraphicsContext, osg::DrawElementsUShort, osg::DrawElementsUByte, osg::RefMatrixd, osg::DrawArrayLengths, osg::Texture, osg::DrawArrays, osgViewer::GraphicsWindowEmbedded, osg::StateAttribute, osgShadow::ShadowVolumeGeometry, osg::PrimitiveSet, osg::ShapeDrawable, osg::TemplateValueObject, osg::Drawable, osg::Image, osg::Array, osg::Node, osgText::Font, osgViewer::GraphicsWindowX11, osgFX::Effect, osgUtil::RenderBin, osg::Shape, osgAnimation::MorphGeometry, osg::Light, osg::AudioStream, osg::ClipPlane, osg::StateSet, osgSim::ImpostorSprite, osgParticle::ParticleProcessor, osgViewer::GraphicsWindow, osgShadow::OccluderGeometry, osg::Hint, osgParticle::Program, osg::DrawPixels, osgParticle::Emitter, osgParticle::Operator, osgParticle::ParticleEffect, osg::Geometry, osg::ImageSequence, osg::AutoTransform, osgParticle::Interpolator, osgText::Text, osgUtil::PositionalStateContainer, osgSim::Sector, osgText::TextBase, osgViewer::GraphicsWindowWin32, osgViewer::PixelBufferWin32, osg::ImageStream, osg::UserDataContainer, osgParticle::Placer, osg::ShaderAttribute, osgParticle::PrecipitationEffect, osgParticle::Shooter, osgViewer::PixelBufferX11, osgDB::Archive, osgParticle::CenteredPlacer, osgParticle::VariableRateCounter, osg::AudioSink, and osgParticle::Counter.

virtual void osg::Object::releaseGLObjects ( osg::State = 0) const [inline, virtual]
virtual void osg::Object::resizeGLObjectBuffers ( unsigned int  ) [inline, virtual]
void osg::Object::setDataVariance ( DataVariance  dv) [inline]

Set the data variance of this object.

Can be set to either STATIC for values that do not change over the lifetime of the object, or DYNAMIC for values that vary over the lifetime of the object. The DataVariance value can be used by routines such as optimization codes that wish to share static data. UNSPECIFIED is used to specify that the DataVariance hasn't been set yet.

virtual void osg::Object::setName ( const std::string &  name) [inline, virtual]
void osg::Object::setName ( const char *  name) [inline]

Set the name of object using a C style string.

virtual void osg::Object::setThreadSafeRefUnref ( bool  threadSafe) [virtual]
virtual void osg::Object::setUserData ( Referenced obj) [virtual]

Set user data, data must be subclassed from Referenced to allow automatic memory handling.

If your own data isn't directly subclassed from Referenced then create an adapter object which points to your own object and handles the memory addressing.

Reimplemented in osg::DefaultUserDataContainer, and osg::UserDataContainer.

void osg::Object::setUserDataContainer ( osg::UserDataContainer udc)

set the UserDataContainer object.

template<typename T >
void osg::Object::setUserValue ( const std::string &  name,
const T &  value 
)

Convinience method that creates the osg::TemplateValueObject<T> to store the specified value and adds it as a named UserObject.

provide implementation of osg::Object::setUserValue(..) template.

To use this template method you need to include the osg/ValueObject header.

References osg::UserDataContainer::getUserObjectIndex(), osg::UserDataContainer::setUserObject(), and osg::UserDataContainer::addUserObject().


Member Data Documentation

std::string osg::Object::_name [protected]

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

osg logo
Generated at Mon Oct 3 2011 12:39:43 for the OpenSceneGraph by doxygen 1.7.5.