Skip to main content

ScoreTypeId.ixx File

Strongly-typed identifier for score types. More...

Included Headers

#include <functional> #include <helios.core.types> #include <helios.core.data.TypeIndexer>

Namespaces Index

namespacehelios
namespaceengine

Main engine module aggregating core infrastructure and game systems. More...

namespacemechanics

High-level gameplay systems and components for game logic. More...

namespacescoring

Score management and tracking system for game mechanics. More...

namespacetypes

Score data types and value classes. More...

Classes Index

classScoreTypeId

Strongly-typed identifier for score types. More...

structhelios_engine_common_tag_ScoreTypes

Tag type for the TypeIndexer domain. More...

structhash<helios::engine::mechanics::scoring::types::ScoreTypeId>

std::hash specialization for ScoreTypeId. More...

Description

Strongly-typed identifier for score types.

File Listing

The file content with the documentation metadata removed is:

1/**
2 * @file ScoreTypeId.ixx
3 * @brief Strongly-typed identifier for score types.
4 */
5module;
6
7#include <functional>
8
9export module helios.engine.mechanics.scoring.types.ScoreTypeId;
10
11import helios.core.data.TypeIndexer;
12import helios.core.types;
13
15
16 /**
17 * @brief Strongly-typed identifier for score types.
18 *
19 * Uses TypeIndexer to generate unique, monotonically increasing IDs for each
20 * score type at compile time. Suitable for use as array indices.
21 */
22 class ScoreTypeId {
23
24 /**
25 * @brief Tag type for the TypeIndexer domain.
26 */
27 struct helios_engine_common_tag_ScoreTypes{};
28
29 using ScoreType = helios_engine_common_tag_ScoreTypes;
30
31 /**
32 * @brief The underlying ID value.
33 */
34 size_t id_{0};
35
36 /**
37 * @brief Private constructor for internal use.
38 *
39 * @param id The type ID value.
40 */
41 explicit ScoreTypeId(const size_t id) : id_(id) {}
42
43 public:
44
45 /**
46 * @brief Constructs an uninitialized ScoreTypeId.
47 *
48 * @param helios::core::types::no_init_t Tag to indicate no initialization.
49 */
51
52 /**
53 * @brief Returns the underlying ID value.
54 *
55 * @return The numeric type ID, suitable for use as an array index.
56 */
57 [[nodiscard]] size_t value() const noexcept {
58 return id_;
59 }
60
61 /**
62 * @brief Gets the ScoreTypeId for a specific component type.
63 *
64 * @details Uses TypeIndexer to generate a unique, monotonically increasing ID
65 * for each component type. The ID is generated once per type and cached.
66 *
67 * @tparam T The component type. Must be a concrete type (not abstract).
68 *
69 * @return The unique ScoreTypeId for type T.
70 */
71 template <typename T>
72 [[nodiscard]] static ScoreTypeId id() {
74 return ScoreTypeId(tid);
75 }
76
77 friend constexpr bool operator==(ScoreTypeId, ScoreTypeId) noexcept = default;
78 };
79
80
81}
82
83
84/**
85 * @brief std::hash specialization for ScoreTypeId.
86 *
87 * @details Enables use of ScoreTypeId as a key in unordered containers.
88 */
89template<>
90struct std::hash<helios::engine::mechanics::scoring::types::ScoreTypeId> {
92 return id.value();
93 }
94
95};

Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.