Urho3D::SharedPtr< T > Class Template Reference

Shared pointer template class with intrusive reference counting. More...

#include <Urho3D/Container/Ptr.h>

Collaboration diagram for Urho3D::SharedPtr< T >:
[legend]

Public Member Functions

 SharedPtr ()
 Construct a null shared pointer.
 
 SharedPtr (const SharedPtr< T > &rhs)
 Copy-construct from another shared pointer.
 
template<class U >
 SharedPtr (const SharedPtr< U > &rhs)
 Copy-construct from another shared pointer allowing implicit upcasting.
 
 SharedPtr (T *ptr)
 Construct from a raw pointer.
 
 ~SharedPtr ()
 Destruct. Release the object reference.
 
SharedPtr< T > & operator= (const SharedPtr< T > &rhs)
 Assign from another shared pointer.
 
template<class U >
SharedPtr< T > & operator= (const SharedPtr< U > &rhs)
 Assign from another shared pointer allowing implicit upcasting.
 
SharedPtr< T > & operator= (T *ptr)
 Assign from a raw pointer.
 
T * operator-> () const
 Point to the object.
 
T & operator* () const
 Dereference the object.
 
T & operator[] (const int index)
 Subscript the object if applicable.
 
template<class U >
bool operator< (const SharedPtr< U > &rhs) const
 Test for less than with another shared pointer.
 
template<class U >
bool operator== (const SharedPtr< U > &rhs) const
 Test for equality with another shared pointer.
 
template<class U >
bool operator!= (const SharedPtr< U > &rhs) const
 Test for inequality with another shared pointer.
 
 operator T * () const
 Convert to a raw pointer.
 
void Reset ()
 Reset to null and release the object reference.
 
T * Detach ()
 Detach without destroying the object even if the refcount goes zero. To be used for scripting language interoperation.
 
template<class U >
void StaticCast (const SharedPtr< U > &rhs)
 Perform a static cast from a shared pointer of another type.
 
template<class U >
void DynamicCast (const SharedPtr< U > &rhs)
 Perform a dynamic cast from a shared pointer of another type.
 
bool Null () const
 Check if the pointer is null.
 
bool NotNull () const
 Check if the pointer is not null.
 
T * Get () const
 Return the raw pointer.
 
int Refs () const
 Return the object's reference count, or 0 if the pointer is null.
 
int WeakRefs () const
 Return the object's weak reference count, or 0 if the pointer is null.
 
RefCountRefCountPtr () const
 Return pointer to the RefCount structure.
 
unsigned ToHash () const
 Return hash value for HashSet & HashMap.
 

Private Member Functions

void AddRef ()
 Add a reference to the object pointed to.
 
void ReleaseRef ()
 Release the object reference and delete it if necessary.
 

Private Attributes

T * ptr_
 Pointer to the object.
 

Friends

template<class U >
class SharedPtr
 

Detailed Description

template<class T>
class Urho3D::SharedPtr< T >

Shared pointer template class with intrusive reference counting.


The documentation for this class was generated from the following file:
  • Source/Urho3D/Container/Ptr.h