Kicking it Olde Sküül! Burgerlib on Github Follow Olde Sküül on Twitter Burgerbecky on LinkedIn Burgerbecky on LinkedIn
Loading...
Searching...
No Matches
Burger::ProxyReferenceCounter Class Reference

Class to track an object that can be deleted at any time. More...

Public Member Functions

uint_t IsParentAlive (void) const noexcept
 Return TRUE if the parent still exists.
 
void ParentIsDead (void) noexcept
 Send a signal that the parent was deleted.
 
void AddRef (void) noexcept
 Increase the reference count by 1.
 
void Release (void) noexcept
 Decrease the reference count by 1.
 

Static Public Member Functions

static ProxyReferenceCounterNew (void) noexcept
 Allocate a ProxyReferenceCounter using the global memory manager.
 

Private Member Functions

 ProxyReferenceCounter (const ProxyReferenceCounter &)=delete
 
ProxyReferenceCounteroperator= (const ProxyReferenceCounter &)=delete
 
 ProxyReferenceCounter (ProxyReferenceCounter &&)=delete
 
ProxyReferenceCounteroperator= (ProxyReferenceCounter &&)=delete
 
 ProxyReferenceCounter () noexcept
 Private default constructor.
 

Private Attributes

uint_t m_uRefCount
 Number of weak pointers that are using this object as an anchor.
 
uint_t m_bParentAlive
 TRUE if the parent object was deleted
 

Detailed Description

Class to track an object that can be deleted at any time.


When using a WeakPointer, it needs to be able to keep track of an object's status in case the object is deleted. To handle this, a reference counted object will create an independently allocated object in which all weak pointers will reference count so if the parent object is deleted, this object will remain to notify all the other systems that the object is no more. When all the WeakPointer have been notified of the parent's deletion, the proxy will be disposed of.

This class is not meant to be used as a stand alone class, it's meant to be created by ReferenceCounter objects when a WeakPointer object is requesting a connection.

See also
WeakPointer, ReferenceCounter and SmartPointer

Constructor & Destructor Documentation

◆ ProxyReferenceCounter() [1/3]

Burger::ProxyReferenceCounter::ProxyReferenceCounter ( const ProxyReferenceCounter & )
privatedelete

◆ ProxyReferenceCounter() [2/3]

Burger::ProxyReferenceCounter::ProxyReferenceCounter ( ProxyReferenceCounter && )
privatedelete

◆ ProxyReferenceCounter() [3/3]

Burger::ProxyReferenceCounter::ProxyReferenceCounter ( )
inlineprivatenoexcept

Private default constructor.


Sets the default values on construction. This can't be called by applications. Use Burger::ProxyReferenceCounter::New() instead.

See also
New()

Member Function Documentation

◆ AddRef()

void Burger::ProxyReferenceCounter::AddRef ( void )
inlinenoexcept

Increase the reference count by 1.


Take an ownership of this object by calling this function. Call Release() to give up ownership. Once the reference count reaches zero, the object will self destruct.

See also
Release()

◆ IsParentAlive()

uint_t Burger::ProxyReferenceCounter::IsParentAlive ( void ) const
inlinenoexcept

Return TRUE if the parent still exists.


When this class is created, this flag is set to TRUE. Once the parent is deleted, it will clear this flag so all WeakPointer class instances will know that the parent object is no more.

Returns
TRUE if the parent is still valid or FALSE if the parent object is gone

◆ New()

Burger::ProxyReferenceCounter *BURGER_API Burger::ProxyReferenceCounter::New ( void )
staticnoexcept

Allocate a ProxyReferenceCounter using the global memory manager.


Using the GlobalMemoryManager, allocate an instance of this class and return the pointer.

Returns
A pointer to a new instance of the ProxyReferenceCounter class or nullptr on failure

◆ operator=() [1/2]

ProxyReferenceCounter & Burger::ProxyReferenceCounter::operator= ( const ProxyReferenceCounter & )
privatedelete

◆ operator=() [2/2]

ProxyReferenceCounter & Burger::ProxyReferenceCounter::operator= ( ProxyReferenceCounter && )
privatedelete

◆ ParentIsDead()

void Burger::ProxyReferenceCounter::ParentIsDead ( void )
inlinenoexcept

Send a signal that the parent was deleted.


This function should only be called by the parent object when the parent object's destructor is called. The ProxyReferenceCounter will be signaled and all WeakPointer object that reference it will be able to know that the parent is gone.

◆ Release()

void Burger::ProxyReferenceCounter::Release ( void )
inlinenoexcept

Decrease the reference count by 1.


Give up ownership of this object by calling this function. Once the reference count reaches zero, the object will immediately self destruct. Call AddRef() to take ownership of this object.

See also
AddRef()

Member Data Documentation

◆ m_bParentAlive

uint_t Burger::ProxyReferenceCounter::m_bParentAlive
private

TRUE if the parent object was deleted

◆ m_uRefCount

uint_t Burger::ProxyReferenceCounter::m_uRefCount
private

Number of weak pointers that are using this object as an anchor.