#include <weakref.h>
A WeakRef points to a target object as long as there are strong references which also point to it. When an object has no more strong references it will be destructed and all weak references to it will return a null reference from then on.
Public Member Functions | |
WeakRef () | |
MAXON_IMPLICIT | WeakRef (const REFERENCE &strongReference) |
WeakRef (const WeakRef &src) | |
~WeakRef () | |
WeakRef (WeakRef &&src) | |
WeakRef & | operator= (const REFERENCE &strongReference) |
WeakRef & | operator= (const WeakRef &src) |
MAXON_OPERATOR_MOVE_ASSIGNMENT (WeakRef) | |
WeakRef & | operator= (std::nullptr_t t) |
operator REFERENCE () const | |
REFERENCE | GetReference () const |
Bool | operator== (const WeakRef &other) const |
Bool | operator!= (const WeakRef &other) const |
operator Bool () const | |
Bool | IsEmpty () const |
Bool | IsPopulated () const |
HashInt | GetHashCode () const |
UniqueHash | GetUniqueHashCode () const |
Public Member Functions inherited from WeakRefBase | |
WeakRefBase () | |
WeakRefBase (WeakRefTargetBase *targetData) | |
~WeakRefBase () | |
WeakRefBase (const WeakRefBase &src) | |
WeakRefBase (WeakRefBase &&src) | |
WeakRefBase & | operator= (const WeakRefBase &src) |
MAXON_OPERATOR_MOVE_ASSIGNMENT (WeakRefBase) | |
Protected Member Functions | |
WeakRef (WeakRefTargetBase *data) | |
const void * | GetCurrent () const |
Private Member Functions | |
const void * | Lock () const |
void | Unlock (const void *target) const |
Static Private Member Functions | |
template<typename REFERENCETYPE > | |
static REFERENCETYPE::BaseRefType & | GetBaseRef (const REFERENCETYPE &strongReference) |
template<typename T , typename HANDLER > | |
static BaseRef< T, HANDLER > & | GetBaseRef (const BaseRef< T, HANDLER > &strongReference) |
Additional Inherited Members | |
Public Attributes inherited from WeakRefBase | |
WeakRefTargetBase * | data |
WeakRef | ( | ) |
MAXON_IMPLICIT WeakRef | ( | const REFERENCE & | strongReference | ) |
Adds a weak reference. If memory allocation fails the weak reference will be nullptr.
[in] | strongReference | BaseRef with strong reference to an object. |
Copy constructs a weak reference.
[in] | src | Source weak reference. |
~WeakRef | ( | ) |
Removes a weak reference.
Moves a weak reference.
[in] | src | Source weak reference, will be nulled. |
|
explicitprotected |
WeakRef& operator= | ( | const REFERENCE & | strongReference | ) |
Adds a strong reference.
[in] | strongReference | BaseRef with strong reference to an object. |
Copies a weak reference.
[in] | src | Source weak reference. |
MAXON_OPERATOR_MOVE_ASSIGNMENT | ( | WeakRef< REFERENCE > | ) |
Moves a weak reference.
[in] | src | Source weak reference. |
WeakRef& operator= | ( | std::nullptr_t | t | ) |
operator REFERENCE | ( | ) | const |
Returns a strong reference. If the weak referenced object was already released a null reference will be returned.
REFERENCE GetReference | ( | ) | const |
Returns a strong reference. If the weak referenced object was already released a null reference will be returned.
Compares WeakRefs for equality.
[in] | other | The other comparand. |
Compares WeakRefs for inequality.
[in] | other | The other comparand. |
|
explicit |
Checks if the weak reference points to a strong reference (non-blocking check).
Bool IsEmpty | ( | ) | const |
Checks if the weak reference is empty.
Bool IsPopulated | ( | ) | const |
Checks if this weak reference contains anything.
HashInt GetHashCode | ( | ) | const |
Compute hash code based on the targeted object's pointer. WeakRefs pointing to the same target will have the same hash code. When the target object is removed the hash code will change to the hash code of nullptr, this means two WeakRefs which initially pointed to different objects will have the same hash code after the target objects were destructed.
UniqueHash GetUniqueHashCode | ( | ) | const |
Compute hash value based on the targeted object's pointer. WeakRefs pointing to the same target will have the same hash value. When the target object is removed the hash value will change to the hash value of nullptr, this means two WeakRefs which initially pointed to different objects will have the same hash value after the target objects were destructed.
|
protected |
|
private |
Locks the WeakRefTarget.
|
private |
Unlocks the WeakRefTarget.
|
staticprivate |