ComponentTypeId Class
Unique type identifier for component types. More...
Declaration
Private Member Typedefs Index
| using | ComponentType = helios_engine_core_data_ComponentTypes |
Friends Index
| bool | operator== |
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_t | value () const noexcept |
|
Returns the underlying ID value. More... | |
Private Member Attributes Index
| size_t | id_ {0} |
|
The underlying ID value. More... | |
Public Static Functions Index
template <typename T> | |
| static ComponentTypeId | id () |
|
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
|
Definition at line 48 of file ComponentTypeId.ixx.
Friends
operator==
| constexpr noexcept default |
Definition at line 102 of file ComponentTypeId.ixx.
Reference ComponentTypeId.
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 68 of file ComponentTypeId.ixx.
Reference id.
Referenced by id and operator==.
ComponentTypeId()
| 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()
| inline nodiscard noexcept |
Returns the underlying ID value.
- Returns
The numeric type ID, suitable for use as an array index.
Definition at line 82 of file ComponentTypeId.ixx.
Referenced by 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::EntityManager::has, helios::engine::ecs::ComponentOpsRegistry::ops, helios::engine::ecs::EntityManager::raw and helios::engine::ecs::ComponentOpsRegistry::setOps.
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 97 of file ComponentTypeId.ixx.
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.