Skip to main content

UiActionCommandManager Class

Manages and processes UI action commands with policy-based dispatch. More...

Declaration

class helios::engine::modules::ui::UiActionCommandManager { ... }

Public Member Typedefs Index

usingEngineRoleTag = helios::engine::common::tags::ManagerRole

Private Member Typedefs Index

usingActionCallback = std::function< void( helios::engine::runtime::world::UpdateContext &updateContext, const UiActionCommand &command)>

Public Constructors Index

UiActionCommandManager ()

Constructs the manager with default capacity. More...

Public Member Functions Index

voidflush (helios::engine::runtime::world::UpdateContext &update_context) noexcept

Processes all pending commands by invoking their registered policies. More...

boolsubmit (UiActionCommand uiActionCommand) noexcept

Submits a UI action command for processing. More...

UiActionCommandManager &addPolicy (const ActionId actionId, ActionCallback callback)

Registers a callback for a specific action ID. More...

voidinit (helios::engine::runtime::world::GameWorld &gameWorld)

Initializes the manager and registers it with the game world. More...

Private Member Attributes Index

std::vector< UiActionCommand >commands_

Queue of pending UI action commands. More...

std::unordered_map< ActionId, ActionCallback >policies_

Map from ActionId to their handling callbacks. More...

Description

Manages and processes UI action commands with policy-based dispatch.

Collects UiActionCommand instances and dispatches them to registered action callbacks based on ActionId. Supports policy registration for handling different action types.

See Also

UiActionCommand

See Also

CommandHandlerRegistry

Definition at line 43 of file UiActionCommandManager.ixx.

Public Member Typedefs

EngineRoleTag

using helios::engine::modules::ui::UiActionCommandManager::EngineRoleTag = helios::engine::common::tags::ManagerRole

Private Member Typedefs

ActionCallback

using helios::engine::modules::ui::UiActionCommandManager::ActionCallback = std::function<void( helios::engine::runtime::world::UpdateContext& updateContext, const UiActionCommand& command)>

Definition at line 45 of file UiActionCommandManager.ixx.

45 using ActionCallback = std::function<void(

Public Constructors

UiActionCommandManager()

helios::engine::modules::ui::UiActionCommandManager::UiActionCommandManager ()
inline

Constructs the manager with default capacity.

Definition at line 64 of file UiActionCommandManager.ixx.

65 commands_.reserve(UI_ACTION_COMMAND_HANDLER_DEFAULT_CAPACITY);
66 };

Referenced by addPolicy.

Public Member Functions

addPolicy()

UiActionCommandManager & helios::engine::modules::ui::UiActionCommandManager::addPolicy (const ActionId actionId, ActionCallback callback)
inline

Registers a callback for a specific action ID.

Parameters
actionId

The action ID to register.

callback

The callback to invoke when the action is triggered.

Returns

Reference to this manager for method chaining.

Definition at line 111 of file UiActionCommandManager.ixx.

112 const ActionId actionId,
113 ActionCallback callback
114 ) {
115 assert(policies_.find(actionId) == policies_.end() && "Action already registered");
116
117 policies_[actionId] = std::move(callback);
118 return *this;
119 }

Reference UiActionCommandManager.

flush()

void helios::engine::modules::ui::UiActionCommandManager::flush (helios::engine::runtime::world::UpdateContext & update_context)
inline noexcept

Processes all pending commands by invoking their registered policies.

Parameters
gameWorld

The game world.

update_context

The current update context.

Definition at line 74 of file UiActionCommandManager.ixx.

74 void flush(
76 ) noexcept {
77
78 for (auto cmd : commands_) {
79 if (policies_.contains(cmd.actionId())) {
80 policies_[cmd.actionId()](
81 update_context, cmd
82 );
83 }
84 }
85
86 commands_.clear();
87 }

init()

void helios::engine::modules::ui::UiActionCommandManager::init (helios::engine::runtime::world::GameWorld & gameWorld)
inline

Initializes the manager and registers it with the game world.

Parameters
gameWorld

The game world to register with.

Definition at line 126 of file UiActionCommandManager.ixx.

Reference helios::engine::runtime::world::GameWorld::registerCommandHandler.

submit()

bool helios::engine::modules::ui::UiActionCommandManager::submit (UiActionCommand uiActionCommand)
inline noexcept

Submits a UI action command for processing.

Parameters
uiActionCommand

The command to submit.

Returns

Always returns true.

Definition at line 96 of file UiActionCommandManager.ixx.

96 bool submit(UiActionCommand uiActionCommand) noexcept {
97
98 commands_.push_back(std::move(uiActionCommand));
99
100 return true;
101 };

Private Member Attributes

commands_

std::vector<UiActionCommand> helios::engine::modules::ui::UiActionCommandManager::commands_

Queue of pending UI action commands.

Definition at line 51 of file UiActionCommandManager.ixx.

51 std::vector<UiActionCommand> commands_;

policies_

std::unordered_map<ActionId, ActionCallback> helios::engine::modules::ui::UiActionCommandManager::policies_

Map from ActionId to their handling callbacks.

Definition at line 56 of file UiActionCommandManager.ixx.

56 std::unordered_map<ActionId, ActionCallback> policies_;

The documentation for this class was generated from the following file:


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.