Skip to main content

ComponentOps.ixx File

Function pointer structure for type-erased component lifecycle callbacks. More...

Included Headers

Namespaces Index

namespacehelios
namespaceengine

Main engine module aggregating core infrastructure and game systems. More...

namespaceecs

Core Entity-Component-System architecture. More...

Classes Index

structComponentOps

Container for type-erased component lifecycle function pointers. More...

Description

Function pointer structure for type-erased component lifecycle callbacks.

File Listing

The file content with the documentation metadata removed is:

1/**
2 * @file ComponentOps.ixx
3 * @brief Function pointer structure for type-erased component lifecycle callbacks.
4 */
5module;
6
7export module helios.engine.ecs.ComponentOps;
8
9import helios.engine.ecs.EntityHandle;
10
11export namespace helios::engine::ecs {
12
13 /**
14 * @brief Container for type-erased component lifecycle function pointers.
15 *
16 * @details `ComponentOps` enables runtime invocation of component lifecycle
17 * hooks without knowing the concrete component type. Function pointers are
18 * set during type registration via `ComponentReflector::registerType<T>()`.
19 *
20 * ## Type Erasure Pattern
21 *
22 * ```cpp
23 * // At registration (type known):
24 * ComponentOps ops{
25 * .onAcquire = [](void* ptr) {
26 * static_cast<HealthComponent*>(ptr)->onAcquire();
27 * }
28 * };
29 *
30 * // At runtime (type erased):
31 * if (ops.onAcquire) {
32 * ops.onAcquire(rawComponent);
33 * }
34 * ```
35 *
36 * @see ComponentOpsRegistry
37 * @see ComponentReflector
38 * @see Traits
39 */
40 struct ComponentOps {
41
42 /**
43 * @brief Function signature for pool acquisition callback.
44 *
45 * @param ptr Raw pointer to the component instance.
46 */
47 using OnAcquireFn = void(*)(void*);
48
49 /**
50 * @brief Function signature for pool release callback.
51 *
52 * @param ptr Raw pointer to the component instance.
53 */
54 using OnReleaseFn = void(*)(void*);
55
56 /**
57 * @brief Function signature for removal interception callback.
58 *
59 * @param ptr Raw pointer to the component instance.
60 *
61 * @return `true` to allow removal, `false` to prevent it.
62 */
63 using OnRemoveFn = bool(*)(void*);
64
65 /**
66 * @brief Function signature for component enable callback.
67 *
68 * @param ptr Raw pointer to the component instance.
69 */
70 using EnableFn = void(*)(void*);
71
72 /**
73 * @brief Function signature for component disable callback.
74 *
75 * @param ptr Raw pointer to the component instance.
76 */
77 using DisableFn = void(*)(void*);
78
79 /**
80 * @brief Function signature for component cloning.
81 *
82 * @param manager Raw pointer to the EntityManager.
83 * @param source Raw pointer to the source component.
84 * @param target Pointer to the target EntityHandle.
85 *
86 * @return Raw pointer to the newly created component.
87 */
88 using CloneFn = void*(*)(void* manager, const void* source, const EntityHandle* target);
89
90 /**
91 * @brief Function signature for GameObject activation callback.
92 *
93 * @param ptr Raw pointer to the component instance.
94 */
95 using OnActivateFn = void(*)(void*);
96
97 /**
98 * @brief Function signature for GameObject deactivation callback.
99 *
100 * @param ptr Raw pointer to the component instance.
101 */
102 using OnDeactivateFn = void(*)(void*);
103
104 /**
105 * @brief Called when entity is acquired from an object pool.
106 */
108
109 /**
110 * @brief Called when entity is released back to an object pool.
111 */
113
114 /**
115 * @brief Called before component removal. Return `false` to block.
116 */
118
119 /**
120 * @brief Called to enable the component.
121 */
122 EnableFn enable = nullptr;
123
124 /**
125 * @brief Called to disable the component.
126 */
127 DisableFn disable = nullptr;
128
129 /**
130 * @brief Called to clone the component to a target entity.
131 */
132 CloneFn clone = nullptr;
133
134 /**
135 * @brief Called when the owning GameObject is activated.
136 */
138
139 /**
140 * @brief Called when the owning GameObject is deactivated.
141 */
143
144
145 };
146
147}

Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.