SystemRegistry Class
Container for System instances within a game loop pass. More...
Declaration
Public Member Functions Index
| std::vector< std::unique_ptr< helios::engine::ecs::System > > & | systems () noexcept |
|
Returns a reference to the system collection. More... | |
template <typename T, typename... Args> | |
| T & | add (Args &&... args) |
|
Adds a new System of type T to the registry. More... | |
template <typename T> | |
| bool | hasSystem () const |
|
Checks if a System of type T is registered. More... | |
template <typename T> | |
| T * | getSystem () const |
|
Retrieves a System by type. More... | |
Private Member Attributes Index
| std::vector< std::unique_ptr< helios::engine::ecs::System > > | systems_ |
|
Collection of owned System instances. More... | |
Description
Container for System instances within a game loop pass.
SystemRegistry manages a collection of Systems that execute together within a single pass of the game loop. It provides type-safe registration, lookup, and iteration over Systems.
## Ownership
The registry owns all registered Systems via `std::unique_ptr`. Systems are destroyed when the registry is destroyed.
## Type-Safe Access
Systems can be retrieved by type using `getSystem<T>()`, enabling inter-system communication when necessary.
Example: ```cpp SystemRegistry registry;
// Add systems registry.add<Move2DSystem>(gameWorld); registry.add<CollisionSystem>(gameWorld);
// Check for system if (registry.hasSystem<CollisionSystem>()) { auto* collision = registry.getSystem<CollisionSystem>(); }
// Iterate all systems for (auto& system : registry.systems()) { system->update(ctx); } ```
- See Also
System
- See Also
GameLoop
- See Also
GameLoopPhase
Definition at line 59 of file SystemRegistry.ixx.
Public Member Functions
add()
| inline |
Adds a new System of type T to the registry.
- Template Parameters
-
T The System type to add. Must derive from System.
Args Constructor argument types.
- Parameters
-
args Arguments forwarded to the System constructor.
- Returns
Reference to the newly added System.
- Precondition
No System of type T is already registered.
Definition at line 91 of file SystemRegistry.ixx.
Reference hasSystem.
getSystem()
| inline nodiscard |
Retrieves a System by type.
- Template Parameters
-
T The System type to retrieve.
- Returns
Pointer to the System if found, nullptr otherwise.
Uses dynamic_cast for type checking. O(n) complexity.
Definition at line 123 of file SystemRegistry.ixx.
Referenced by hasSystem.
hasSystem()
| inline nodiscard |
Checks if a System of type T is registered.
- Template Parameters
-
T The System type to check for.
- Returns
True if the System exists, false otherwise.
Definition at line 108 of file SystemRegistry.ixx.
Reference getSystem.
Referenced by add.
systems()
| inline nodiscard noexcept |
Returns a reference to the system collection.
- Returns
Reference to the vector of System unique_ptrs.
Definition at line 73 of file SystemRegistry.ixx.
Private Member Attributes
systems_
|
Collection of owned System instances.
Definition at line 64 of file SystemRegistry.ixx.
The documentation for this class was generated from the following file:
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.