Sound Bakery  v0.1.0
Open-source audio middleware for games
Loading...
Searching...
No Matches
SB::Core::DatabasePtr< TObject > Class Template Reference

#include <database_ptr.h>

Inheritance diagram for SB::Core::DatabasePtr< TObject >:

Public Types

using TThisType = DatabasePtr< TObject >
 
using TIdentifierType = SB_ID
 
using TObjectPtr = TObject *
 
using TObjectRef = TObject &
 
using TObjectWeak = std::weak_ptr< DatabaseObject >
 
using TObjectShared = std::shared_ptr< TObject >
 
using TPtrType = std::weak_ptr< DatabaseObject >
 

Public Member Functions

 DatabasePtr ()
 Creates an empty and null LazyPtr.
 
 DatabasePtr (const TThisType &other)=default
 
 DatabasePtr (TThisType &&other)=default
 
 DatabasePtr (SB_ID id)
 Creates a LazyPtr that can lookup its object pointer after construction.
 
 DatabasePtr (const TObjectPtr &object)
 Create a valid LazyPtr.
 
 DatabasePtr (std::nullptr_t)
 Create an empty and null LazyPtr.
 
SB_ID id () const noexcept
 Get ID of the referenced object.
 
TObjectShared shared () const noexcept
 
TObjectWeak weak () const noexcept
 
TObjectPtr raw () const noexcept
 Get raw pointer of the referenced object.
 
TObjectPtr lookupRaw () const noexcept
 
bool hasId () const
 Returns true if we hold a valid ID and can search for an object at runtime.
 
bool null () const
 Returns true if the object pointer is not set.
 
bool pending () const
 Returns true if we hold an ID but haven't found the live object to point to yet.
 
bool stale () const
 Returns true if we previously referenced an object that has been destroyed.
 
bool valid () const
 Returns true if we hold an ID and a valid pointer to the object.
 
bool lookup () const
 Find the live object referenced by the ID and store it.
 
void reset (TObjectPtr object=nullptr)
 Clear all references.
 
TThisTypeoperator= (TObjectPtr object)
 Assign this LazyPtr to a new object, potentially destroying the current object if we're acting as a UniquePtr.
 
TThisTypeoperator= (const TThisType &other)
 
TThisTypeoperator= (const TThisType &&other)
 
 operator bool () const
 Returns true if this LazyPtr references a valid object.
 
bool operator! () const
 Returns true if this LazyPtr is invalid.
 
TObjectPtr operator-> () const
 Access the raw object.
 

Protected Attributes

SB_ID m_objectID
 
TPtrType m_objectPtr = TPtrType()
 
bool m_null
 

Detailed Description

template<typename TObject>
class SB::Core::DatabasePtr< TObject >

Lazy Pointer Lazy pointers store an Indentifier to an object and use it to find the object later Lazy pointers can be serialized so references can persist through multiple shutdowns Passing only an indentifier will create a pointer that references no object but will try to find the object when accessing the object

Constructor & Destructor Documentation

◆ DatabasePtr() [1/3]

template<typename TObject >
SB::Core::DatabasePtr< TObject >::DatabasePtr ( SB_ID  id)
inline

Creates a LazyPtr that can lookup its object pointer after construction.

Parameters
idID of the object to reference

◆ DatabasePtr() [2/3]

template<typename TObject >
SB::Core::DatabasePtr< TObject >::DatabasePtr ( const TObjectPtr &  object)
inline

Create a valid LazyPtr.

Parameters
object

◆ DatabasePtr() [3/3]

template<typename TObject >
SB::Core::DatabasePtr< TObject >::DatabasePtr ( std::nullptr_t  )
inline

Create an empty and null LazyPtr.

Parameters
nullptr_t

Member Function Documentation

◆ hasId()

template<typename TObject >
bool SB::Core::DatabasePtr< TObject >::hasId ( ) const
inline

Returns true if we hold a valid ID and can search for an object at runtime.

Returns

◆ id()

template<typename TObject >
SB_ID SB::Core::DatabasePtr< TObject >::id ( ) const
inlinenoexcept

Get ID of the referenced object.

Returns

◆ lookup()

template<typename TObject >
bool SB::Core::DatabasePtr< TObject >::lookup ( ) const
inline

Find the live object referenced by the ID and store it.

Returns
true if the object was found and we're a valid ptr

◆ null()

template<typename TObject >
bool SB::Core::DatabasePtr< TObject >::null ( ) const
inline

Returns true if the object pointer is not set.

Returns

◆ operator->()

template<typename TObject >
TObjectPtr SB::Core::DatabasePtr< TObject >::operator-> ( ) const
inline

Access the raw object.

Returns
raw object

◆ operator=()

template<typename TObject >
TThisType & SB::Core::DatabasePtr< TObject >::operator= ( TObjectPtr  object)
inline

Assign this LazyPtr to a new object, potentially destroying the current object if we're acting as a UniquePtr.

Parameters
objectto assign to
Returns
this

◆ pending()

template<typename TObject >
bool SB::Core::DatabasePtr< TObject >::pending ( ) const
inline

Returns true if we hold an ID but haven't found the live object to point to yet.

Returns

◆ raw()

template<typename TObject >
TObjectPtr SB::Core::DatabasePtr< TObject >::raw ( ) const
inlinenoexcept

Get raw pointer of the referenced object.

Returns

◆ stale()

template<typename TObject >
bool SB::Core::DatabasePtr< TObject >::stale ( ) const
inline

Returns true if we previously referenced an object that has been destroyed.

Returns

◆ valid()

template<typename TObject >
bool SB::Core::DatabasePtr< TObject >::valid ( ) const
inline

Returns true if we hold an ID and a valid pointer to the object.

Returns

The documentation for this class was generated from the following files: