Flecs: Getting & Setting
Description: A fast entity component system (ECS) for C & C++

| Flecs v4.0 A fast entity component system (ECS) for C & C++

Loading...
Searching...
No Matches
Macros
Getting & Setting
C API » Macro API » Type Safe API » Entity API
Collaboration diagram for Getting & Setting:

## Macros
#define | ecs_insert(world, ...)
#define | ecs_set_ptr(world, entity, component, ptr)
#define | ecs_set(world, entity, component, ...)
#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)
#define | ecs_emplace_pair(world, entity, First, second, is_new)
#define | ecs_get(world, entity, 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)
#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)
#define | ecs_ensure_pair(world, subject, First, second)
#define | ecs_ensure_pair_second(world, subject, first, Second)
#define | ecs_modified(world, entity, component)
#define | ecs_modified_pair(world, subject, first, second)
#define | ecs_record_get(world, record, T)
#define | ecs_record_has(world, record, 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)
#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)
#define | ecs_ref_get(world, ref, T)

## 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), is_new)))
ecs_id
FLECS_API const ecs_entity_t ecs_id(EcsDocDescription)
Component id for EcsDocDescription.
ecs_emplace_id
void * ecs_emplace_id(ecs_world_t *world, ecs_entity_t entity, ecs_id_t id, bool *is_new)
Emplace a component.

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

Definition at line 388 of file flecs_c.h.

## ◆ ecs_ensure [1/2]

#define ecs_ensure | ( |  | world,
|  |  | entity,
|  |  | T )

Value:
(ECS_CAST(T*, ecs_ensure_id(world, entity, ecs_id(T))))
ecs_ensure_id
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 422 of file flecs_c.h.

## ◆ ecs_ensure [2/2]

#define ecs_ensure | ( |  | world,
|  |  | entity,
|  |  | T )

Value:
(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))))

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 )

Value:
(ECS_CAST(const T*, ecs_get_id(world, entity, ecs_id(T))))
ecs_get_id
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 393 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))))
ecs_get_mut_id
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 406 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))))

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

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

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

Value:
ecs_entity(world, { .set = ecs_values(__VA_ARGS__)})
ecs_entity
#define ecs_entity(world,...)
Shorthand for creating an entity with ecs_entity_init().
Definition flecs_c.h:235
ecs_values
#define ecs_values(...)
Convenience macro for creating compound literal values array.
Definition flecs_c.h:723

Definition at line 358 of file flecs_c.h.

## ◆ ecs_modified

#define ecs_modified | ( |  | world,
|  |  | entity,
|  |  | component )

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

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

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

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

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 )

Value:
(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))))

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 )

Value:
(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 )

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

Definition at line 482 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_init_id
ecs_ref_t ecs_ref_init_id(const ecs_world_t *world, ecs_entity_t entity, ecs_id_t id)
Create a component ref.

Definition at line 479 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__)
ecs_set_id
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 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__)
ecs_add_id
void ecs_add_id(ecs_world_t *world, ecs_entity_t entity, ecs_id_t id)
Add a (component) id to an entity.
ECS_AUTO_OVERRIDE
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__)

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 )

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

Definition at line 363 of file flecs_c.h.