Skip to main content

ComponentTypeId Class

Unique type identifier for component types. More...

Declaration

class helios::engine::core::data::ComponentTypeId { ... }

Private Member Typedefs Index

usingComponentType = helios_engine_core_data_ComponentTypes

Friends Index

booloperator==

Public Constructors Index

ComponentTypeId (const size_t id)

Constructs a ComponentTypeId with a specific ID value. More...

ComponentTypeId (helios::core::types::no_init_t)

Constructs an uninitialized ComponentTypeId. More...

Public Member Functions Index

size_tvalue () const noexcept

Returns the underlying ID value. More...

Private Member Attributes Index

size_tid_ {0}

The underlying ID value. More...

Public Static Functions Index

template <typename T>
static ComponentTypeIdid ()

Gets the ComponentTypeId for a specific component type. More...

Description

Unique type identifier for component types.

ComponentTypeId assigns a unique, monotonically increasing integer ID to each component type at compile time. This ID is used as an index into the component storage vector within GameObject, enabling O(1) access.

**Usage:** ```cpp // Get the ID for a component type auto id = ComponentTypeId::id<Move2DComponent>();

// Use the value as an index components_[id.value()] = std::move(component); ```

**Thread Safety:** The static ID generation is thread-safe due to C++11 static initialization guarantees.

See Also

TypeIndexer

See Also

GameObject

Definition at line 41 of file ComponentTypeId.ixx.

Private Member Typedefs

ComponentType

using helios::engine::core::data::ComponentTypeId::ComponentType = helios_engine_core_data_ComponentTypes

Definition at line 48 of file ComponentTypeId.ixx.

48 using ComponentType = helios_engine_core_data_ComponentTypes;

Friends

operator==

friend bool ComponentTypeId, ComponentTypeId
constexpr noexcept default

Definition at line 102 of file ComponentTypeId.ixx.

Reference ComponentTypeId.

Public Constructors

ComponentTypeId()

helios::engine::core::data::ComponentTypeId::ComponentTypeId (const size_t id)
inline explicit

Constructs a ComponentTypeId with a specific ID value.

This constructor initializes a ComponentTypeId object with a given ID, representing a unique identifier for a component type. The ID is used internally for indexing and retrieving components from the storage system.

Parameters
id

The unique identifier assigned to the component type. This ID must be a valid non-negative value.

Definition at line 68 of file ComponentTypeId.ixx.

68 explicit ComponentTypeId(const size_t id) : id_(id) {}

Reference id.

Referenced by id and operator==.

ComponentTypeId()

helios::engine::core::data::ComponentTypeId::ComponentTypeId (helios::core::types::no_init_t)
inline explicit

Constructs an uninitialized ComponentTypeId.

Parameters
no_init_t

Tag to indicate no initialization.

Definition at line 75 of file ComponentTypeId.ixx.

Public Member Functions

value()

size_t helios::engine::core::data::ComponentTypeId::value ()
inline nodiscard noexcept

Private Member Attributes

id_

size_t helios::engine::core::data::ComponentTypeId::id_ {0}

The underlying ID value.

Definition at line 53 of file ComponentTypeId.ixx.

53 size_t id_{0};

Public Static Functions

id()

template <typename T>
ComponentTypeId helios::engine::core::data::ComponentTypeId::id ()
inline nodiscard static

Gets the ComponentTypeId for a specific component type.

Uses TypeIndexer to generate a unique, monotonically increasing ID for each component type. The ID is generated once per type and cached.

Template Parameters
T

The component type. Must be a concrete type (not abstract).

Returns

The unique ComponentTypeId for type T.

Definition at line 97 of file ComponentTypeId.ixx.

97 [[nodiscard]] static ComponentTypeId id() {
99 return ComponentTypeId(tid);
100 }

References ComponentTypeId and helios::core::data::TypeIndexer< Group >::typeIndex.

Referenced by helios::engine::ecs::GameObject::add, ComponentTypeId, helios::engine::ecs::EntityManager::emplace, helios::engine::ecs::EntityManager::get, helios::engine::ecs::EntityManager::getSparseSet, helios::engine::ecs::EntityManager::getSparseSet, helios::engine::ecs::EntityManager::has, helios::engine::ecs::ComponentReflector::registerType and helios::engine::ecs::EntityManager::remove.


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


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.