Skip to main content

ComponentTypeId.ixx File

Compile-time type identifier for component types. More...

Included Headers

#include <functional> #include <cstddef> #include <helios.ecs.types.TypeDefs> #include <helios.ecs.TypeIndexer>

Namespaces Index

namespacehelios
namespaceecs
namespacetypes

Classes Index

classComponentTypeId<THandle>

Unique type identifier for component types, scoped per domain. More...

structhash<helios::ecs::types::ComponentTypeId< THandle >>

std::hash specialization for ComponentTypeId. More...

Description

Compile-time type identifier for component types.

Provides a unique, compile-time generated ID for each component type, enabling O(1) direct indexing into the component storage vector within GameObject.

File Listing

The file content with the documentation metadata removed is:

1
8module;
9
10#include <functional>
11#include <cstddef>
12
13export module helios.ecs.types.ComponentTypeId;
14
15import helios.ecs.TypeIndexer;
16import helios.ecs.types.TypeDefs;
17
18export namespace helios::ecs::types {
19
52 template<typename THandle>
54
58 size_t id_{0};
59
60 public:
61
72 explicit ComponentTypeId(const size_t id) : id_(id) {}
73
80
86 [[nodiscard]] size_t value() const noexcept {
87 return id_;
88 }
89
100 template <typename T>
101 [[nodiscard]] static ComponentTypeId<THandle> id() {
102 static const size_t tid = helios::ecs::TypeIndexer<THandle>::template typeIndex<T>();
103 return ComponentTypeId(tid);
104 }
105
106 friend constexpr bool operator==(ComponentTypeId, ComponentTypeId) noexcept = default;
107 };
108
109
110}
111
112
118template<typename THandle>
119struct std::hash<helios::ecs::types::ComponentTypeId<THandle>> {
120 std::size_t operator()(const helios::ecs::types::ComponentTypeId<THandle>& id) const noexcept {
121 return id.value();
122 }
123
124};

Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.9.8.