Skip to content
Flecs v4.2
Getting & Setting

Macros

#define ecs_insert(world, ...)
 Insert a new entity with a list of component values.
#define ecs_set_ptr(world, entity, component, ptr)
 Set a component using a pointer.
#define ecs_set(world, entity, component, ...)
 Set a component value.
#define ecs_set_pair(world, subject, First, second, ...)
 Set the first element of a pair.
#define ecs_set_pair_second(world, subject, first, Second, ...)
 Set the second element of a pair.
#define ecs_set_override(world, entity, T, ...)
 Set a component with auto-override.
#define ecs_emplace(world, entity, T, is_new)
 Emplace a component.
#define ecs_emplace_pair(world, entity, First, second, is_new)
 Emplace the first element of a pair.
#define ecs_get(world, entity, T)
 Get a component.
#define ecs_get_pair(world, subject, First, second)
 Get the first element of a pair.
#define ecs_get_pair_second(world, subject, first, Second)
 Get the second element of a pair.
#define ecs_get_mut(world, entity, T)
 Get a mutable pointer to a component.
#define ecs_get_mut(world, entity, T)
 Get a mutable pointer to a component.
#define ecs_get_mut_pair(world, subject, First, second)
 Get a mutable pointer to the first element of a pair.
#define ecs_get_mut_pair_second(world, subject, first, Second)
 Get a mutable pointer to the second element of a pair.
#define ecs_ensure(world, entity, T)
 Ensure entity has a component, return mutable pointer.
#define ecs_ensure_pair(world, subject, First, second)
 Ensure entity has the first element of a pair, return mutable pointer.
#define ecs_ensure_pair_second(world, subject, first, Second)
 Ensure entity has the second element of a pair, return mutable pointer.
#define ecs_modified(world, entity, component)
 Signal that a component has been modified.
#define ecs_modified_pair(world, subject, first, second)
 Signal that a pair has been modified.
#define ecs_ref_init(world, entity, T)
 Initialize a ref for a component.
#define ecs_ref_get(world, ref, T)
 Get a component from a ref.
#define ecs_ref_modified(world, ref, T)
 Signal that the component of a ref has been modified.

Detailed Description

Macro Definition Documentation

◆ ecs_emplace

#define ecs_emplace ( world,
entity,
T,
is_new )
Value:
(ECS_CAST(T*, ecs_emplace_id(world, entity, ecs_id(T), sizeof(T), is_new)))
FLECS_API const ecs_entity_t ecs_id(EcsDocDescription)
Component ID for EcsDocDescription.
void * ecs_emplace_id(ecs_world_t *world, ecs_entity_t entity, ecs_id_t component, size_t size, bool *is_new)
Emplace a component.

Emplace a component.

Definition at line 334 of file flecs_c.h.

◆ ecs_emplace_pair

#define ecs_emplace_pair ( world,
entity,
First,
second,
is_new )
Value:
(ECS_CAST(First*, ecs_emplace_id(world, entity, ecs_pair_t(First, second), sizeof(First), is_new)))

Emplace the first element of a pair.

Definition at line 338 of file flecs_c.h.

◆ ecs_ensure

#define ecs_ensure ( world,
entity,
T )
Value:
(ECS_CAST(T*, ecs_ensure_id(world, entity, ecs_id(T), sizeof(T))))
void * ecs_ensure_id(ecs_world_t *world, ecs_entity_t entity, ecs_id_t component, size_t size)
Ensure an entity has a component and return a pointer.

Ensure entity has a component, return mutable pointer.

Definition at line 374 of file flecs_c.h.

◆ ecs_ensure_pair

#define ecs_ensure_pair ( world,
subject,
First,
second )
Value:
(ECS_CAST(First*, ecs_ensure_id(world, subject,\
ecs_pair(ecs_id(First), second), sizeof(First))))

Ensure entity has the first element of a pair, return mutable pointer.

Definition at line 378 of file flecs_c.h.

◆ ecs_ensure_pair_second

#define ecs_ensure_pair_second ( world,
subject,
first,
Second )
Value:
(ECS_CAST(Second*, ecs_ensure_id(world, subject,\
ecs_pair(first, ecs_id(Second)), sizeof(Second))))

Ensure entity has the second element of a pair, return mutable pointer.

Definition at line 383 of file flecs_c.h.

◆ ecs_get

#define ecs_get ( world,
entity,
T )
Value:
(ECS_CAST(const T*, ecs_get_id(world, entity, ecs_id(T))))
const void * ecs_get_id(const ecs_world_t *world, ecs_entity_t entity, ecs_id_t component)
Get an immutable pointer to a component.

Get a component.

Definition at line 342 of file flecs_c.h.

◆ ecs_get_mut [1/2]

#define ecs_get_mut ( world,
entity,
T )
Value:
(ECS_CAST(T*, ecs_get_mut_id(world, entity, ecs_id(T))))
void * ecs_get_mut_id(const ecs_world_t *world, ecs_entity_t entity, ecs_id_t component)
Get a mutable pointer to a component.

Get a mutable pointer to a component.

Definition at line 356 of file flecs_c.h.

◆ ecs_get_mut [2/2]

#define ecs_get_mut ( world,
entity,
T )
Value:
(ECS_CAST(T*, ecs_get_mut_id(world, entity, ecs_id(T))))

Get a mutable pointer to a component.

Definition at line 356 of file flecs_c.h.

◆ ecs_get_mut_pair

