Cogs.Core
|
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.
Definition at line 66 of file Component.h.
|
inlineconstexpr |
Explicit full initialization.
Definition at line 78 of file Component.h.
|
inlinestatic |
Returns an empty, invalid handle. Will evaluate to false if tested against using operator bool().
Definition at line 119 of file Component.h.
Referenced by Cogs::Core::EntityStore::addComponent(), Cogs::ComponentModel::Component::getComponentHandle(), Cogs::ComponentModel::Entity::getComponentHandle(), Cogs::Core::EntityStore::removeChild(), Cogs::Core::EntityStore::removeChildren(), Cogs::Core::PotreeSystem::update(), Cogs::Core::AssetSystem::update(), and Cogs::Core::CameraSystem::update().
|
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
Definition at line 116 of file Component.h.
References resolve().
Cogs::ComponentModel::Component * Cogs::ComponentModel::ComponentHandle::resolve | ( | ) | const |
Resolve the handle, returning a pointer to the held Component instance.
Definition at line 65 of file Component.cpp.
Referenced by Cogs::ComponentModel::Entity::addComponent(), Cogs::Core::OGC3DTilesSystem::createComponent(), Cogs::Core::PotreeSystem::createComponent(), Cogs::ComponentModel::ComponentPoolBase::deallocateComponent(), Cogs::Core::Image360System::destroyComponent(), Cogs::Core::OGC3DTilesSystem::destroyComponent(), Cogs::Core::EntityStore::getEntityParent(), operator bool(), Cogs::ComponentModel::Entity::removeComponent(), and resolveComponent().
|
inline |
Utility method for returning a pointer to a type derived from Component. Might incur a performance penalty if type checking is enabled.
Definition at line 90 of file Component.h.
References resolve().
Referenced by Cogs::Core::CurtainView::CurtainViewSystem::createComponent(), Cogs::Core::EchoSounder::UniformGridSystem::createComponent(), Cogs::Core::FixedConstraintSystem::destroyComponent(), Cogs::Core::HingeConstraintSystem::destroyComponent(), Cogs::Core::SpringConstraintSystem::destroyComponent(), Cogs::Core::GenericConstraintSystem::destroyComponent(), Cogs::Core::GhostSystem::destroyComponent(), Cogs::Core::RigidBodySystem::destroyComponent(), Cogs::Core::TriggerSystem::destroyComponent(), Cogs::Core::EchoSounder::UniformGridSystem::destroyComponent(), Cogs::Core::OceanSystem::destroyComponent(), Cogs::Core::TerrainSystem::destroyComponent(), Cogs::Core::VectorField::VectorFieldSystem::destroyComponent(), Cogs::Core::VideoCaptureSystem::destroyComponent(), Cogs::Core::CaptureSystem::destroyComponent(), Cogs::Core::AudioSystem::destroyComponent(), Cogs::Core::VideoPlaybackSystem::destroyComponent(), Cogs::Core::VectorField::VectorFieldBounds::getBounds(), Cogs::Core::EnvironmentSystem::getGlobalEnvironment(), Cogs::Core::FogSystem::getGlobalFog(), Cogs::Core::CameraSystem::getMainCamera(), Cogs::Core::InstancedMeshPicker::pickImpl(), Cogs::Core::MeshRenderPicker::pickImpl(), Cogs::Core::SubMeshPicker::pickImpl(), Cogs::Core::Scene::setup(), and Cogs::Core::InstancedModelSystem::update().