19#ifdef OSG_USE_REF_PTR_SAFE_DEREFERENCE
27template<
typename T>
class observer_ptr;
37 ref_ptr(T* ptr) : _ptr(ptr) {
if (_ptr) _ptr->ref(); }
41 ~ref_ptr() {
if (_ptr) _ptr->unref(); _ptr = 0; }
57 if (_ptr==ptr)
return *
this;
60 if (_ptr) _ptr->ref();
64 if (tmp_ptr) tmp_ptr->unref();
68#ifdef OSG_USE_REF_PTR_IMPLICIT_OUTPUT_CONVERSION
70 operator T*()
const {
return _ptr; }
89 typedef T*
ref_ptr::*unspecified_bool_type;
93 operator unspecified_bool_type()
const {
return valid()? &ref_ptr::_ptr : 0; }
98#ifdef OSG_USE_REF_PTR_SAFE_DEREFERENCE
101 throw std::runtime_error(std::string(
"could not dereference invalid osg pointer ") + std::string(
typeid(T).name()));
108#ifdef OSG_USE_REF_PTR_SAFE_DEREFERENCE
111 throw std::runtime_error(std::string(
"could not call invalid osg pointer ") + std::string(
typeid(T).name()));
117 T*
get()
const {
return _ptr; }
120 bool valid()
const {
return _ptr!=0; }
128 void swap(
ref_ptr& rp) { T* tmp=_ptr; _ptr=rp._ptr; rp._ptr=tmp; }
134 if (_ptr==rp._ptr)
return;
137 if (_ptr) _ptr->ref();
141 if (tmp_ptr) tmp_ptr->unref();
150template<
class T>
inline
153template<
class T>
inline
156template<
class T,
class Y>
inline
159template<
class T,
class Y>
inline
162template<
class T,
class Y>
inline
The core osg library provides the basic scene graph classes such as Nodes, State and Drawables,...
Definition AlphaFunc:19
ref_ptr< T > static_pointer_cast(const ref_ptr< Y > &rp)
Definition ref_ptr:157
T * get_pointer(const ref_ptr< T > &rp)
Definition ref_ptr:154
void swap(MixinVector< ValueT > &left, MixinVector< ValueT > &right)
Definition MixinVector:174
ref_ptr< T > const_pointer_cast(const ref_ptr< Y > &rp)
Definition ref_ptr:163
ref_ptr< T > dynamic_pointer_cast(const ref_ptr< Y > &rp)
Definition ref_ptr:160
Smart pointer for observed objects, that automatically set pointers to them to null when they are del...
Definition observer_ptr:39
bool lock(ref_ptr< T > &rptr) const
Assign the observer_ptr to a ref_ptr.
Definition observer_ptr:100
Smart pointer for handling referenced counted objects.
Definition ref_ptr:32
friend class ref_ptr
Definition ref_ptr:144
bool operator<(const ref_ptr &rp) const
Definition ref_ptr:81
T * get() const
Definition ref_ptr:117
bool operator!() const
Definition ref_ptr:119
void swap(ref_ptr &rp)
Definition ref_ptr:128
T * operator->() const
Definition ref_ptr:106
bool operator!=(const ref_ptr &rp) const
Definition ref_ptr:77
ref_ptr(const ref_ptr< Other > &rp)
Definition ref_ptr:39
ref_ptr(const ref_ptr &rp)
Definition ref_ptr:38
ref_ptr(T *ptr)
Definition ref_ptr:37
ref_ptr()
Definition ref_ptr:36
ref_ptr & operator=(const ref_ptr &rp)
Definition ref_ptr:43
T element_type
Definition ref_ptr:34
~ref_ptr()
Definition ref_ptr:41
T * release()
release the pointer from ownership by this ref_ptr<>, decrementing the objects refencedCount() via un...
Definition ref_ptr:126
bool operator==(const ref_ptr &rp) const
Definition ref_ptr:73
ref_ptr(observer_ptr< T > &optr)
Definition ref_ptr:40
T & operator*() const
Definition ref_ptr:96
bool valid() const
Definition ref_ptr:120
int unref_nodelete() const
Decrement the reference count by one, indicating that a pointer to this object is no longer referenci...