Skip to main content

WorldLifecycleManager Class

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

Declaration

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

Base classes

classManager

Abstract base class for managers that process deferred operations. More...

classTypedCommandHandler<CommandType>

Type-safe handler for a specific command type. More...

Public Member Functions Index

boolsubmit (WorldLifecycleCommand cmd) noexcept override

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

voidinit (GameWorld &gameWorld) override

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

voidflush (UpdateContext &updateContext) noexcept override

Processes all pending lifecycle commands. More...

voidreset () override

Clears all pending commands. More...

Private Member Attributes Index

std::vector< WorldLifecycleCommand >pending_

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

GameWorld *gameWorld_ = nullptr

Cached pointer to the GameWorld, set during init(). 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 42 of file WorldLifecycleManager.ixx.

Public Member Functions

flush()

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

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 89 of file WorldLifecycleManager.ixx.

89 void flush(UpdateContext& updateContext) noexcept override {
90 if (pending_.empty() || gameWorld_ == nullptr) {
91 return;
92 }
93
94 std::vector<WorldLifecycleCommand> queue = std::move(pending_);
95 pending_.clear();
96
97 for (const auto& cmd : queue) {
98 switch (cmd.action()) {
100 gameWorld_->reset();
101 // reset complete, do not process further commands.
102 return;
103 }
104 }
105
106 }

Reference helios::engine::mechanics::lifecycle::types::Reset.

init()

void helios::engine::mechanics::lifecycle::WorldLifecycleManager::init (GameWorld & gameWorld)
inline virtual

Registers this manager as the WorldLifecycleCommand handler.

Parameters
gameWorld

The GameWorld to register with.

Definition at line 74 of file WorldLifecycleManager.ixx.

74 void init(GameWorld& gameWorld) override {
75 gameWorld_ = &gameWorld;
77 }

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

reset()

void helios::engine::mechanics::lifecycle::WorldLifecycleManager::reset ()
inline virtual

Clears all pending commands.

Definition at line 111 of file WorldLifecycleManager.ixx.

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

submit()

bool helios::engine::mechanics::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 64 of file WorldLifecycleManager.ixx.

64 bool submit(WorldLifecycleCommand cmd) noexcept override {
65 pending_.push_back(cmd);
66 return true;
67 }

Private Member Attributes

gameWorld_

GameWorld* helios::engine::mechanics::lifecycle::WorldLifecycleManager::gameWorld_ = nullptr

Cached pointer to the GameWorld, set during init().

Definition at line 53 of file WorldLifecycleManager.ixx.

53 GameWorld* gameWorld_ = nullptr;

pending_

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

Pending commands queued for the next flush.

Definition at line 48 of file WorldLifecycleManager.ixx.

48 std::vector<WorldLifecycleCommand> pending_;

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


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.