#include <TCWeakPtr.h>
Public Member Functions | |
WeakPtr () | |
null pointer construction | |
template<class M_PTR > | |
WeakPtr (const WeakPtr< M_PTR > &r) | |
Copy constructor. | |
template<class M_PTR > | |
WeakPtr (const SharedPtr< M_PTR > &r) | |
Construct a weak pointer out of an shared pointer. | |
SharedPtr< T > | Lock () const |
Get the shared pointer of this weak pointer. | |
long | GetUseCount () const |
Get how many shared pointer point to the same pointer. | |
bool | IsExpired () const |
True if the the pointer pointing to is already deleted. | |
void | Reset () |
Let the weak pointer point to a null pointer. | |
void | Swap (WeakPtr< T > &other) |
Swap two weak pointers. | |
template<class N_PTR > | |
bool | Equal (const WeakPtr< N_PTR > &src) const |
Check if a weak pointer is equal with another. | |
template<class M_PTR > | |
bool | Less (const WeakPtr< M_PTR > &src) const |
Check if a weak pointer is less then another. | |
Private Attributes | |
T * | m_ptr |
WeakPtrCount | m_count |
Friends | |
class | WeakPtr |
class | SharedPtr |
To access the object, a WeakPtr can be converted to a SharedPtr using the SharedPtr constructor or the member function Lock. When the last SharedPtr to the object goes away and the object is deleted, the attempt to obtain a SharedPtr from the WeakPtr instances that refer to the deleted object will fail: WeakPtr::Lock will return an empty SharedPtr.
The class template is parameterized on PTR, the type of the object pointed to.
Definition at line 68 of file TCWeakPtr.h.
TC::WeakPtr< T >::WeakPtr | ( | ) | [inline] |
TC::WeakPtr< T >::WeakPtr | ( | const WeakPtr< M_PTR > & | r | ) | [inline] |
TC::WeakPtr< T >::WeakPtr | ( | const SharedPtr< M_PTR > & | r | ) | [inline] |
SharedPtr<T> TC::WeakPtr< T >::Lock | ( | ) | const [inline] |
Get the shared pointer of this weak pointer.
Definition at line 83 of file TCWeakPtr.h.
References TC::WeakPtr< T >::IsExpired().
long TC::WeakPtr< T >::GetUseCount | ( | ) | const [inline] |
Get how many shared pointer point to the same pointer.
Definition at line 86 of file TCWeakPtr.h.
References TC::WeakPtrCount::GetUseCount(), and TC::WeakPtr< T >::m_count.
bool TC::WeakPtr< T >::IsExpired | ( | ) | const [inline] |
True if the the pointer pointing to is already deleted.
Definition at line 89 of file TCWeakPtr.h.
References TC::WeakPtrCount::GetUseCount(), and TC::WeakPtr< T >::m_count.
Referenced by TC::WeakPtr< T >::Lock().
void TC::WeakPtr< T >::Reset | ( | ) | [inline] |
Let the weak pointer point to a null pointer.
Definition at line 92 of file TCWeakPtr.h.
References TC::WeakPtr< T >::Swap().
void TC::WeakPtr< T >::Swap | ( | WeakPtr< T > & | other | ) | [inline] |
Swap two weak pointers.
Definition at line 95 of file TCWeakPtr.h.
References TC::WeakPtr< T >::m_count, TC::WeakPtr< T >::m_ptr, and TC::WeakPtrCount::Swap().
Referenced by TC::WeakPtr< T >::Reset().
bool TC::WeakPtr< T >::Equal | ( | const WeakPtr< N_PTR > & | src | ) | const [inline] |
Check if a weak pointer is equal with another.
Definition at line 99 of file TCWeakPtr.h.
References TC::WeakPtr< T >::m_ptr.
Referenced by TC::operator!=(), and TC::operator==().
bool TC::WeakPtr< T >::Less | ( | const WeakPtr< M_PTR > & | src | ) | const [inline] |
Check if a weak pointer is less then another.
Definition at line 103 of file TCWeakPtr.h.
References TC::WeakPtr< T >::m_count.
friend class WeakPtr [friend] |
Definition at line 109 of file TCWeakPtr.h.
friend class SharedPtr [friend] |
Definition at line 110 of file TCWeakPtr.h.
T* TC::WeakPtr< T >::m_ptr [private] |
Definition at line 106 of file TCWeakPtr.h.
Referenced by TC::WeakPtr< T >::Equal(), and TC::WeakPtr< T >::Swap().
WeakPtrCount TC::WeakPtr< T >::m_count [private] |
Definition at line 107 of file TCWeakPtr.h.
Referenced by TC::WeakPtr< T >::GetUseCount(), TC::WeakPtr< T >::IsExpired(), TC::WeakPtr< T >::Less(), and TC::WeakPtr< T >::Swap().