Kicking it Olde Sküül! Burgerlib on Github Follow Olde Sküül on Twitter Burgerbecky on LinkedIn Burgerbecky on LinkedIn
No Matches
Public Member Functions | Private Attributes | List of all members
Burger::WeakPointerAnchor Class Reference

Private sub class for use by WeakPointer. More...

Collaboration diagram for Burger::WeakPointerAnchor:
Collaboration graph

Public Member Functions

 WeakPointerAnchor () noexcept
 Sets the pointer to the proxy to nullptr.
 ~WeakPointerAnchor ()
 Sends a destruction message.
ProxyReferenceCounterGetProxyReferenceCounter (void) const noexcept
 Returns the owned ProxyReferenceCounter object.

Private Attributes

 Pointer to reference counter common object.

Detailed Description

Private sub class for use by WeakPointer.

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 by this sub class if one is requested. Once created, ProxyReferenceCounter::AddRef() is called on it to ensure it's instantiation until the parent object is deleted, in which the object will have ProxyReferenceCounter::Release() called.

If there are no WeakPointer objects pointing to the ProxyReferenceCounter object, it will also self destruct, otherwise, it will stay active with a message stating that the parent is gone until all WeakPointer objects have gotten the message and released their references.

This class is not meant to be used as a stand alone class, it's mean to be instantiated by the macro BURGER_ALLOW_WEAK_POINTERS()

See also
WeakPointer, ReferenceCounter and BURGER_ALLOW_WEAK_POINTERS()

Constructor & Destructor Documentation

◆ WeakPointerAnchor()

Burger::WeakPointerAnchor::WeakPointerAnchor ( )

Sets the pointer to the proxy to nullptr.

◆ ~WeakPointerAnchor()

Burger::WeakPointerAnchor::~WeakPointerAnchor ( )

Sends a destruction message.

If a ProxyReferenceCounter was created, send a message to it that the parent has self destructed and then call ProxyReferenceCounter::Release() to give up ownership of the ProxyReferenceCounter object.

Member Function Documentation

◆ GetProxyReferenceCounter()

Burger::ProxyReferenceCounter * Burger::WeakPointerAnchor::GetProxyReferenceCounter ( void ) const

Returns the owned ProxyReferenceCounter object.

If a ProxyReferenceCounter object exists, return the pointer, otherwise, create the object and return the pointer while taking ownership of it.

There will be only one shared ProxyReferenceCounter object created for each instantiation of this sub class.

Pointer to a valid ProxyReferenceCounter object or nullptr on failure
See also

Member Data Documentation

◆ m_pReferenceCounter

ProxyReferenceCounter* Burger::WeakPointerAnchor::m_pReferenceCounter

Pointer to reference counter common object.