Flecs v4.0
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__)})
 
#define ecs_set_ptr(world, entity, component, ptr)    ecs_set_id(world, entity, ecs_id(component), sizeof(component), ptr)
 
#define ecs_set(world, entity, component, ...)    ecs_set_id(world, entity, ecs_id(component), sizeof(component), &(component)__VA_ARGS__)
 
#define ecs_set_pair(world, subject, First, second, ...)
 
#define ecs_set_pair_second(world, subject, first, Second, ...)
 
#define ecs_set_override(world, entity, T, ...)
 
#define ecs_emplace(world, entity, T, is_new)    (ECS_CAST(T*, ecs_emplace_id(world, entity, ecs_id(T), is_new)))
 
#define ecs_emplace_pair(world, entity, First, second, is_new)    (ECS_CAST(First*, ecs_emplace_id(world, entity, ecs_pair_t(First, second), is_new)))
 
#define ecs_get(world, entity, T)    (ECS_CAST(const T*, ecs_get_id(world, entity, ecs_id(T))))
 
#define ecs_get_pair(world, subject, First, second)
 
#define ecs_get_pair_second(world, subject, first, Second)
 
#define ecs_get_mut(world, entity, T)    (ECS_CAST(T*, ecs_get_mut_id(world, entity, ecs_id(T))))
 
#define ecs_get_mut(world, entity, T)    (ECS_CAST(T*, ecs_get_mut_id(world, entity, ecs_id(T))))
 
#define ecs_get_mut_pair(world, subject, First, second)
 
#define ecs_get_mut_pair_second(world, subject, first, Second)
 
#define ecs_ensure(world, entity, T)    (ECS_CAST(T*, ecs_ensure_id(world, entity, ecs_id(T))))
 
#define ecs_ensure(world, entity, T)    (ECS_CAST(T*, ecs_ensure_id(world, entity, ecs_id(T))))
 
#define ecs_ensure_pair(world, subject, First, second)
 
#define ecs_ensure_pair(world, subject, First, second)
 
#define ecs_ensure_pair_second(world, subject, first, Second)
 
#define ecs_ensure_pair_second(world, subject, first, Second)
 
#define ecs_modified(world, entity, component)    ecs_modified_id(world, entity, ecs_id(component))
 
#define ecs_modified_pair(world, subject, first, second)    ecs_modified_id(world, subject, ecs_pair(first, second))
 
#define ecs_record_get(world, record, T)    (ECS_CAST(const T*, ecs_record_get_id(world, record, ecs_id(T))))
 
#define ecs_record_has(world, record, T)    (ecs_record_has_id(world, record, ecs_id(T)))
 
#define ecs_record_get_pair(world, record, First, second)
 
#define ecs_record_get_pair_second(world, record, first, Second)
 
#define ecs_record_ensure(world, record, T)    (ECS_CAST(T*, ecs_record_ensure_id(world, record, ecs_id(T))))
 
#define ecs_record_ensure_pair(world, record, First, second)
 
#define ecs_record_ensure_pair_second(world, record, first, Second)
 
#define ecs_ref_init(world, entity, T)    ecs_ref_init_id(world, entity, ecs_id(T))
 
#define ecs_ref_get(world, ref, T)    (ECS_CAST(T*, ecs_ref_get_id(world, ref, ecs_id(T))))
 

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), is_new)))

Definition at line 385 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), is_new)))

Definition at line 388 of file flecs_c.h.

◆ ecs_ensure [1/2]

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

Definition at line 422 of file flecs_c.h.

◆ ecs_ensure [2/2]

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

Definition at line 422 of file flecs_c.h.

◆ ecs_ensure_pair [1/2]

#define ecs_ensure_pair ( world,
subject,
First,
second )
Value:
(ECS_CAST(First*, ecs_ensure_id(world, subject,\
ecs_pair(ecs_id(First), second))))
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 id)
Get a mutable pointer to a component.

Definition at line 425 of file flecs_c.h.

◆ ecs_ensure_pair [2/2]

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

Definition at line 425 of file flecs_c.h.

◆ ecs_ensure_pair_second [1/2]

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

Definition at line 429 of file flecs_c.h.

◆ ecs_ensure_pair_second [2/2]

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

Definition at line 429 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))))

Definition at line 393 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))))

Definition at line 406 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))))

Definition at line 406 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 id)
Get a mutable pointer to a component.

Definition at line 409 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)))))

Definition at line 413 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 id)
Get an immutable pointer to a component.

Definition at line 396 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)))))

Definition at line 400 of file flecs_c.h.

◆ ecs_insert

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

Definition at line 358 of file flecs_c.h.

◆ ecs_modified

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

Definition at line 446 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))

Definition at line 449 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))))

Definition at line 468 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))))
void * ecs_record_ensure_id(ecs_world_t *world, ecs_record_t *record, ecs_id_t id)
Same as ecs_record_get_id(), but returns a mutable pointer.

Definition at line 471 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)))))

Definition at line 475 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))))

Definition at line 454 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))))
const void * ecs_record_get_id(const ecs_world_t *world, const ecs_record_t *record, ecs_id_t id)
Get component from entity record.

Definition at line 460 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)))))

Definition at line 464 of file flecs_c.h.

◆ ecs_record_has

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

Definition at line 457 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))))

Definition at line 482 of file flecs_c.h.

◆ ecs_ref_init

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

Definition at line 479 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__)

Definition at line 366 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 id)
Add a (component) id to an entity.
const ecs_id_t ECS_AUTO_OVERRIDE
Automatically override component when it is inherited.

Definition at line 379 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 id, size_t size, const void *ptr)
Set the value of a component.

Definition at line 369 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__)

Definition at line 374 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)

Definition at line 363 of file flecs_c.h.