TypedHandleWorld Class Template
A multi-domain entity world that dispatches operations to the correct `EntityManager` based on the handle type. More...
Declaration
Public Member Functions Index
template <typename THandle> | |
| auto & | entityManager () |
|
Returns a reference to the EntityManager that owns handles of type `THandle`. More... | |
template <typename THandle> | |
| const auto & | entityManager () const |
|
Returns a const reference to the EntityManager that owns handles of type `THandle`. More... | |
template <typename THandle> | |
| auto | addEntity (THandle::StrongId_type strongId) |
|
Creates a new entity in the domain identified by `THandle`. More... | |
template <typename THandle> | |
| auto | addEntity () |
|
Creates a new entity with an auto-generated id. More... | |
template <typename THandle> | |
| bool | destroy (THandle handle) |
|
Destroys an entity identified by its handle. More... | |
template <typename THandle> | |
| auto | findEntity (THandle handle) |
|
Looks up an existing entity by its handle. More... | |
template <typename THandle> | |
| auto | cloneEntity (THandle source) noexcept |
|
Clones all components from a source entity into a new entity. More... | |
template <typename THandle, typename ... TComponents> | |
| auto | view () |
|
Creates a `View` for iterating entities with specific components. More... | |
Private Member Attributes Index
template <typename... TEntityManagers> | |
| std::tuple< TEntityManagers... > | entityManagers_ |
Description
A multi-domain entity world that dispatches operations to the correct `EntityManager` based on the handle type.
`TypedHandleWorld` holds a tuple of `EntityManager` instances, each responsible for a different entity domain (identified by its handle type). All public methods accept a handle-type template argument and resolve the matching manager at **compile time** via `HandleToManager`.
This enables a single world object to manage entities from multiple independent registries — for example game entities, UI entities, and audio entities — without runtime dispatch overhead.
## Domain-Specific Entity Managers
Each `TEntityManagers` template argument is a fully configured `EntityManager<THandle, TEntityRegistry, TCapacity>` specialisation. The handle type (`THandle`) serves as the **domain key**: calling `addEntity<MyHandle>()` automatically selects the manager whose `Handle_type` is `MyHandle`.
## Usage
```cpp // Define domain-specific handle types using GameHandle = EntityHandle<GameStrongId>; using UiHandle = EntityHandle<UiStrongId>;
// Configure managers using GameEM = EntityManager<GameHandle, GameRegistry, 4096>; using UiEM = EntityManager<UiHandle, UiRegistry, 512>;
// Create the world TypedHandleWorld<GameEM, UiEM> world;
// Add entities — handle type selects the manager auto player = world.addEntity<GameHandle>(); auto button = world.addEntity<UiHandle>();
// Query a specific domain for (auto [entity, transform, velocity] : world.view<GameHandle, TransformComponent, VelocityComponent>()) { // ... } ```
## Template Parameters
- Template Parameters
-
TEntityManagers One or more `EntityManager` specialisations. Each must expose a unique `Handle_type` typedef.
- See Also
- See Also
- See Also
- See Also
Definition at line 121 of file TypedHandleWorld.ixx.
Public Member Functions
addEntity()
| inline nodiscard |
Creates a new entity in the domain identified by `THandle`.
Delegates to the matching `EntityManager::create()` and wraps the result in an `Entity` facade.
- Template Parameters
-
THandle The handle type identifying the target domain.
- Returns
An `Entity` wrapping the newly created handle.
Definition at line 171 of file TypedHandleWorld.ixx.
Reference helios::ecs::TypedHandleWorld< TEntityManagers >::entityManager.
addEntity()
| inline nodiscard |
Creates a new entity with an auto-generated id.
- Template Parameters
-
THandle The handle type identifying the target domain.
- Returns
An `Entity` wrapping the newly created handle.
Definition at line 187 of file TypedHandleWorld.ixx.
Reference helios::ecs::TypedHandleWorld< TEntityManagers >::entityManager.
Referenced by helios::ecs::TypedHandleWorld< TEntityManagers >::cloneEntity.
cloneEntity()
| inline nodiscard noexcept |
Clones all components from a source entity into a new entity.
Creates a new entity in the same domain and copies every component attached to `source` into it via `EntityManager::clone()`.
- Template Parameters
-
THandle The handle type identifying the target domain.
- Parameters
-
source The handle of the entity to clone.
- Returns
An `Entity` wrapping the newly created clone.
Definition at line 253 of file TypedHandleWorld.ixx.
References helios::ecs::TypedHandleWorld< TEntityManagers >::addEntity and helios::ecs::TypedHandleWorld< TEntityManagers >::entityManager.
destroy()
| inline |
Destroys an entity identified by its handle.
Delegates to the owning `EntityManager::destroy()`. The handle's version is incremented, making all existing copies stale.
- Template Parameters
-
THandle The handle type identifying the target domain.
- Parameters
-
handle The handle of the entity to destroy.
- Returns
True if the entity was valid and successfully destroyed.
Definition at line 208 of file TypedHandleWorld.ixx.
Reference helios::ecs::TypedHandleWorld< TEntityManagers >::entityManager.
entityManager()
| inline |
Returns a reference to the EntityManager that owns handles of type `THandle`.
Uses `HandleToManager` to resolve the tuple index at compile time. A `static_assert` fires if no manager matches.
- Template Parameters
-
THandle The handle type identifying the target domain.
- Returns
Mutable reference to the matching EntityManager.
Definition at line 140 of file TypedHandleWorld.ixx.
Referenced by helios::ecs::TypedHandleWorld< TEntityManagers >::addEntity, helios::ecs::TypedHandleWorld< TEntityManagers >::addEntity, helios::ecs::TypedHandleWorld< TEntityManagers >::cloneEntity, helios::ecs::TypedHandleWorld< TEntityManagers >::destroy, helios::ecs::TypedHandleWorld< TEntityManagers >::findEntity and helios::ecs::TypedHandleWorld< TEntityManagers >::view.
entityManager()
| inline |
Returns a const reference to the EntityManager that owns handles of type `THandle`.
- Template Parameters
-
THandle The handle type identifying the target domain.
- Returns
Const reference to the matching EntityManager.
Definition at line 154 of file TypedHandleWorld.ixx.
findEntity()
| inline nodiscard |
Looks up an existing entity by its handle.
Validates the handle via the owning `EntityManager`. If valid, returns an `Entity` facade; otherwise returns `std::nullopt`.
- Template Parameters
-
THandle The handle type (and thus the domain) to search.
- Parameters
-
handle The entity handle to resolve.
- Returns
`std::optional<Entity>` — engaged if the handle is valid.
Definition at line 227 of file TypedHandleWorld.ixx.
Reference helios::ecs::TypedHandleWorld< TEntityManagers >::entityManager.
view()
| inline nodiscard |
Creates a `View` for iterating entities with specific components.
The view operates on the `EntityManager` identified by `THandle`. The first component type in `TComponents` serves as the lead set for iteration.
- Template Parameters
-
THandle The handle type selecting the domain.
TComponents The component types to include in the view.
- Returns
A `View` over the matching EntityManager.
- See Also
Definition at line 278 of file TypedHandleWorld.ixx.
Reference helios::ecs::TypedHandleWorld< TEntityManagers >::entityManager.
Private Member Attributes
entityManagers_
|
Definition at line 123 of file TypedHandleWorld.ixx.
The documentation for this class was generated from the following file:
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.