Loading...
Searching...
No Matches
by::life Class Reference

Binding tag for instance reference tracking and lifecycle management. More...

#include <life.hpp>

Inheritance diagram for by::life:
by::typeProvidable by::tbindable< instance >

Public Member Functions

 life (id newId)
 
instanceoperator-> ()
 
instanceoperator* ()
 
const instanceoperator-> () const BY_CONST_FUNC(operator->()) const instance &operator*() const BY_CONST_FUNC(operator*()) public:const chunk *getChunk() const
 
ncnt getStrongCnt () const
 Returns current strong reference count.
 
void rel () override
 Releases the binding for this life object, decrementing the strong reference count.
 
nbool isBind () const override
 
const typegetBindable () const
 
instanceget ()
 
const instanceget () const BY_CONST_FUNC(get()) template< typename E > E *get()
 
template<typename E >
const E *get() const BY_CONST_FUNC(get< E >()) using tbindable< instance > nbool canBind (const type &cls) const override
 
nbool bind (const instance &new1) override
 Binds instance to this life object for lifecycle tracking.
 
id getId () const
 
const typegetType () const override
 
nbool onStrong (ncnt vote)
 Updates strong reference count by vote amount.
 
- Public Member Functions inherited from by::typeProvidable
nbool operator== (const me &rhs) const
 
nbool operator!= (const me &rhs) const
 
nbool isSub (const type &it) const
 
nbool isSub (const type *it) const BY_SIDE_FUNC(isSub)
 
nbool isSub (const me &it) const
 
nbool isSub (const me *it) const BY_SIDE_FUNC(isSub)
 
nbool isSuper (const type &it) const
 
nbool isSuper (const type *it) const BY_SIDE_FUNC(isSuper)
 
nbool isSuper (const me &it) const
 
nbool isSuper (const me *it) const BY_SIDE_FUNC(isSuper)
 
template<typename T >
nint isSub () const
 
template<typename T >
nint isSuper () const
 
template<typename T >
Tcast ()
 
template<typename T >
const Tcast () const BY_CONST_FUNC(cast< T >()) virtual void *cast(const type &to)
 Safe cast to target type using type hierarchy information.
 
const voidcast (const type &to) const BY_CONST_FUNC(cast(to)) void *cast(const type *it) BY_SIDE_FUNC(cast)
 
- Public Member Functions inherited from by::tbindable< instance >
 operator nbool () const
 
nbool bind (const instance *it)
 Bind to instance pointer.
 
nbool canBind (const instance &it) const
 
nbool canBind (const instance *it) const BY_SIDE_FUNC(canBind)
 
nbool canBind (const type *it) const BY_SIDE_FUNC(canBind)
 

Static Public Member Functions

static const lifegetBindTag (id newId)
 Retrieves life object associated with given id.
 

Detailed Description

Binding tag for instance reference tracking and lifecycle management.

While pool manages memory from a low-level block perspective, the watcher component organically manages information for each block. See watcher first for details. life has an address value (_pt) allocated in pool and values for reference counting.

_strong is for reference counting, _pt directly points to an instance allocated in pool. _id is for identifying objects, see id for details.

Member Function Documentation

◆ bind()

nbool by::life::bind ( const instance & new1)
overridevirtual

Binds instance to this life object for lifecycle tracking.

Returns
true on success, false if already bound or type mismatch
Note
Initializes _pt pointer and sets up reference counting. Called by instancer.

Reimplemented from by::tbindable< instance >.

◆ canBind()

template<typename E >
const E *get() const BY_CONST_FUNC(get< E >()) using tbindable< instance > nbool by::life::canBind ( const type & cls) const
overridevirtual

◆ getBindTag()

static const life * by::life::getBindTag ( id newId)
static

Retrieves life object associated with given id.

Returns
Pointer to life object, or nullptr if not found
Note
Used to lookup life objects from watcher by instance id

◆ getStrongCnt()

ncnt by::life::getStrongCnt ( ) const

Returns current strong reference count.

Returns
Number of strong references (tstr binders) pointing to this instance

◆ getType()

const type & by::life::getType ( ) const
overridevirtual

Implements by::typeProvidable.

◆ isBind()

nbool by::life::isBind ( ) const
overridevirtual

◆ onStrong()

nbool by::life::onStrong ( ncnt vote)

Updates strong reference count by vote amount.

Parameters
votePositive to increment, negative to decrement reference count
Returns
true on success, false on error
Note
When count reaches 0, triggers instance destruction via instancer

◆ rel()

void by::life::rel ( )
overridevirtual

Releases the binding for this life object, decrementing the strong reference count.

When the strong count reaches zero, the associated instance is typically destroyed via the instancer.

Implements by::tbindable< instance >.


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