CommandHandlerRegistry.ixx File
Registry for mapping command types to their handlers. More...
Included Headers
#include <concepts>
#include <vector>
#include <cassert>
#include <helios.engine.runtime.messaging.command.types>
#include <helios.engine.ecs.types.ComponentTypeId>
Namespaces Index
| namespace | helios |
| namespace | engine |
|
Main engine module aggregating core infrastructure and game systems. More... | |
| namespace | runtime |
|
Runtime infrastructure for game execution and lifecycle orchestration. More... | |
| namespace | messaging |
|
Communication infrastructure for commands and events. More... | |
| namespace | command |
|
Compile-time typed command buffering and handler routing. More... | |
Classes Index
| struct | CommandHandlerEntry |
|
Type-erased storage entry for a registered command handler. More... | |
| struct | CommandHandlerRef<CommandType> |
|
Typed reference wrapper for invoking a registered handler. More... | |
| class | CommandHandlerRegistry |
|
Registry that maps CommandType types to handler instances via function pointers. More... | |
Description
Registry for mapping command types to their handlers.
File Listing
The file content with the documentation metadata removed is:
16using namespace helios::engine::ecs::types;
17using namespace helios::engine::runtime::messaging::command::types;
20export namespace helios::engine::runtime::messaging::command {
25 struct CommandHandlerEntry {
43 struct CommandHandlerRef {
60 [[nodiscard]] explicit operator bool() const noexcept {
79 * @details The CommandHandlerRegistry provides a mechanism to decouple command producers (systems)
81 * stores a type-erased "trampoline" function that allows invoking the handler's `submit(const Cmd&)`
89 class CommandHandlerRegistry {
109 * @param owner Reference to the handler instance. Must outlive the registry (usually Owned by GameWorld/ResourceRegistry).
114 void registerHandler(OwningT& owner) {
119 const auto idx = CommandTypeId::id<CommandType>().value();
127 entries_[idx] = CommandHandlerEntry{
130 return static_cast<OwningT*>(owner)->submit(*static_cast<const CommandType*>(cmd));
144 const auto idx = CommandTypeId::id<CommandType>().value();
162 [[nodiscard]] CommandHandlerRef<CommandType> tryHandler() const noexcept {
163 const auto idx = CommandTypeId::id<CommandType>().value();
175 return CommandHandlerRef<CommandType>{ entry.owner, entry.submitFn };
189 if (auto handler = tryHandler<CommandType>()) {
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.