Skip to main content

ComponentOpsRegistry Class

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

Declaration

class helios::engine::ecs::ComponentOpsRegistry { ... }

Public Static Functions Index

static voidsetOps (const helios::engine::ecs::types::ComponentTypeId typeId, const ComponentOps &ops)

Registers ComponentOps for a component type. More...

static const ComponentOps &ops (const helios::engine::ecs::types::ComponentTypeId typeId)

Retrieves ComponentOps for a component type. More...

Private Static Attributes Index

static std::vector< ComponentOps >operations_

Type-indexed storage for ComponentOps. More...

static constexpr ComponentOpsemptyOps_ {}

Empty ops returned for unregistered types. More...

Description

Global registry for component lifecycle function pointers.

`ComponentOpsRegistry` provides O(1) lookup of `ComponentOps` by `ComponentTypeId`. It uses a type-indexed vector where the index corresponds to the component type's unique identifier.

## Usage

```cpp // Registration (done by ComponentReflector) ComponentOpsRegistry::setOps(typeId, ops);

// Lookup at runtime const auto& ops = ComponentOpsRegistry::ops(typeId); if (ops.onAcquire) { ops.onAcquire(rawComponent); } ```

info

Not thread-safe. All registration must complete before concurrent access.

See Also

ComponentOps

See Also

ComponentReflector

Definition at line 44 of file ComponentOpsRegistry.ixx.

Public Static Functions

ops()

const ComponentOps & helios::engine::ecs::ComponentOpsRegistry::ops (const helios::engine::ecs::types::ComponentTypeId typeId)
inline static

setOps()

void helios::engine::ecs::ComponentOpsRegistry::setOps (const helios::engine::ecs::types::ComponentTypeId typeId, const ComponentOps & ops)
inline static

Registers ComponentOps for a component type.

Auto-resizes the internal vector if necessary.

Parameters
typeId

The unique identifier for the component type.

ops

The lifecycle function pointers to register.

Definition at line 66 of file ComponentOpsRegistry.ixx.

67
68 if (typeId.value() >= operations_.size()) {
69 operations_.resize(typeId.value() + 1);
70 }
71
72 operations_[typeId.value()] = ops;
73 }

References ops and helios::engine::ecs::types::ComponentTypeId::value.

Referenced by helios::engine::ecs::ComponentReflector::registerType.

Private Static Attributes

emptyOps_

ComponentOps helios::engine::ecs::ComponentOpsRegistry::emptyOps_ {}
constexpr static

Empty ops returned for unregistered types.

Definition at line 54 of file ComponentOpsRegistry.ixx.

54 inline static constexpr ComponentOps emptyOps_{};

operations_

std::vector<ComponentOps> helios::engine::ecs::ComponentOpsRegistry::operations_
static

Type-indexed storage for ComponentOps.

Definition at line 49 of file ComponentOpsRegistry.ixx.

49 inline static std::vector<ComponentOps> operations_;

The documentation for this class was generated from the following file:


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.