Skip to main content

StateTypeId.ixx File

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...

namespacestate

Generic, template-based state management system. More...

namespacetypes

Type definitions for state transitions. More...

Classes Index

classStateTypeId
structhelios_engine_common_tag_StateTypes

Tag type for the TypeIndexer domain. More...

structhash<helios::engine::state::types::StateTypeId>

std::hash specialization for StateTypeId. More...

File Listing

The file content with the documentation metadata removed is:

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

Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.