Template for tracking an object that could self destruct. More...
Public Member Functions | |
WeakPointer () noexcept | |
Initialize a weak pointer to nullptr. | |
WeakPointer (T *pData) noexcept | |
Initialize a weak pointer. | |
WeakPointer (const WeakPointer< T > &rData) noexcept | |
Copy a weak pointer. | |
WeakPointer (const SmartPointer< T > &rData) noexcept | |
Copy a weak pointer from a SmartPointer object. | |
~WeakPointer () | |
Release a reference to a weak pointer. | |
void | operator= (T *pData) noexcept |
Track a new object. | |
void | operator= (const SmartPointer< T > &rData) noexcept |
Track a new object. | |
T * | operator-> () const noexcept |
Get the current pointer. | |
T * | GetPtr () const noexcept |
Get the current pointer. | |
operator SmartPointer< T > () noexcept | |
Award shared ownership of an object. | |
uint_t | operator== (const T *pData) const noexcept |
Test for equality. | |
uint_t | operator!= (const T *pData) const noexcept |
Test for inequality. | |
uint_t | operator== (const T *pData) noexcept |
Test for equality. | |
uint_t | operator!= (const T *pData) noexcept |
Test for inequality. | |
uint_t | operator== (const SmartPointer< T > &rData) const noexcept |
Test for equality. | |
uint_t | operator!= (const SmartPointer< T > &rData) const noexcept |
Test for inequality. | |
uint_t | operator== (const SmartPointer< T > &rData) noexcept |
Test for equality. | |
uint_t | operator!= (const SmartPointer< T > &rData) noexcept |
Test for inequality. | |
uint_t | operator== (const WeakPointer< T > &rData) const noexcept |
Test for equality. | |
uint_t | operator!= (const WeakPointer< T > &rData) const noexcept |
Test for inequality. | |
Private Member Functions | |
T * | Dereference (void) const noexcept |
Return the pointer to an object. | |
Private Attributes | |
T * | m_pData |
Pointer to the object being tracked. | |
SmartPointer< ProxyReferenceCounter > | m_pProxy |
Pointer to the object the tracked object will notify if it's deleted. | |
Template for tracking an object that could self destruct.
For objects that can be destroyed by other systems or can self destruct, this pointer template class will handle monitoring the object and will detect if the object isn't present in the system anymore.
|
inlinenoexcept |
|
inlinenoexcept |
Initialize a weak pointer.
Obtain the pointer to the object's ProxyReferenceCounter and call ProxyReferenceCounter::AddRef() on it. Store the pointer inside the class for tracking.
pData | Pointer to an instance of the class T or nullptr |
|
inlinenoexcept |
Copy a weak pointer.
Obtain the pointer to the object's ProxyReferenceCounter and call ProxyReferenceCounter::AddRef() on it. Store the pointer inside the class for tracking.
rData | Reference to an instance of another WeakPointer |
|
inlinenoexcept |
Copy a weak pointer from a SmartPointer object.
Obtain the pointer to the object's ProxyReferenceCounter and call ProxyReferenceCounter::AddRef() on it. Store the pointer inside the class for tracking.
rData | Reference to an instance of a SmartPointer |
|
inline |
Release a reference to a weak pointer.
If the ProxyReferenceCounter pointer contained is not nullptr, call ProxyReferenceCounter::Release() on it. The internal pointer is then set to nullptr to ensure there are no dangling pointers
|
inlineprivatenoexcept |
Return the pointer to an object.
Test if the object exists, and if so, or if no object is being tracked, return nullptr
|
inlinenoexcept |
Get the current pointer.
Return an untracked copy of the pointer. The pointer can be nullptr if the object being track was destroyed.
|
inlinenoexcept |
Award shared ownership of an object.
Obtain the pointer to the object or nullptr if the object was destroyed and create a SmartPointer with a reference to the object. If the object exists, the SmartPointer will call AddRef() on it or the SmartPointer will contain a nullptr
|
inlinenoexcept |
Test for inequality.
Compare the pointers for inequality and if not equal, return TRUE
rData | Reference to an instance of another SmartPointer |
|
inlinenoexcept |
Test for inequality.
Compare the pointers for inequality and if not equal, return TRUE
rData | Reference to an instance of another SmartPointer |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
Test for inequality.
Compare the pointers for inequality and if not equal, return TRUE
rData | Reference to an instance of another WeakPointer |
|
inlinenoexcept |
Get the current pointer.
Return an untracked copy of the pointer. The pointer can be nullptr if the object being track was destroyed.
|
inlinenoexcept |
Track a new object.
Obtain the pointer to the object's ProxyReferenceCounter and call ProxyReferenceCounter::AddRef() on it. Store the pointer inside the class for tracking. If there was an object previously being tracked, call ProxyReferenceCounter::Release() on it.
rData | Reference to an instance of another SmartPointer |
|
inlinenoexcept |
Track a new object.
Obtain the pointer to the object's ProxyReferenceCounter and call ProxyReferenceCounter::AddRef() on it. Store the pointer inside the class for tracking. If there was an object previously being tracked, call ProxyReferenceCounter::Release() on it.
pData | Pointer to an instance of the class T or nullptr |
|
inlinenoexcept |
Test for equality.
Compare the pointers for equality and if equal, return TRUE
rData | Reference to an instance of another SmartPointer |
|
inlinenoexcept |
Test for equality.
Compare the pointers for equality and if equal, return TRUE
rData | Reference to an instance of another SmartPointer |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
Test for equality.
Compare the pointers for equality and if equal, return TRUE
rData | Reference to an instance of another WeakPointer |
|
mutableprivate |
Pointer to the object being tracked.
|
mutableprivate |
Pointer to the object the tracked object will notify if it's deleted.