#define ecs_get_mut_pair ( world,
subject,
First,
second )
Value:
(ECS_CAST(First*, ecs_get_mut_id(world, subject,\
ecs_pair(ecs_id(First), second))))

Get a mutable pointer to the first element of a pair.

Definition at line 360 of file flecs_c.h.

◆ ecs_get_mut_pair_second

#define ecs_get_mut_pair_second ( world,
subject,
first,
Second )
Value:
(ECS_CAST(Second*, ecs_get_mut_id(world, subject,\
ecs_pair(first, ecs_id(Second)))))

Get a mutable pointer to the second element of a pair.

Definition at line 365 of file flecs_c.h.

◆ ecs_get_pair

#define ecs_get_pair ( world,
subject,
First,
second )
Value:
(ECS_CAST(const First*, ecs_get_id(world, subject,\
ecs_pair(ecs_id(First), second))))

Get the first element of a pair.

Definition at line 346 of file flecs_c.h.

◆ ecs_get_pair_second

#define ecs_get_pair_second ( world,
subject,
first,
Second )
Value:
(ECS_CAST(const Second*, ecs_get_id(world, subject,\
ecs_pair(first, ecs_id(Second)))))

Get the second element of a pair.

Definition at line 351 of file flecs_c.h.

◆ ecs_insert

#define ecs_insert ( world,
... )
Value:
ecs_insert_w_values(world, ecs_values(__VA_ARGS__))
ecs_entity_t ecs_insert_w_values(ecs_world_t *world, const ecs_value_t *values)
Create a new entity with a list of component values.
#define ecs_values(...)
Convenience macro for creating a compound literal values array.
Definition flecs_c.h:743

Insert a new entity with a list of component values.

Definition at line 305 of file flecs_c.h.

◆ ecs_modified

#define ecs_modified ( world,
entity,
component )
Value:
ecs_modified_id(world, entity, ecs_id(component))
void ecs_modified_id(ecs_world_t *world, ecs_entity_t entity, ecs_id_t component)
Signal that a component has been modified.

Signal that a component has been modified.

Definition at line 388 of file flecs_c.h.

◆ ecs_modified_pair

#define ecs_modified_pair ( world,
subject,
first,
second )
Value:
ecs_modified_id(world, subject, ecs_pair(first, second))

Signal that a pair has been modified.

Definition at line 392 of file flecs_c.h.

◆ ecs_ref_get

#define ecs_ref_get ( world,
ref,
T )
Value:
(ECS_CAST(T*, ecs_ref_get_id(world, ref, ecs_id(T))))
void * ecs_ref_get_id(const ecs_world_t *world, ecs_ref_t *ref, ecs_id_t component)
Get a component from a ref.

Get a component from a ref.

Definition at line 400 of file flecs_c.h.

◆ ecs_ref_init

#define ecs_ref_init ( world,
entity,
T )
Value:
ecs_ref_init_id(world, entity, ecs_id(T))
ecs_ref_t ecs_ref_init_id(const ecs_world_t *world, ecs_entity_t entity, ecs_id_t component)
Create a component ref.

Initialize a ref for a component.

Definition at line 396 of file flecs_c.h.

◆ ecs_ref_modified

#define ecs_ref_modified ( world,
ref,
T )
Value:
ecs_ref_modified_id(world, ref, ecs_id(T))
void ecs_ref_modified_id(ecs_world_t *world, ecs_ref_t *ref, ecs_id_t component)
Signal that the component of a ref has been modified.

Signal that the component of a ref has been modified.

Definition at line 404 of file flecs_c.h.

◆ ecs_set

#define ecs_set ( world,
entity,
component,
... )
Value:
ecs_set_id(world, entity, ecs_id(component), sizeof(component), &(component)__VA_ARGS__)
void ecs_set_id(ecs_world_t *world, ecs_entity_t entity, ecs_id_t component, size_t size, const void *ptr)
Set the value of a component.

Set a component value.

Definition at line 313 of file flecs_c.h.

◆ ecs_set_override

#define ecs_set_override ( world,
entity,
T,
... )
Value:
ecs_add_id(world, entity, ECS_AUTO_OVERRIDE | ecs_id(T));\
ecs_set(world, entity, T, __VA_ARGS__)
void ecs_add_id(ecs_world_t *world, ecs_entity_t entity, ecs_id_t component)
Add a (component) ID to an entity.
const ecs_id_t ECS_AUTO_OVERRIDE
Automatically override component when it is inherited.

Set a component with auto-override.

Definition at line 329 of file flecs_c.h.

◆ ecs_set_pair

#define ecs_set_pair ( world,
subject,
First,
second,
... )
Value:
ecs_set_id(world, subject,\
ecs_pair(ecs_id(First), second),\
sizeof(First), &(First)__VA_ARGS__)

Set the first element of a pair.

Definition at line 317 of file flecs_c.h.

◆ ecs_set_pair_second

#define ecs_set_pair_second ( world,
subject,
first,
Second,
... )
Value:
ecs_set_id(world, subject,\
ecs_pair(first, ecs_id(Second)),\
sizeof(Second), &(Second)__VA_ARGS__)

Set the second element of a pair.

Definition at line 323 of file flecs_c.h.

◆ ecs_set_ptr

#define ecs_set_ptr ( world,
entity,
component,
ptr )
Value:
ecs_set_id(world, entity, ecs_id(component), sizeof(component), ptr)

Set a component using a pointer.

Definition at line 309 of file flecs_c.h.