Sound Bakery  v0.1.0
Open-source audio middleware for games
|
#include <database_ptr.h>
Public Types | |
using | TThisType = database_ptr< TObject > |
using | TIdentifierType = sbk_id |
using | TObjectPtr = TObject * |
using | TObjectRef = TObject & |
using | TObjectWeak = std::weak_ptr< database_object > |
using | TObjectShared = std::shared_ptr< TObject > |
using | TPtrType = std::weak_ptr< database_object > |
Public Member Functions | |
database_ptr () | |
Creates an empty and null LazyPtr. | |
database_ptr (const TThisType &other)=default | |
database_ptr (TThisType &&other)=default | |
database_ptr (sbk_id id) | |
Creates a LazyPtr that can lookup its object pointer after construction. | |
database_ptr (const TObjectShared &object) | |
Create a valid LazyPtr. | |
database_ptr (const TObjectPtr &object) | |
Create a valid LazyPtr. | |
database_ptr (std::nullptr_t) | |
Create an empty and null LazyPtr. | |
sbk_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. | |
TThisType & | operator= (TObjectShared object) |
TThisType & | operator= (TObjectPtr object) |
Assign this LazyPtr to a new object, potentially destroying the current object if we're acting as a UniquePtr. | |
TThisType & | operator= (const TThisType &other) |
TThisType & | operator= (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 | |
sbk_id | m_objectID |
TPtrType | m_objectPtr = TPtrType() |
bool | m_null |
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
|
inline |
Creates a LazyPtr that can lookup its object pointer after construction.
id | ID of the object to reference |
|
inline |
Create a valid LazyPtr.
object |
|
inline |
Create a valid LazyPtr.
object |
|
inline |
Create an empty and null LazyPtr.
nullptr_t |
|
inline |
Returns true if we hold a valid ID and can search for an object at runtime.
|
inlinenoexcept |
Get ID of the referenced object.
|
inline |
Find the live object referenced by the ID and store it.
|
inline |
Returns true if the object pointer is not set.
|
inline |
Access the raw object.
|
inline |
Assign this LazyPtr to a new object, potentially destroying the current object if we're acting as a UniquePtr.
object | to assign to |
|
inline |
Returns true if we hold an ID but haven't found the live object to point to yet.
|
inlinenoexcept |
Get raw pointer of the referenced object.
|
inline |
Returns true if we previously referenced an object that has been destroyed.
|
inline |
Returns true if we hold an ID and a valid pointer to the object.