Sound Bakery  v0.1.0
Open-source audio middleware for games
Loading...
Searching...
No Matches
sbk::core::child_ptr< TObject > Class Template Referencefinal

Syntactic type to define a pointer that must be a child of the owning object. More...

#include <database_ptr.h>

Inheritance diagram for sbk::core::child_ptr< TObject >:
Collaboration diagram for sbk::core::child_ptr< TObject >:

Public Types

using TThisType = child_ptr< TObject >
 
- Public Types inherited from sbk::core::database_ptr< TObject >
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

 child_ptr ()=default
 Default constructor is exposed for RTTR but not for the user.
 
 child_ptr (const TThisType &other)
 
 child_ptr (TThisType &&other)=default
 
 child_ptr (const database_object &owner)
 Construct a new Child Ptr object with an owner.
 
 child_ptr (sbk_id id)
 Construct a new child_ptr that points to the ID.
 
TThisTypeoperator= (typename database_ptr< TObject >::TIdentifierType id)
 
TThisTypeoperator= (typename database_ptr< TObject >::TObjectPtr object)
 
TThisTypeoperator= (const TThisType &other)
 
void setID (typename database_ptr< TObject >::TIdentifierType id=0)
 
void reset (typename database_ptr< TObject >::TObjectPtr object=nullptr)
 
- Public Member Functions inherited from sbk::core::database_ptr< TObject >
 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.
 
TThisTypeoperator= (TObjectShared object)
 
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.
 

Additional Inherited Members

- Protected Attributes inherited from sbk::core::database_ptr< TObject >
sbk_id m_objectID
 
TPtrType m_objectPtr = TPtrType()
 
bool m_null
 

Detailed Description

template<typename TObject>
class sbk::core::child_ptr< TObject >

Syntactic type to define a pointer that must be a child of the owning object.

Constructor & Destructor Documentation

◆ child_ptr() [1/3]

template<typename TObject >
sbk::core::child_ptr< TObject >::child_ptr ( )
default

Default constructor is exposed for RTTR but not for the user.

Warning
Child Ptr objects must belong to a DatabaseObject at construction time.

◆ child_ptr() [2/3]

template<typename TObject >
sbk::core::child_ptr< TObject >::child_ptr ( const database_object owner)
inline

Construct a new Child Ptr object with an owner.

Child Ptr types must have an owner so it can check whether an assigned ptr is a child or not.

Parameters
ownerto check for child objects on

◆ child_ptr() [3/3]

template<typename TObject >
sbk::core::child_ptr< TObject >::child_ptr ( sbk_id  id)
inline

Construct a new child_ptr that points to the ID.

Tries to find the owner from the ID.


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