Skip to main content

ScorePoolManager Class

Manages score pools and processes score commands. More...

Declaration

class helios::engine::mechanics::scoring::ScorePoolManager { ... }

Public Member Typedefs Index

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

Public Member Functions Index

ScorePool &addScorePool (helios::engine::mechanics::scoring::types::ScorePoolId scorePoolId) noexcept

Creates and registers a new score pool. More...

ScorePool *scorePool (const helios::engine::mechanics::scoring::types::ScorePoolId scorePoolId) noexcept

Retrieves a score pool by ID. More...

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

Flushes pending score updates to their respective pools. More...

boolsubmit (UpdateScoreCommand updateScoreCommand) noexcept

Submits a score update command for processing. More...

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

Initializes the manager and registers it as the score command handler. More...

voidreset ()

Resets all managed score pools to zero. More...

Private Member Attributes Index

std::vector< ScorePool >pools_

Collection of score pools managed by this manager. More...

std::vector< helios::engine::mechanics::scoring::types::ScoreValueContext >scores_

Pending score contexts to be processed on flush. More...

Description

Manages score pools and processes score commands.

ScorePoolManager is responsible for creating and managing score pools, and for handling score update commands. It implements both the Manager interface (for lifecycle management) and ScoreCommandHandler (for receiving score commands from the command system).

Score updates are batched: commands submitted via `submit()` are queued and processed during `flush()`, ensuring deterministic ordering.

See Also

ScorePool

See Also

ScoreCommandHandler

See Also

Manager

Definition at line 51 of file ScorePoolManager.ixx.

Public Member Typedefs

EngineRoleTag

using helios::engine::mechanics::scoring::ScorePoolManager::EngineRoleTag = helios::engine::common::tags::ManagerRole

Public Member Functions

addScorePool()

ScorePool & helios::engine::mechanics::scoring::ScorePoolManager::addScorePool (helios::engine::mechanics::scoring::types::ScorePoolId scorePoolId)
inline noexcept

Creates and registers a new score pool.

Parameters
scorePoolId

Unique identifier for the new pool.

Returns

Reference to the newly created ScorePool.

Definition at line 75 of file ScorePoolManager.ixx.

76
77 assert(!scorePool(scorePoolId) && "Score with scorePoolId already registered");
78
79 pools_.emplace_back(scorePoolId);
80
81 return pools_.back();
82 }

Reference scorePool.

flush()

void helios::engine::mechanics::scoring::ScorePoolManager::flush (helios::engine::runtime::world::UpdateContext & update_context)
inline noexcept

Flushes pending score updates to their respective pools.

Processes all pending ScoreValueContext entries and adds them to the appropriate score pools based on their scorePoolId.

Parameters
gameWorld

Reference to the game world.

update_context

Reference to the update context.

Definition at line 115 of file ScorePoolManager.ixx.

115 void flush(
117 ) noexcept {
118
119 for (const auto& scoreContext : scores_) {
120
121 for (auto& pool : pools_) {
122 if (const auto scorePoolId = pool.scorePoolId(); scorePoolId == scoreContext.scorePoolId) {
123 pool.addScore(scoreContext);
124 break;
125 }
126 }
127 }
128
129
130 scores_.clear();
131 }

init()

void helios::engine::mechanics::scoring::ScorePoolManager::init (helios::engine::runtime::world::GameWorld & gameWorld)
inline

Initializes the manager and registers it as the score command handler.

Parameters
gameWorld

Reference to the game world.

Definition at line 154 of file ScorePoolManager.ixx.

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

reset()

void helios::engine::mechanics::scoring::ScorePoolManager::reset ()
inline

Resets all managed score pools to zero.

Iterates through all registered pools and calls their reset() method, clearing all scores and resetting totals.

Definition at line 165 of file ScorePoolManager.ixx.

165 void reset() {
166 for (auto& pool : pools_) {
167 pool.reset();
168 }
169 }

scorePool()

ScorePool * helios::engine::mechanics::scoring::ScorePoolManager::scorePool (const helios::engine::mechanics::scoring::types::ScorePoolId scorePoolId)
inline nodiscard noexcept

Retrieves a score pool by ID.

Parameters
scorePoolId

The ID of the pool to find.

Returns

Pointer to the ScorePool, or nullptr if not found.

Definition at line 92 of file ScorePoolManager.ixx.

93
94 const auto it = std::ranges::find_if(pools_, [&scorePoolId](const auto& scorePool) -> bool {
95 return scorePool.scorePoolId() == scorePoolId;
96 });
97
98 if (it == pools_.end()) {
99 return nullptr;
100 }
101
102 return &*it;
103 }

Reference scorePool.

Referenced by addScorePool and scorePool.

submit()

bool helios::engine::mechanics::scoring::ScorePoolManager::submit (UpdateScoreCommand updateScoreCommand)
inline noexcept

Submits a score update command for processing.

Parameters
updateScoreCommand

The command containing score context.

Returns

True if the command was accepted.

Definition at line 141 of file ScorePoolManager.ixx.

141 bool submit(
142 UpdateScoreCommand updateScoreCommand
143 ) noexcept {
144 scores_.push_back(std::move(updateScoreCommand).scoreContext());
145
146 return true;
147 };

Private Member Attributes

pools_

std::vector<ScorePool> helios::engine::mechanics::scoring::ScorePoolManager::pools_

Collection of score pools managed by this manager.

Definition at line 56 of file ScorePoolManager.ixx.

56 std::vector<ScorePool> pools_;

scores_

std::vector<helios::engine::mechanics::scoring::types::ScoreValueContext> helios::engine::mechanics::scoring::ScorePoolManager::scores_

Pending score contexts to be processed on flush.

Definition at line 61 of file ScorePoolManager.ixx.

61 std::vector<helios::engine::mechanics::scoring::types::ScoreValueContext> scores_;

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


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.