osg::observer_ptr< T > Class Template Reference

Inheritance diagram for osg::observer_ptr< T >:

osg::Observer

List of all members.

Public Types

typedef T element_type

Public Member Functions

 observer_ptr ()
 observer_ptr (T *t)
 observer_ptr (const observer_ptr &rp)
 ~observer_ptr ()
observer_ptroperator= (const observer_ptr &rp)
observer_ptroperator= (T *ptr)
ref_ptr< T > lock () const
T * get () const
bool operator== (const observer_ptr &rp) const
bool operator!= (const observer_ptr &rp) const
bool operator< (const observer_ptr &rp) const
bool operator> (const observer_ptr &rp) const
bool operator== (const T *ptr) const
bool operator!= (const T *ptr) const
bool operator< (const T *ptr) const
bool operator> (const T *ptr) const
T & operator* () const
T * operator-> () const
bool operator! () const
bool valid () const

Protected Member Functions

virtual void objectDeleted (void *)

Protected Attributes

T * _ptr


Detailed Description

template<class T>
class osg::observer_ptr< T >

Smart pointer for observed objects, that automatically set pointers to them to null when they deleted. To use the observer_ptr<> robustly in mulit-threaded applications it is recommend to access the pointer via the lock() method that passes back a ref_ptr<> that safely takes a reference to the object to prevent deletion during usage of the object. In certain conditions it may be safe to use the pointer directly without using lock(), which will confer a perfomance advantage, the conditions are: 1) The data structure is only accessed/deleted in single threaded/serial way. 2) The data strucutre is guarenteed by high level management of data strucutures and threads which avoid possible situations where the observer_ptr<>'s object may be deleted by one thread whilst being accessed by another. If you are in any doubt about whether it is safe to access the object safe then use ref_ptr<> observer_ptr<>.lock() combination.

Member Typedef Documentation

template<class T>
typedef T osg::observer_ptr< T >::element_type


Constructor & Destructor Documentation

template<class T>
osg::observer_ptr< T >::observer_ptr (  )  [inline]

template<class T>
osg::observer_ptr< T >::observer_ptr ( T *  t  )  [inline]

template<class T>
osg::observer_ptr< T >::observer_ptr ( const observer_ptr< T > &  rp  )  [inline]

template<class T>
osg::observer_ptr< T >::~observer_ptr (  )  [inline]


Member Function Documentation

template<class T>
observer_ptr& osg::observer_ptr< T >::operator= ( const observer_ptr< T > &  rp  )  [inline]

template<class T>
observer_ptr& osg::observer_ptr< T >::operator= ( T *  ptr  )  [inline]

template<class T>
ref_ptr<T> osg::observer_ptr< T >::lock (  )  const [inline]

template<class T>
T* osg::observer_ptr< T >::get (  )  const [inline]

template<class T>
bool osg::observer_ptr< T >::operator== ( const observer_ptr< T > &  rp  )  const [inline]

template<class T>
bool osg::observer_ptr< T >::operator!= ( const observer_ptr< T > &  rp  )  const [inline]

template<class T>
bool osg::observer_ptr< T >::operator< ( const observer_ptr< T > &  rp  )  const [inline]

template<class T>
bool osg::observer_ptr< T >::operator> ( const observer_ptr< T > &  rp  )  const [inline]

template<class T>
bool osg::observer_ptr< T >::operator== ( const T *  ptr  )  const [inline]

template<class T>
bool osg::observer_ptr< T >::operator!= ( const T *  ptr  )  const [inline]

template<class T>
bool osg::observer_ptr< T >::operator< ( const T *  ptr  )  const [inline]

template<class T>
bool osg::observer_ptr< T >::operator> ( const T *  ptr  )  const [inline]

template<class T>
T& osg::observer_ptr< T >::operator* (  )  const [inline]

template<class T>
T* osg::observer_ptr< T >::operator-> (  )  const [inline]

template<class T>
bool osg::observer_ptr< T >::operator! (  )  const [inline]

template<class T>
bool osg::observer_ptr< T >::valid (  )  const [inline]

template<class T>
virtual void osg::observer_ptr< T >::objectDeleted ( void *   )  [inline, protected, virtual]

objectDeleted is called when the observed object is about to be deleted. The observer will be automatically removed from the observerd objects observer set so there is no need for the objectDeleted implementation to call removeObserver() on the observed object.

Reimplemented from osg::Observer.


Member Data Documentation

template<class T>
T* osg::observer_ptr< T >::_ptr [protected]


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

Generated on Sat Mar 20 12:33:58 2010 for openscenegraph by  doxygen 1.5.6