Rebel Fork Framework
Urho3D::WeakPtr< InterfaceType, RefCountedType > Class Template Reference

Weak pointer template class with intrusive reference counting. Does not keep the object pointed to alive. More...

#include <Urho3D/Container/Ptr.h>

Public Types

using ThisType = WeakPtr< InterfaceType, RefCountedType >
 
using SharedPtrType = SharedPtr< InterfaceType, RefCountedType >
 

Public Member Functions

 WeakPtr (std::nullptr_t) noexcept
 
 WeakPtr (const ThisType &rhs) noexcept
 Copy-construct from another weak pointer.
 
 WeakPtr (ThisType &&rhs) noexcept
 Move-construct from another weak pointer.
 
template<class U1 , class U2 >
 WeakPtr (const WeakPtr< U1, U2 > &rhs) noexcept
 Copy-construct from another weak pointer allowing implicit upcasting.
 
template<class U1 , class U2 >
 WeakPtr (const SharedPtr< U1, U2 > &rhs) noexcept
 Construct from a shared pointer.
 
 WeakPtr (InterfaceType *ptr) noexcept
 Construct from a raw pointer.
 
 ~WeakPtr () noexcept
 Destruct. Release the weak reference to the object.
 
template<class U1 , class U2 >
ThisTypeoperator= (const SharedPtr< U1, U2 > &rhs) noexcept
 Assign from a shared pointer.
 
ThisTypeoperator= (const ThisType &rhs) noexcept
 Assign from a weak pointer.
 
ThisTypeoperator= (ThisType &&rhs) noexcept
 Move-assign from another weak pointer.
 
template<class U1 , class U2 >
ThisTypeoperator= (const WeakPtr< U1, U2 > &rhs) noexcept
 Assign from another weak pointer allowing implicit upcasting.
 
ThisTypeoperator= (InterfaceType *ptr) noexcept
 Assign from a raw pointer.
 
SharedPtrType Lock () const noexcept
 Convert to a shared pointer. If expired, return a null shared pointer.
 
InterfaceType * Get () const noexcept
 Return raw pointer. If expired, return null.
 
InterfaceType * operator-> () const noexcept
 Point to the object.
 
InterfaceType & operator* () const noexcept
 Dereference the object.
 
template<class U1 , class U2 >
bool operator== (const WeakPtr< U1, U2 > &rhs) const noexcept
 Test for equality with another weak pointer.
 
template<class U1 , class U2 >
bool operator!= (const WeakPtr< U1, U2 > &rhs) const noexcept
 Test for inequality with another weak pointer.
 
template<class U1 , class U2 >
bool operator< (const WeakPtr< U1, U2 > &rhs) const noexcept
 Test for less than with another weak pointer.
 
 operator InterfaceType * () const noexcept
 Convert to a raw pointer, null if the object is expired.
 
void Swap (ThisType &rhs) noexcept
 Swap with another WeakPtr.
 
void Reset (InterfaceType *ptr=nullptr) noexcept
 Reset with another pointer.
 
template<class U1 , class U2 >
void StaticCast (const WeakPtr< U1, U2 > &rhs) noexcept
 Perform a static cast from a weak pointer of another type.
 
template<class U1 , class U2 >
void DynamicCast (const WeakPtr< U1, U2 > &rhs) noexcept
 Perform a dynamic cast from a weak pointer of another type.
 
int Refs () const noexcept
 Return the object's reference count, or 0 if null pointer or if object has expired.
 
int WeakRefs () const noexcept
 Return the object's weak reference count.
 
bool Expired () const noexcept
 Return whether the object has expired. If null pointer, always return true.
 
RefCountRefCountPtr () const noexcept
 Return pointer to the RefCount structure.
 
size_t ToHash () const noexcept
 Return hash value for HashSet & HashMap. Use the same hash function as for raw pointers!
 

Private Member Functions

void AddRef () noexcept
 Add a weak reference to the object pointed to.
 
void ReleaseRef () noexcept
 Release the weak reference. Delete the Refcount structure if necessary.
 

Private Attributes

InterfaceType * ptr_ {}
 Pointer to the object.
 
RefCountrefCount_ {}
 Pointer to the RefCount structure.
 

Detailed Description

template<class InterfaceType, class RefCountedType = InterfaceType>
class Urho3D::WeakPtr< InterfaceType, RefCountedType >

Weak pointer template class with intrusive reference counting. Does not keep the object pointed to alive.


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