ScorePool Class
Container that accumulates scores by type within a pool. More...
Declaration
Public Constructors Index
| ScorePool (const helios::engine::mechanics::scoring::types::ScorePoolId scorePoolId) | |
Public Member Functions Index
| helios::engine::mechanics::scoring::types::ScorePoolId | id () const noexcept |
|
Returns the pool's unique identifier. More... | |
| void | addScore (const helios::engine::mechanics::scoring::types::ScoreValueContext &scoreContext) |
|
Adds a score from the given context. More... | |
| void | reset () noexcept |
|
Resets all scores to zero. More... | |
| double | totalScore () const noexcept |
|
Returns the running total of all scores. More... | |
| helios::engine::mechanics::scoring::types::ScorePoolId | scorePoolId () const noexcept |
|
Returns the pool's unique identifier. More... | |
| helios::engine::mechanics::scoring::types::ScorePoolRevision | revision () const noexcept |
|
Returns the current revision number. More... | |
| helios::engine::mechanics::scoring::ScorePoolSnapshot | snapshot () const noexcept |
|
Returns a snapshot of the current pool state. More... | |
| void | updateMaxScore () noexcept |
|
Recalculates the high score from the current total. More... | |
| double | maxScore () const noexcept |
|
Returns the highest total score observed. More... | |
| helios::engine::mechanics::scoring::types::ScorePoolRevision | maxScoreRevision () const noexcept |
|
Returns the revision counter for maxScore changes. More... | |
| helios::engine::mechanics::scoring::MaxScorePoolSnapshot | maxScoreSnapshot () const noexcept |
|
Returns a snapshot of the current high score state. More... | |
Private Member Functions Index
| void | addTotal (const double total) noexcept |
|
Adds to the running total. More... | |
| void | setTotal (const double total) noexcept |
|
Sets the running total directly. More... | |
Private Member Attributes Index
| helios::engine::mechanics::scoring::types::ScorePoolId | scorePoolId_ |
|
Unique identifier for this score pool. More... | |
| std::vector< double > | scores_ |
|
Per-type score values indexed by ScoreTypeId. More... | |
| double | totalScore_ {} |
|
Running total of all scores in this pool. More... | |
| double | maxScore_ {} |
|
The highest total score observed so far. More... | |
| helios::engine::mechanics::scoring::types::ScorePoolRevision | maxScoreRevision_ {} |
|
Revision counter for maxScore changes. More... | |
| helios::engine::mechanics::scoring::types::ScorePoolRevision | revision_ {} |
Description
Container that accumulates scores by type within a pool.
ScorePool maintains a collection of scores indexed by ScoreTypeId, along with a running total. It tracks changes via a revision number that is incremented whenever a score value changes, enabling efficient change detection by observers.
ScorePools are managed by ScorePoolManager, which handles command processing and pool lifecycle.
- See Also
- See Also
- See Also
ScoreValueContext
Definition at line 39 of file ScorePool.ixx.
Public Constructors
ScorePool()
| inline explicit |
Constructs a ScorePool with the given ID.
- Parameters
-
scorePoolId Unique identifier for this pool.
Definition at line 96 of file ScorePool.ixx.
Reference scorePoolId.
Public Member Functions
addScore()
| inline |
Adds a score from the given context.
Updates both the per-type score and the running total.
- Parameters
-
scoreContext Context containing type ID and value.
Definition at line 115 of file ScorePool.ixx.
References id, helios::engine::mechanics::scoring::types::ScoreValueContext::scoreTypeId, updateMaxScore, helios::engine::mechanics::scoring::types::ScoreTypeId::value and helios::engine::mechanics::scoring::types::ScoreValueContext::value.
id()
| inline nodiscard noexcept |
Returns the pool's unique identifier.
- Returns
The ScorePoolId.
Definition at line 104 of file ScorePool.ixx.
Referenced by addScore.
maxScore()
| inline nodiscard noexcept |
Returns the highest total score observed.
- Returns
The maximum score value.
Definition at line 204 of file ScorePool.ixx.
maxScoreRevision()
| inline nodiscard noexcept |
Returns the revision counter for maxScore changes.
- Returns
The current max score revision.
Definition at line 213 of file ScorePool.ixx.
maxScoreSnapshot()
| inline nodiscard noexcept |
Returns a snapshot of the current high score state.
- Returns
A MaxScorePoolSnapshot with current values.
- See Also
Definition at line 224 of file ScorePool.ixx.
reset()
| inline noexcept |
Resets all scores to zero.
Definition at line 135 of file ScorePool.ixx.
revision()
| inline nodiscard noexcept |
Returns the current revision number.
The revision is incremented whenever a score value changes. Used by observers to detect changes without polling values.
- Returns
The current ScorePoolRevision.
Definition at line 168 of file ScorePool.ixx.
scorePoolId()
| inline nodiscard noexcept |
Returns the pool's unique identifier.
- Returns
The ScorePoolId.
Definition at line 156 of file ScorePool.ixx.
Referenced by ScorePool.
snapshot()
| inline nodiscard noexcept |
Returns a snapshot of the current pool state.
The snapshot contains the pool ID, total score, and current revision. Useful for observers and UI binding.
- Returns
A ScorePoolSnapshot with current values.
Definition at line 180 of file ScorePool.ixx.
totalScore()
| inline nodiscard noexcept |
Returns the running total of all scores.
- Returns
The total score value.
Definition at line 147 of file ScorePool.ixx.
updateMaxScore()
| inline noexcept |
Recalculates the high score from the current total.
Increments maxScoreRevision if the high score changes. Called automatically by addScore().
Definition at line 191 of file ScorePool.ixx.
Referenced by addScore.
Private Member Functions
addTotal()
| inline noexcept |
Adds to the running total.
- Parameters
-
total Value to add.
Definition at line 71 of file ScorePool.ixx.
setTotal()
| inline noexcept |
Sets the running total directly.
- Parameters
-
total New total value.
Definition at line 80 of file ScorePool.ixx.
Private Member Attributes
maxScore_
|
The highest total score observed so far.
Definition at line 59 of file ScorePool.ixx.
maxScoreRevision_
|
Revision counter for maxScore changes.
Definition at line 64 of file ScorePool.ixx.
revision_
|
The current revision of this ScorePool.
Definition at line 87 of file ScorePool.ixx.
scorePoolId_
|
Unique identifier for this score pool.
Definition at line 44 of file ScorePool.ixx.
scores_
|
Per-type score values indexed by ScoreTypeId.
Definition at line 49 of file ScorePool.ixx.
totalScore_
|
Running total of all scores in this pool.
Definition at line 54 of file ScorePool.ixx.
The documentation for this class was generated from the following file:
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.