Skip to main content

types.ixx File

Core type definitions and tag types for the helios engine. More...

Included Headers

#include <cstdint> #include <limits>

Namespaces Index

namespacehelios
namespacecore

Core utilities shared across the helios engine. More...

namespacetypes

Classes Index

structno_init_t

Tag type used to indicate skipping default initialization. More...

Description

Core type definitions and tag types for the helios engine.

File Listing

The file content with the documentation metadata removed is:

1/**
2 * @file types.ixx
3 * @brief Core type definitions and tag types for the helios engine.
4 */
5module;
6
7#include <cstdint>
8#include <limits>
9
10export module helios.core.types;
11
12
13export namespace helios::core::types {
14
15 /**
16 * @brief Tag type used to indicate skipping default initialization.
17 *
18 * @details `no_init_t` is a tag type that signals to constructors or
19 * factory functions that default initialization should be skipped.
20 * This is useful for performance-critical code paths where objects
21 * will be immediately overwritten or initialized manually.
22 *
23 * ## Usage
24 *
25 * Pass `no_init` as a constructor argument to request uninitialized storage:
26 *
27 * ```cpp
28 * import helios.util.Guid;
29 * import helios.core.types;
30 *
31 * // Generate a new unique Guid
32 * auto id = helios::util::Guid::generate();
33 *
34 * // Declare uninitialized Guid for later assignment
35 * helios::util::Guid deferredId{helios::core::types::no_init};
36 *
37 * // Assign later
38 * deferredId = helios::util::Guid::generate();
39 * ```
40 *
41 * @note Objects constructed with `no_init` are in an indeterminate state.
42 * Reading from them before assignment is undefined behavior.
43 *
44 * @see no_init
45 * @see helios::util::Guid
46 */
47 struct no_init_t{};
48
49 /**
50 * @brief Tag constant for requesting uninitialized construction.
51 *
52 * @details This is a convenience instance of `no_init_t` that can be
53 * passed to constructors supporting uninitialized construction.
54 *
55 * ```cpp
56 * helios::util::Guid id{helios::core::types::no_init};
57 * ```
58 *
59 * @see no_init_t
60 * @see helios::util::Guid
61 */
62 inline constexpr no_init_t no_init;
63
64 /**
65 * @brief Underlying integer type for all strong identifiers.
66 *
67 * @details `StrongId_t` is the common numeric representation used by
68 * `StrongId<Tag>` and related lookup structures (e.g., `EntityRegistry`,
69 * `LinearLookupStrategy`, `HashedLookupStrategy`). Centralising the
70 * typedef ensures a consistent width across the entire identifier
71 * subsystem.
72 *
73 * @see helios::core::data::StrongId
74 * @see EntityId
75 * @see VersionId
76 */
77 using StrongId_t = uint32_t;
78
79 /**
80 * @brief Version number for detecting stale entity references.
81 *
82 * Each entity slot in an EntityPool has an associated version that is
83 * incremented when the entity is removed. EntityHandles store both the
84 * EntityId and VersionId, allowing the pool to detect when a handle
85 * refers to a recycled slot.
86 *
87 * A valid version starts at 1 (uninitialized handles have version 0).
88 *
89 * @see EntityHandle
90 * @see EntityId
91 * @see EntityPool
92 */
93 using VersionId = uint32_t;
94
95 /**
96 * @brief Unique identifier for an entity within an EntityPool.
97 *
98 * Used as the index into the sparse array of an EntityPool. Combined with
99 * a VersionId in an EntityHandle, it enables safe entity references that
100 * detect stale handles after entity removal.
101 *
102 * @see EntityHandle
103 * @see VersionId
104 * @see EntityPool
105 */
106 using EntityId = uint32_t;
107
108
109 /**
110 * @brief Sentinel value indicating an invalid or removed sparse index.
111 *
112 * Used in sparse-set data structures (e.g., EntityPool, GameObjectPool) to mark
113 * slots that do not contain valid entity references. When a slot contains this
114 * value, the corresponding entity has been removed or was never assigned.
115 *
116 * @see EntityPool
117 * @see GameObjectPool
118 */
119 constexpr size_t EntityTombstone = std::numeric_limits<size_t>::max();
120}

Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.