WeakRef< REFERENCE > Class Template Reference Data Structures

#include <weakref.h>

详细描述

template<typename REFERENCE>
class maxon::WeakRef< REFERENCE >

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.

公共成员函数

  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

Protected Member Functions

  WeakRef ( WeakRefTargetBase *data)
const void *  GetCurrent () const

私有成员函数

const void *  () 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)

构造函数 & 析构函数文档编制

◆  WeakRef() [1/5]

WeakRef ( )

◆  WeakRef() [2/5]

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.

◆  WeakRef() [3/5]

WeakRef ( const WeakRef < REFERENCE > &  src )

Copy constructs a weak reference.

参数
[in] src Source weak reference.

◆  ~WeakRef()

~ WeakRef ( )

Removes a weak reference.

◆  WeakRef() [4/5]

WeakRef ( WeakRef < REFERENCE > &&  src )

Moves a weak reference.

参数
[in] src Source weak reference, will be nulled.

◆  WeakRef() [5/5]

WeakRef ( WeakRefTargetBase data )
explicit protected

成员函数文档编制

◆  operator=() [1/3]

WeakRef & operator= ( const REFERENCE &  strongReference )

Adds a strong reference.

参数
[in] strongReference BaseRef with strong reference to an object.
返回
*this.

◆  operator=() [2/3]

WeakRef & operator= ( const WeakRef < REFERENCE > &  src )

Copies a weak reference.

参数
[in] src Source weak reference.
返回
*this.

◆  MAXON_OPERATOR_MOVE_ASSIGNMENT()

MAXON_OPERATOR_MOVE_ASSIGNMENT ( WeakRef < REFERENCE >  )

Moves a weak reference.

参数
[in] src Source weak reference.
返回
*this.

◆  operator=() [3/3]

WeakRef & operator= ( std::nullptr_t  t )

◆  operator REFERENCE()

operator REFERENCE ( ) const

Returns a strong reference. If the weak referenced object was already released a null reference will be returned.

返回
Strong reference to the target or null.

◆  GetReference()

REFERENCE GetReference ( ) const

Returns a strong reference. If the weak referenced object was already released a null reference will be returned.

返回
Strong reference to the target or null.

◆  operator==()

Bool operator== ( const WeakRef < REFERENCE > &  other ) const

Compares WeakRefs for equality.

参数
[in] other The other comparand.
返回
True if equal.

◆  operator!=()

Bool operator!= ( const WeakRef < REFERENCE > &  other ) const

Compares WeakRefs for inequality.

参数
[in] other The other comparand.
返回
True if not equal.

◆  operator Bool()

operator Bool ( ) const
explicit

Checks if the weak reference points to a strong reference (non-blocking check).

返回
True if there currently is a strong reference, otherwise false.

◆  IsEmpty()

Bool IsEmpty ( ) const

Checks if the weak reference is empty.

返回
True if the weak reference is empty.

◆  IsPopulated()

Bool IsPopulated ( ) const

Checks if this weak reference contains anything.

返回
True if the weak reference points to an object.

◆  GetHashCode()

HashInt GetHashCode ( ) const

Compute hash code based on the targeted object. WeakRefs pointing to the same target will have the same hash code. When the target object is removed the hash code will change to 0, this means two WeakRefs which initially pointed to different objects will have the same hash code after the target objects were destructed.

返回
True if the weak reference points to an object.

◆  GetCurrent()

const void* GetCurrent ( ) const
protected

◆  Lock()

const void* Lock ( ) const
private

Locks the WeakRefTarget.

◆  Unlock()

void Unlock ( const void *  target ) const
private

Unlocks the WeakRefTarget.

◆  GetBaseRef() [1/2]

static REFERENCETYPE::BaseRefType& GetBaseRef ( const REFERENCETYPE &  strongReference )
static private

◆  GetBaseRef() [2/2]

static BaseRef <T, HANDLER>& GetBaseRef ( const BaseRef < T, HANDLER > &  strongReference )
static private