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

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

Loading...
Searching...
No Matches
Singletons
C API » Macro API » Type-Safe API » Entity API
Collaboration diagram for Singletons:

## Macros
#define | ecs_singleton_add(world, comp)
| Add a singleton component.
#define | ecs_singleton_remove(world, comp)
| Remove a singleton component.
#define | ecs_singleton_get(world, comp)
| Get a singleton component.
#define | ecs_singleton_get_mut(world, comp)
| Get a mutable pointer to a singleton component.
#define | ecs_singleton_set_ptr(world, comp, ptr)
| Set a singleton component using a pointer.
#define | ecs_singleton_set(world, comp, ...)
| Set a singleton component value.
#define | ecs_singleton_ensure(world, comp)
| Ensure a singleton component, return mutable pointer.
#define | ecs_singleton_emplace(world, comp, is_new)
| Emplace a singleton component.
#define | ecs_singleton_modified(world, comp)
| Signal that a singleton component has been modified.

## Detailed Description

## Macro Definition Documentation

## ◆ ecs_singleton_add

#define ecs_singleton_add | ( |  | world,
|  |  | comp )

Value:
ecs_add(world, ecs_id(comp), comp)
ecs_id
FLECS_API const ecs_entity_t ecs_id(EcsDocDescription)
Component ID for EcsDocDescription.
ecs_add
#define ecs_add(world, entity, T)
Add a component to an entity.
Definition flecs_c.h:318

Add a singleton component.

Definition at line 487 of file flecs_c.h.

## ◆ ecs_singleton_emplace

#define ecs_singleton_emplace | ( |  | world,
|  |  | comp,
|  |  | is_new )

Value:
ecs_emplace(world, ecs_id(comp), comp, is_new)
ecs_emplace
#define ecs_emplace(world, entity, T, is_new)
Emplace a component.
Definition flecs_c.h:378

Emplace a singleton component.

Definition at line 515 of file flecs_c.h.

## ◆ ecs_singleton_ensure

#define ecs_singleton_ensure | ( |  | world,
|  |  | comp )

Value:
ecs_ensure(world, ecs_id(comp), comp)
ecs_ensure
#define ecs_ensure(world, entity, T)
Ensure entity has a component, return mutable pointer.
Definition flecs_c.h:418

Ensure a singleton component, return mutable pointer.

Definition at line 511 of file flecs_c.h.

## ◆ ecs_singleton_get

#define ecs_singleton_get | ( |  | world,
|  |  | comp )

Value:
ecs_get(world, ecs_id(comp), comp)
ecs_get
#define ecs_get(world, entity, T)
Get a component.
Definition flecs_c.h:386

Get a singleton component.

Definition at line 495 of file flecs_c.h.

## ◆ ecs_singleton_get_mut

#define ecs_singleton_get_mut | ( |  | world,
|  |  | comp )

Value:
ecs_get_mut(world, ecs_id(comp), comp)
ecs_get_mut
#define ecs_get_mut(world, entity, T)
Get a mutable pointer to a component.
Definition flecs_c.h:400

Get a mutable pointer to a singleton component.

Definition at line 499 of file flecs_c.h.

## ◆ ecs_singleton_modified

#define ecs_singleton_modified | ( |  | world,
|  |  | comp )

Value:
ecs_modified(world, ecs_id(comp), comp)
ecs_modified
#define ecs_modified(world, entity, component)
Signal that a component has been modified.
Definition flecs_c.h:432

Signal that a singleton component has been modified.

Definition at line 519 of file flecs_c.h.

## ◆ ecs_singleton_remove

#define ecs_singleton_remove | ( |  | world,
|  |  | comp )

Value:
ecs_remove(world, ecs_id(comp), comp)
ecs_remove
#define ecs_remove(world, entity, T)
Remove a component from an entity.
Definition flecs_c.h:326

Remove a singleton component.

Definition at line 491 of file flecs_c.h.

## ◆ ecs_singleton_set

#define ecs_singleton_set | ( |  | world,
|  |  | comp,
|  |  | ... )

Value:
ecs_set(world, ecs_id(comp), comp, __VA_ARGS__)
ecs_set
#define ecs_set(world, entity, component,...)
Set a component value.
Definition flecs_c.h:357

Set a singleton component value.

Definition at line 507 of file flecs_c.h.

## ◆ ecs_singleton_set_ptr

#define ecs_singleton_set_ptr | ( |  | world,
|  |  | comp,
|  |  | ptr )

Value:
ecs_set_ptr(world, ecs_id(comp), comp, ptr)
ecs_set_ptr
#define ecs_set_ptr(world, entity, component, ptr)
Set a component using a pointer.
Definition flecs_c.h:353

Set a singleton component using a pointer.

Definition at line 503 of file flecs_c.h.