31template <
typename T,
typename ElemType =
void>
33 opaque(flecs::world_t *w =
nullptr) :
world(w) {
48 reinterpret_cast<decltype(
49 this-
>desc.type.serialize)>(func);
56 reinterpret_cast<decltype(
57 this-
>desc.type.assign_bool)>(func);
64 reinterpret_cast<decltype(
65 this-
>desc.type.assign_char)>(func);
70 opaque&
assign_int(
void (*func)(T *dst, int64_t value)) {
72 reinterpret_cast<decltype(
73 this-
>desc.type.assign_int)>(func);
80 reinterpret_cast<decltype(
81 this-
>desc.type.assign_uint)>(func);
88 reinterpret_cast<decltype(
89 this-
>desc.type.assign_float)>(func);
96 reinterpret_cast<decltype(
97 this-
>desc.type.assign_string)>(func);
106 reinterpret_cast<decltype(
107 this-
>desc.type.assign_entity)>(func);
116 reinterpret_cast<decltype(
117 this-
>desc.type.assign_id)>(func);
124 reinterpret_cast<decltype(
125 this-
>desc.type.assign_null)>(func);
130 opaque&
clear(
void (*func)(T *dst)) {
131 this->desc.type.
clear =
132 reinterpret_cast<decltype(
133 this-
>desc.type.clear)>(func);
140 reinterpret_cast<decltype(
141 this-
>desc.type.ensure_element)>(func);
148 reinterpret_cast<decltype(
149 this-
>desc.type.ensure_member)>(func);
154 opaque&
count(
size_t (*func)(
const T *dst)) {
155 this->desc.type.
count =
156 reinterpret_cast<decltype(
157 this-
>desc.type.count)>(func);
164 reinterpret_cast<decltype(
165 this-
>desc.type.resize)>(func);
ecs_id_t ecs_entity_t
An entity identifier.
struct ecs_world_t ecs_world_t
A world is the container for all ECS data and supporting features.
uint64_t ecs_id_t
Ids are the things that can be added to an entity.
Used with ecs_opaque_init().
Type safe interface for opaque types.
opaque & assign_char(void(*func)(T *dst, char value))
Assign char value.
opaque & assign_uint(void(*func)(T *dst, uint64_t value))
Assign unsigned int value.
opaque & assign_string(void(*func)(T *dst, const char *value))
Assign string value.
opaque & assign_bool(void(*func)(T *dst, bool value))
Assign bool value.
opaque & as_type(flecs::id_t func)
Type that describes the type kind/structure of the opaque type.
opaque & assign_float(void(*func)(T *dst, double value))
Assign float value.
opaque & assign_entity(void(*func)(T *dst, ecs_world_t *world, ecs_entity_t entity))
Assign entity value.
flecs::world_t * world
Opaque type descriptor.
opaque & resize(void(*func)(T *dst, size_t count))
Resize to number of elements.
opaque & assign_null(void(*func)(T *dst))
Assign null value.
opaque & assign_id(void(*func)(T *dst, ecs_world_t *world, ecs_id_t id))
Assign (component) id value.
opaque & ensure_member(void *(*func)(T *dst, const char *member))
Ensure & get element.
opaque & clear(void(*func)(T *dst))
Clear collection elements.
opaque & ensure_element(ElemType *(*func)(T *dst, size_t elem))
Ensure & get collection element.
opaque & serialize(flecs::serialize< T > func)
Serialize function.
opaque & count(size_t(*func)(const T *dst))
Return number of elements.
opaque & assign_int(void(*func)(T *dst, int64_t value))
Assign int value.