OpenSceneGraph
3.5.1
|
Smart pointer for observed objects, that automatically set pointers to them to null when they are deleted. More...
Public Types | |
typedef T | element_type |
Public Member Functions | |
observer_ptr () | |
observer_ptr (const ref_ptr< T > &rp) | |
Create a observer_ptr from a ref_ptr. More... | |
observer_ptr (T *rp) | |
Create a observer_ptr from a raw pointer. More... | |
observer_ptr (const observer_ptr &wp) | |
~observer_ptr () | |
observer_ptr & | operator= (const observer_ptr &wp) |
observer_ptr & | operator= (const ref_ptr< T > &rp) |
observer_ptr & | operator= (T *rp) |
bool | lock (ref_ptr< T > &rptr) const |
Assign the observer_ptr to a ref_ptr. More... | |
bool | operator== (const observer_ptr &wp) const |
Comparison operators. More... | |
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 |
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.
typedef T osg::observer_ptr< T >::element_type |
|
inline |
|
inline |
Create a observer_ptr from a ref_ptr.
|
inline |
Create a observer_ptr from a raw pointer.
For compatibility; the result might not be lockable.
|
inline |
|
inline |
|
inline |
|
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.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Comparison operators.
These continue to work even after the observed object has been deleted.
|
inline |
|
inline |
|
inline |
|
inline |
|
protected |
|
protected |
Generated at Wed Nov 11 2015 22:14:38 for the OpenSceneGraph by doxygen 1.8.10. |