Cogs.Foundation
|
Handle to a Component instance. More...
#include <Component.h>
Public Member Functions | |
ComponentHandle ()=default | |
Defaulted constructor. | |
ComponentHandle (const ComponentHandle &other)=default | |
Defaulted copy constructor. | |
ComponentHandle & | operator= (const ComponentHandle &rhs)=default |
Defaulted assign operator. | |
constexpr | ComponentHandle (class ComponentPoolBase *pool, ComponentIndex index, Reflection::TypeId typeId, uint16_t generation) |
Explicit full initialization. | |
COGSFOUNDATION_API class Component * | resolve () const |
Resolve the handle, returning a pointer to the held Component instance. | |
template<typename ComponentType > | |
ComponentType * | resolveComponent () const |
operator bool () const | |
Explicit bool conversion for checking if a handle is valid. | |
Static Public Member Functions | |
static ComponentHandle | Empty () |
Returns an empty, invalid handle. Will evaluate to false if tested against using operator bool(). | |
Handle to a Component instance.
|
default |
Defaulted constructor.
|
default |
Defaulted copy constructor.
|
inlineconstexpr |
Explicit full initialization.
|
inlinestatic |
Returns an empty, invalid handle. Will evaluate to false if tested against using operator bool().
Referenced by Cogs::ComponentModel::Component::getComponentHandle(), and Cogs::ComponentModel::Entity::getComponentHandle().
|
inlineexplicit |
Explicit bool conversion for checking if a handle is valid.
Since we check the generation counter, this is essentially the same as a resolve.
To avoid paying the resolve cost twice when subsequently resolving the handle, use the following pattern
instead of
References resolve().
|
default |
Defaulted assign operator.
Cogs::ComponentModel::Component * Cogs::ComponentModel::ComponentHandle::resolve | ( | ) | const |
Resolve the handle, returning a pointer to the held Component instance.
References LOG_WARNING, and Cogs::logger.
Referenced by Cogs::ComponentModel::Entity::addComponent(), Cogs::ComponentModel::ComponentPoolBase::deallocateComponent(), operator bool(), Cogs::ComponentModel::Entity::removeComponent(), and resolveComponent().
|
inline |