Flecs v4.1
A fast entity component system (ECS) for C & C++
Loading...
Searching...
No Matches
Getting & Setting
Collaboration diagram for Getting & Setting:

Macros

#define ecs_insert(world, ...)    ecs_entity(world, { .set = ecs_values(__VA_ARGS__)})
 Insert a new entity with a list of component values.
 
#define ecs_set_ptr(world, entity, component, ptr)    ecs_set_id(world, entity, ecs_id(component), sizeof(component), ptr)
 Set a component using a pointer.
 
#define ecs_set(world, entity, component, ...)    ecs_set_id(world, entity, ecs_id(component), sizeof(component), &(component)__VA_ARGS__)
 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)    (ECS_CAST(T*, ecs_emplace_id(world, entity, ecs_id(T), sizeof(T), is_new)))
 Emplace a component.
 
#define ecs_emplace_pair(world, entity, First, second, is_new)    (ECS_CAST(First*, ecs_emplace_id(world, entity, ecs_pair_t(First, second), sizeof(First), is_new)))
 Emplace the first element of a pair.
 
#define ecs_get(world, entity, T)    (ECS_CAST(const T*, ecs_get_id(world, entity, ecs_id(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)    (ECS_CAST(T*, ecs_get_mut_id(world, entity, ecs_id(T))))
 Get a mutable pointer to a component.
 
#define ecs_get_mut(world, entity, T)    (ECS_CAST(T*, ecs_get_mut_id(world, entity, ecs_id(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)    (ECS_CAST(T*, ecs_ensure_id(world, entity, ecs_id(T), sizeof(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)    ecs_modified_id(world, entity, ecs_id(component))
 Signal that a component has been modified.
 
#define ecs_modified_pair(world, subject, first, second)    ecs_modified_id(world, subject, ecs_pair(first, second))
 Signal that a pair has been modified.
 
#define ecs_record_get(world, record, T)    (ECS_CAST(const T*, ecs_record_get_id(world, record, ecs_id(T))))
 Get a component from a record.
 
#define ecs_record_has(world, record, T)    (ecs_record_has_id(world, record, ecs_id(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)    (ECS_CAST(T*, ecs_record_ensure_id(world, record, ecs_id(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)    ecs_ref_init_id(world, entity, ecs_id(T))
 Initialize a ref for a component.
 
#define ecs_ref_get(world, ref, T)    (ECS_CAST(T*, ecs_ref_get_id(world, ref, ecs_id(T))))
 Get a component from a ref.
 

Detailed Description

Macro Definition Documentation

◆ ecs_emplace

#define ecs_emplace ( world,
entity,
T,
is_new )    (ECS_CAST(T*, ecs_emplace_id(world, entity, ecs_id(T), sizeof(T), is_new)))

Emplace a component.

Definition at line 378 of file flecs_c.h.

◆ ecs_emplace_pair

#define ecs_emplace_pair ( world,
entity,
First,
second,
is_new )    (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 382 of file flecs_c.h.

◆ ecs_ensure

#define ecs_ensure ( world,
entity,
T )    (ECS_CAST(T*, ecs_ensure_id(world, entity, ecs_id(T), sizeof(T))))

Ensure entity has a component, return mutable pointer.

Definition at line 418 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))))
FLECS_API const ecs_entity_t ecs_id(EcsDocDescription)
Component ID for EcsDocDescription.
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 the first element of a pair, return mutable pointer.

Definition at line 422 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 427 of file flecs_c.h.

◆ ecs_get

#define ecs_get ( world,
entity,
T )    (ECS_CAST(const T*, ecs_get_id(world, entity, ecs_id(T))))

Get a component.

Definition at line 386 of file flecs_c.h.

◆ ecs_get_mut [1/2]

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

Get a mutable pointer to a component.

Definition at line 400 of file flecs_c.h.

◆ ecs_get_mut [2/2]

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

Get a mutable pointer to a component.

Definition at line 400 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))))
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 the first element of a pair.

Definition at line 404 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 409 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))))
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 the first element of a pair.

Definition at line 390 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 395 of file flecs_c.h.

◆ ecs_insert

#define ecs_insert ( world,
... )    ecs_entity(world, { .set = ecs_values(__VA_ARGS__)})

Insert a new entity with a list of component values.

Definition at line 349 of file flecs_c.h.

◆ ecs_modified

#define ecs_modified ( world,
entity,
component )    ecs_modified_id(world, entity, ecs_id(component))

Signal that a component has been modified.

Definition at line 432 of file flecs_c.h.

◆ ecs_modified_pair

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

Signal that a pair has been modified.

Definition at line 436 of file flecs_c.h.

◆ ecs_record_ensure

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

Ensure a component on a record, return mutable pointer.

Definition at line 458 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 462 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 467 of file flecs_c.h.

◆ ecs_record_get

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

Get a component from a record.

Definition at line 440 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 448 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 453 of file flecs_c.h.

◆ ecs_record_has

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

Test if a record has a component.

Definition at line 444 of file flecs_c.h.

◆ ecs_ref_get

#define ecs_ref_get ( world,
ref,
T )    (ECS_CAST(T*, ecs_ref_get_id(world, ref, ecs_id(T))))

Get a component from a ref.

Definition at line 476 of file flecs_c.h.

◆ ecs_ref_init

#define ecs_ref_init ( world,
entity,
T )    ecs_ref_init_id(world, entity, ecs_id(T))

Initialize a ref for a component.

Definition at line 472 of file flecs_c.h.

◆ ecs_set

#define ecs_set ( world,
entity,
component,
... )    ecs_set_id(world, entity, ecs_id(component), sizeof(component), &(component)__VA_ARGS__)

Set a component value.

Definition at line 357 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 373 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__)
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 the first element of a pair.

Definition at line 361 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 367 of file flecs_c.h.

◆ ecs_set_ptr

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

Set a component using a pointer.

Definition at line 353 of file flecs_c.h.