ComponentTypeId Class Template
Unique type identifier for component types, scoped per domain. More...
Declaration
Friends Index
template <typename THandle> | |
| bool | operator== |
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_t | value () const noexcept |
|
Returns the underlying ID value. More... | |
Private Member Attributes Index
template <typename THandle> | |
| size_t | id_ {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
Definition at line 52 of file ComponentTypeId.ixx.
Friends
operator==
| constexpr noexcept default |
Definition at line 105 of file ComponentTypeId.ixx.
Public Constructors
ComponentTypeId()
| 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.
Referenced by helios::ecs::types::ComponentTypeId< Handle_type >::id.
ComponentTypeId()
| 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()
| 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.
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_
|
Public Static Functions
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.
The documentation for this class was generated from the following file:
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.