ComponentOpsRegistry Class Template
Global registry for component lifecycle function pointers. More...
Declaration
Public Member Typedefs Index
template <typename THandle> | |
| using | ComponentTypeId_type = ComponentTypeId< THandle > |
Public Static Functions Index
template <typename THandle> | |
| static void | setOps (const ComponentTypeId_type typeId, const ComponentOps &ops) |
|
Registers ComponentOps for a component type. More... | |
template <typename THandle> | |
| static const ComponentOps & | ops (const ComponentTypeId_type typeId) |
|
Retrieves ComponentOps for a component type. More... | |
Private Static Attributes Index
template <typename THandle> | |
| static std::vector< ComponentOps > | operations_ |
|
Type-indexed storage for ComponentOps. More... | |
template <typename THandle> | |
| static constexpr ComponentOps | emptyOps_ {} |
|
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.
## Domain Scoping
The registry is templated on `THandle` so that each domain (identified by its `EntityHandle<TStrongId>` specialisation) has its own independent, `inline static` ops storage. This prevents lifecycle hooks registered for one domain from interfering with another.
## Usage
```cpp // Registration (done by ComponentReflector<THandle, TEM>) ComponentOpsRegistry<GameHandle>::setOps(typeId, ops);
// Lookup at runtime const auto& ops = ComponentOpsRegistry<GameHandle>::ops(typeId); if (ops.onAcquire) { ops.onAcquire(rawComponent); } ```
Not thread-safe. All registration must complete before concurrent access.
- Template Parameters
-
THandle The concrete `EntityHandle<TStrongId>` specialisation scoping this registry instance.
- See Also
- See Also
Definition at line 54 of file ComponentOpsRegistry.ixx.
Public Member Typedefs
ComponentTypeId_type
|
Definition at line 68 of file ComponentOpsRegistry.ixx.
Public Static Functions
ops()
| inline static |
Retrieves ComponentOps for a component type.
- Parameters
-
typeId The unique identifier for the component type.
- Returns
Reference to the registered ComponentOps, or empty ops if not registered.
Definition at line 95 of file ComponentOpsRegistry.ixx.
setOps()
| 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 79 of file ComponentOpsRegistry.ixx.
Referenced by helios::ecs::ComponentReflector< TEntityManager >::registerType.
Private Static Attributes
emptyOps_
| constexpr static |
Empty ops returned for unregistered types.
Definition at line 64 of file ComponentOpsRegistry.ixx.
operations_
| static |
Type-indexed storage for ComponentOps.
Definition at line 59 of file ComponentOpsRegistry.ixx.
The documentation for this class was generated from the following file:
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.