OSG  3.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions | Protected Attributes | List of all members
osg::observer_ptr< T > Singleton Reference

#include <observer_ptr.h>

Collaboration diagram for osg::observer_ptr< T >:
Collaboration graph
[legend]

Public Types

typedef T element_type
 

Public Member Functions

 observer_ptr ()
 
 observer_ptr (const ref_ptr< T > &rp)
 
 observer_ptr (T *rp)
 
 observer_ptr (const observer_ptr &wp)
 
 ~observer_ptr ()
 
observer_ptroperator= (const observer_ptr &wp)
 
observer_ptroperator= (const ref_ptr< T > &rp)
 
observer_ptroperator= (T *rp)
 
bool lock (ref_ptr< T > &rptr) const
 
bool operator== (const observer_ptr &wp) const
 
bool operator!= (const observer_ptr &wp) const
 
bool operator< (const observer_ptr &wp) const
 
bool operator> (const observer_ptr &wp) 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
 
T * get () const
 
bool operator! () const
 
bool valid () const
 

Protected Attributes

osg::ref_ptr< ObserverSet_reference
 
T * _ptr
 

Detailed Description

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

Smart pointer for observed objects, that automatically set pointers to them to null when they are deleted. To use the observer_ptr<> robustly in multi-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 performance advantage, the conditions are: 1) The data structure is only accessed/deleted in single threaded/serial way. 2) The data strucutre is guaranteed 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 the ref_ptr<> observer_ptr<>.lock() combination.

Definition at line 38 of file observer_ptr.h.

Member Typedef Documentation

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

Definition at line 41 of file observer_ptr.h.

Constructor & Destructor Documentation

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

Definition at line 42 of file observer_ptr.h.

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

Create a observer_ptr from a ref_ptr.

Definition at line 47 of file observer_ptr.h.

template<class T>
osg::observer_ptr< T >::observer_ptr ( T *  rp)
inline

Create a observer_ptr from a raw pointer. For compatibility; the result might not be lockable.

Definition at line 57 of file observer_ptr.h.

template<class T>
osg::observer_ptr< T >::observer_ptr ( const observer_ptr< T > &  wp)
inline

Definition at line 63 of file observer_ptr.h.

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

Definition at line 69 of file observer_ptr.h.

Member Function Documentation

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

Definition at line 146 of file observer_ptr.h.

template<class T>
bool osg::observer_ptr< T >::lock ( ref_ptr< T > &  rptr) const
inline

Assign the observer_ptr to a ref_ptr. The ref_ptr will be valid if the referenced object hasn't been deleted and has a ref count > 0.

Definition at line 100 of file observer_ptr.h.

Here is the caller graph for this function:

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

Definition at line 148 of file observer_ptr.h.

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

Definition at line 124 of file observer_ptr.h.

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

Definition at line 131 of file observer_ptr.h.

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

Definition at line 142 of file observer_ptr.h.

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

Definition at line 143 of file observer_ptr.h.

template<class T>
bool osg::observer_ptr< T >::operator< ( const observer_ptr< T > &  wp) const
inline

Definition at line 125 of file observer_ptr.h.

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

Definition at line 132 of file observer_ptr.h.

template<class T>
observer_ptr& osg::observer_ptr< T >::operator= ( const observer_ptr< T > &  wp)
inline

Definition at line 73 of file observer_ptr.h.

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

Definition at line 82 of file observer_ptr.h.

template<class T>
observer_ptr& osg::observer_ptr< T >::operator= ( T *  rp)
inline

Definition at line 89 of file observer_ptr.h.

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

Comparison operators. These continue to work even after the observed object has been deleted.

Definition at line 123 of file observer_ptr.h.

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

Definition at line 130 of file observer_ptr.h.

template<class T>
bool osg::observer_ptr< T >::operator> ( const observer_ptr< T > &  wp) const
inline

Definition at line 126 of file observer_ptr.h.

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

Definition at line 133 of file observer_ptr.h.

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

Definition at line 149 of file observer_ptr.h.

Member Data Documentation

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

Definition at line 154 of file observer_ptr.h.

template<class T>
osg::ref_ptr<ObserverSet> osg::observer_ptr< T >::_reference
protected

Definition at line 153 of file observer_ptr.h.


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