Skip to content
Flecs v4.1
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_record_get(world, record, T)
 Get a component from a record.
#define ecs_record_has(world, record, T)
 Test if a record has a component.
#define ecs_record_get_pair(world, record, First, second)
 Get the first element of a pair from a record.
#define ecs_record_get_pair_second(world, record, first, Second)
 Get the second element of a pair from a record.
#define ecs_record_ensure(world, record, T)
 Ensure a component on a record, return mutable pointer.
#define ecs_record_ensure_pair(world, record, First, second)
 Ensure the first element of a pair on a record, return mutable pointer.
#define ecs_record_ensure_pair_second(world, record, first, Second)
 Ensure the second element of a pair on a record, return mutable pointer.
#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.

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 331 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 335 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 371 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 375 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 380 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 339 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 353 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 353 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 357 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 362 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 343 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 348 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:761

Insert a new entity with a list of component values.

Definition at line 302 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 385 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 389 of file flecs_c.h.

◆ ecs_record_ensure

#define ecs_record_ensure ( world,
record,
T )
Value:
(ECS_CAST(T*, ecs_record_ensure_id(world, record, ecs_id(T))))

Ensure a component on a record, return mutable pointer.

Definition at line 411 of file flecs_c.h.

◆ ecs_record_ensure_pair

#define ecs_record_ensure_pair ( world,
record,
First,
second )
Value:
(ECS_CAST(First*, ecs_record_ensure_id(world, record, \
ecs_pair(ecs_id(First), second))))

Ensure the first element of a pair on a record, return mutable pointer.

Definition at line 415 of file flecs_c.h.

◆ ecs_record_ensure_pair_second

#define ecs_record_ensure_pair_second ( world,
record,
first,
Second )
Value:
(ECS_CAST(Second*, ecs_record_ensure_id(world, record,\
ecs_pair(first, ecs_id(Second)))))

Ensure the second element of a pair on a record, return mutable pointer.

Definition at line 420 of file flecs_c.h.

◆ ecs_record_get

#define ecs_record_get ( world,
record,
T )
Value:
(ECS_CAST(const T*, ecs_record_get_id(world, record, ecs_id(T))))

Get a component from a record.

Definition at line 393 of file flecs_c.h.

◆ ecs_record_get_pair

#define ecs_record_get_pair ( world,
record,
First,
second )
Value:
(ECS_CAST(const First*, ecs_record_get_id(world, record, \
ecs_pair(ecs_id(First), second))))

Get the first element of a pair from a record.

Definition at line 401 of file flecs_c.h.

◆ ecs_record_get_pair_second

#define ecs_record_get_pair_second ( world,
record,
first,
Second )
Value:
(ECS_CAST(const Second*, ecs_record_get_id(world, record,\
ecs_pair(first, ecs_id(Second)))))

Get the second element of a pair from a record.

Definition at line 406 of file flecs_c.h.

◆ ecs_record_has

#define ecs_record_has ( world,
record,
T )
Value:
(ecs_record_has_id(world, record, ecs_id(T)))

Test if a record has a component.

Definition at line 397 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 429 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 425 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 310 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 326 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 314 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 320 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 306 of file flecs_c.h.