Skip to main content

ComponentTypeId Class Template

Unique type identifier for component types, scoped per domain. More...

Declaration

template <typename THandle> class helios::ecs::types::ComponentTypeId<THandle> { ... }

Friends Index

template <typename THandle>
booloperator==

Public Constructors Index

template <typename THandle>
ComponentTypeId (const size_t id)

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

template <typename THandle>
ComponentTypeId (helios::core::types::no_init_t)

Constructs an uninitialized ComponentTypeId. More...

Public Member Functions Index

template <typename THandle>
size_tvalue () const noexcept

Returns the underlying ID value. More...

Private Member Attributes Index

template <typename THandle>
size_tid_ {0}

The underlying ID value. More...

Public Static Functions Index

template <typename T>
static auto id () -> ComponentTypeId< THandle >

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

Description

Unique type identifier for component types, scoped per domain.

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 EntityManager, enabling O(1) access.

## Domain Scoping

The class is templated on `THandle` so that each domain (identified by its `EntityHandle<TStrongId>` specialisation) has its own independent type-ID counter via `TypeIndexer<THandle>`. This means the same component type `T` can receive different IDs in different domains.

**Usage:** ```cpp // Get the ID for a component type in the game domain auto id = ComponentTypeId<GameHandle>::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.

Template Parameters
THandle

The concrete `EntityHandle<TStrongId>` specialisation scoping this type-ID counter.

See Also

TypeIndexer

See Also

EntityManager

Definition at line 52 of file ComponentTypeId.ixx.

Friends

operator==

friend bool ComponentTypeId, ComponentTypeId
constexpr noexcept default

Definition at line 105 of file ComponentTypeId.ixx.

Public Constructors

ComponentTypeId()

template <typename THandle>
helios::ecs::types::ComponentTypeId< THandle >::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 71 of file ComponentTypeId.ixx.

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

Referenced by helios::ecs::types::ComponentTypeId< Handle_type >::id.

ComponentTypeId()

template <typename THandle>
helios::ecs::types::ComponentTypeId< THandle >::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 78 of file ComponentTypeId.ixx.

Public Member Functions

value()

template <typename THandle>
size_t helios::ecs::types::ComponentTypeId< THandle >::value ()
inline nodiscard noexcept

Returns the underlying ID value.

Returns

The numeric type ID, suitable for use as an array index.

Definition at line 85 of file ComponentTypeId.ixx.

85 [[nodiscard]] size_t value() const noexcept {
86 return id_;
87 }

Referenced by helios::ecs::EntityManager< THandle, TEntityRegistry, TCapacity >::has, helios::ecs::ComponentOpsRegistry< Handle_type >::ops, helios::ecs::EntityManager< THandle, TEntityRegistry, TCapacity >::raw and helios::ecs::ComponentOpsRegistry< Handle_type >::setOps.

Private Member Attributes

id_

template <typename THandle>
size_t helios::ecs::types::ComponentTypeId< THandle >::id_ {0}

The underlying ID value.

Definition at line 57 of file ComponentTypeId.ixx.

57 size_t id_{0};

Public Static Functions

id()

template <typename T>
ComponentTypeId< THandle > helios::ecs::types::ComponentTypeId< THandle >::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 100 of file ComponentTypeId.ixx.

100 [[nodiscard]] static ComponentTypeId<THandle> id() {
101 static const size_t tid = helios::core::TypeIndexer<THandle>::template typeIndex<T>();
102 return ComponentTypeId(tid);
103 }

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


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.