Skip to main content

ComponentOpsRegistry.ixx File

Global registry mapping ComponentTypeId to ComponentOps. More...

Included Headers

Namespaces Index

namespacehelios
namespaceecs

Classes Index

classComponentOpsRegistry<THandle>

Global registry for component lifecycle function pointers. More...

Description

Global registry mapping ComponentTypeId to ComponentOps.

File Listing

The file content with the documentation metadata removed is:

1
5module;
6
7#include <vector>
8
9export module helios.ecs.ComponentOpsRegistry;
10
11import helios.ecs.types.EntityHandle;
12import helios.ecs.types.ComponentOps;
13import helios.ecs.types.ComponentTypeId;
14
15using namespace helios::ecs::types;
16export namespace helios::ecs {
17
53 template<typename THandle>
55
59 inline static std::vector<ComponentOps> operations_;
60
64 inline static constexpr ComponentOps emptyOps_{};
65
66 public:
67
69
70
79 static void setOps(const ComponentTypeId_type typeId, const ComponentOps& ops) {
80
81 if (typeId.value() >= operations_.size()) {
82 operations_.resize(typeId.value() + 1);
83 }
84
85 operations_[typeId.value()] = ops;
86 }
87
95 static const ComponentOps& ops(const ComponentTypeId_type typeId) {
96
97 if (typeId.value() >= operations_.size()) {
98 return emptyOps_;
99 }
100
101 return operations_[typeId.value()];
102 }
103
104 };
105
106}

Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.9.8.