ComponentReflector Class Template
Generates and registers ComponentOps for a component type. More...
Declaration
Public Member Typedefs Index
template <typename TEntityManager> | |
| using | Handle_type = TEntityManager::Handle_type |
Public Static Functions Index
template <typename T> | |
| static void | registerType () |
|
Registers a component type with the reflection system. More... | |
Description
Generates and registers ComponentOps for a component type.
`ComponentReflector` uses compile-time trait detection to generate appropriate function pointers for each lifecycle hook that a component type implements. This enables zero-overhead conditional invocation at runtime.
## Template Parameters
The reflector is templated on `THandle` and `TEntityManager` so that the generated clone function can cast the type-erased `void*` pointers back to the concrete types of the target domain. This also ensures that `ComponentOpsRegistry<THandle>` stores the ops in the correct per-domain registry.
## Usage
```cpp // Register a component type for the game domain ComponentReflector<GameHandle, GameEM>::registerType<HealthComponent>();
// Or use the module registry pattern inline void registerComponents() { using R = ComponentReflector<GameHandle, GameEM>; R::registerType<CollisionComponent>(); R::registerType<AabbColliderComponent>(); } ```
## Trait Detection
The reflector checks for the following traits at compile time:
- `HasOnAcquire` - `onAcquire()` method
- `HasOnRelease` - `onRelease()` method
- `HasOnRemove` - `onRemove()` method returning bool
- `HasToggleable` - `enable()` and `disable()` methods
- `HasClone` - `onClone(const T&)` method
- `HasActivatable` - `onActivate()` and `onDeactivate()` methods
- Template Parameters
-
THandle The concrete `EntityHandle<TStrongId>` specialisation. Used to scope `ComponentTypeId` and `ComponentOpsRegistry`.
TEntityManager The concrete `EntityManager` specialisation. Used by the clone function to emplace components on the target entity.
- See Also
- See Also
- See Also
Traits
Definition at line 75 of file ComponentReflector.ixx.
Public Member Typedefs
Handle_type
|
Definition at line 80 of file ComponentReflector.ixx.
Public Static Functions
registerType()
| inline static |
Registers a component type with the reflection system.
Generates `ComponentOps` function pointers based on which lifecycle hooks the type implements. Uses `if constexpr` for zero-overhead when hooks are not present.
- Template Parameters
-
T The component type to register. Must be copy-constructible for cloning support.
Definition at line 93 of file ComponentReflector.ixx.
Reference helios::ecs::ComponentOpsRegistry< THandle >::setOps.
The documentation for this class was generated from the following file:
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.