Skip to main content

WorldLifecycleManager Class

Manager that processes deferred world lifecycle commands. More...

Declaration

class helios::engine::runtime::lifecycle::WorldLifecycleManager { ... }

Public Member Typedefs Index

usingEngineRoleTag = helios::engine::runtime::world::tags::ManagerRole

Public Member Functions Index

boolsubmit (WorldLifecycleCommand cmd) noexcept

Enqueues a lifecycle command for deferred processing. More...

voidinit (CommandHandlerRegistry &commandHandlerRegistry)

Registers this manager as the WorldLifecycleCommand handler. More...

voidflush (UpdateContext &updateContext) noexcept

Processes all pending lifecycle commands. More...

voidreset ()

Clears all pending commands. More...

Private Member Attributes Index

std::vector< WorldLifecycleCommand >pending_

Pending commands queued for the next flush. More...

Description

Manager that processes deferred world lifecycle commands.

WorldLifecycleManager collects WorldLifecycleCommands via submit() and executes them during flush(). This allows systems to request world-level operations (e.g. reset) through the command pipeline instead of calling GameWorld methods directly.

On Reset, the pending queue is moved to a local variable before processing. This prevents re-entrant issues since GameWorld::reset() calls Manager::reset() on all managers, including this one.

See Also

WorldLifecycleCommand

See Also

WorldLifecycleAction

See Also

GameWorld::reset

Definition at line 41 of file WorldLifecycleManager.ixx.

Public Member Typedefs

EngineRoleTag

using helios::engine::runtime::lifecycle::WorldLifecycleManager::EngineRoleTag = helios::engine::runtime::world::tags::ManagerRole

Public Member Functions

flush()

void helios::engine::runtime::lifecycle::WorldLifecycleManager::flush (UpdateContext & updateContext)
inline noexcept

Processes all pending lifecycle commands.

Moves the pending queue to a local variable before iterating. This is necessary because a Reset action triggers GameWorld::reset(), which in turn calls reset() on this manager, clearing pending_.

Parameters
updateContext

The current frame's update context.

Definition at line 84 of file WorldLifecycleManager.ixx.

85 if (pending_.empty()) {
86 return;
87 }
88
89 std::vector<WorldLifecycleCommand> queue = std::move(pending_);
90 pending_.clear();
91
92 for (const auto& cmd : queue) {
93 switch (cmd.action()) {
94 case WorldLifecycleAction::Reset:
99 assert(false && "Needs to call GameWorld reset()");
100 // reset complete, do not process further commands.
101 return;
102 }
103 }
104
105 }

Reference helios::engine::runtime::lifecycle::registerComponents.

init()

void helios::engine::runtime::lifecycle::WorldLifecycleManager::init (CommandHandlerRegistry & commandHandlerRegistry)
inline

Registers this manager as the WorldLifecycleCommand handler.

Parameters
gameWorld

The GameWorld to register with.

Definition at line 70 of file WorldLifecycleManager.ixx.

70 void init(CommandHandlerRegistry& commandHandlerRegistry) {
71 commandHandlerRegistry.registerHandler<WorldLifecycleCommand>(*this);
72 }

Reference helios::engine::runtime::messaging::command::CommandHandlerRegistry::registerHandler.

reset()

void helios::engine::runtime::lifecycle::WorldLifecycleManager::reset ()
inline

Clears all pending commands.

Definition at line 110 of file WorldLifecycleManager.ixx.

110 void reset() {
111 pending_.clear();
112 }

submit()

bool helios::engine::runtime::lifecycle::WorldLifecycleManager::submit (WorldLifecycleCommand cmd)
inline noexcept

Enqueues a lifecycle command for deferred processing.

Parameters
cmd

The command to enqueue.

Returns

True if the command was accepted.

Definition at line 60 of file WorldLifecycleManager.ixx.

61 pending_.push_back(cmd);
62 return true;
63 }

Reference helios::engine::runtime::lifecycle::registerComponents.

Private Member Attributes

pending_

std::vector<WorldLifecycleCommand> helios::engine::runtime::lifecycle::WorldLifecycleManager::pending_

Pending commands queued for the next flush.

Definition at line 46 of file WorldLifecycleManager.ixx.

46 std::vector<WorldLifecycleCommand> pending_;

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


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.9.8.