Flecs: Component API
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
Component API
C API » Macro API » Type Safe API
Collaboration diagram for Component API:

## Macros
#define | ecs_set_hooks(world, T, ...)
#define | ecs_get_hooks(world, T)
#define | ECS_CTOR(type, var, ...)
| Declare a constructor.
#define | ECS_DTOR(type, var, ...)
| Declare a destructor.
#define | ECS_COPY(type, dst_var, src_var, ...)
| Declare a copy action.
#define | ECS_MOVE(type, dst_var, src_var, ...)
| Declare a move action.
#define | ECS_ON_ADD(type, ptr, ...)
| Declare component hooks.
#define | ECS_ON_REMOVE(type, ptr, ...)
#define | ECS_ON_SET(type, ptr, ...)
#define | ecs_ctor(type)
#define | ecs_dtor(type)
#define | ecs_copy(type)
#define | ecs_move(type)
#define | ecs_on_set(type)
#define | ecs_on_add(type)
#define | ecs_on_remove(type)

## Detailed Description

## Macro Definition Documentation

## ◆ ECS_COPY

#define ECS_COPY | ( |  | type,
|  |  | dst_var,
|  |  | src_var,
|  |  | ... )

Value:
ECS_COPY_IMPL(type, dst_var, src_var, __VA_ARGS__)

Declare a copy action.

Example:

ECS_COPY(MyType, dst, src, { dst->value = strdup(src->value); });
ECS_COPY
#define ECS_COPY(type, dst_var, src_var,...)
Declare a copy action.
Definition flecs_c.h:634

Definition at line 634 of file flecs_c.h.

## ◆ ecs_copy

#define ecs_copy | ( |  | type | ) |

Value:
type##_copy

Definition at line 664 of file flecs_c.h.

## ◆ ECS_CTOR

#define ECS_CTOR | ( |  | type,
|  |  | var,
|  |  | ... )

Value:
ECS_XTOR_IMPL(type, ctor, var, __VA_ARGS__)

Declare a constructor.

Example:

ECS_CTOR(MyType, ptr, { ptr->value = NULL; });
ECS_CTOR
#define ECS_CTOR(type, var,...)
Declare a constructor.
Definition flecs_c.h:614

Definition at line 614 of file flecs_c.h.

## ◆ ecs_ctor

#define ecs_ctor | ( |  | type | ) |

Value:
type##_ctor

Definition at line 662 of file flecs_c.h.

## ◆ ECS_DTOR

#define ECS_DTOR | ( |  | type,
|  |  | var,
|  |  | ... )

Value:
ECS_XTOR_IMPL(type, dtor, var, __VA_ARGS__)

Declare a destructor.

Example:

ECS_DTOR(MyType, ptr, { free(ptr->value); });
ECS_DTOR
#define ECS_DTOR(type, var,...)
Declare a destructor.
Definition flecs_c.h:624

Definition at line 624 of file flecs_c.h.

## ◆ ecs_dtor

#define ecs_dtor | ( |  | type | ) |

Value:
type##_dtor

Definition at line 663 of file flecs_c.h.

## ◆ ecs_get_hooks

#define ecs_get_hooks | ( |  | world,
|  |  | T )

Value:
ecs_get_hooks_id(world, ecs_id(T));
ecs_id
FLECS_API const ecs_entity_t ecs_id(EcsDocDescription)
Component id for EcsDocDescription.
ecs_get_hooks_id
const ecs_type_hooks_t * ecs_get_hooks_id(const ecs_world_t *world, ecs_entity_t id)
Get hooks for component.

Definition at line 604 of file flecs_c.h.

## ◆ ECS_MOVE

#define ECS_MOVE | ( |  | type,
|  |  | dst_var,
|  |  | src_var,
|  |  | ... )

Value:
ECS_MOVE_IMPL(type, dst_var, src_var, __VA_ARGS__)

Declare a move action.

Example:

ECS_MOVE(MyType, dst, src, { dst->value = src->value; src->value = 0; });
ECS_MOVE
#define ECS_MOVE(type, dst_var, src_var,...)
Declare a move action.
Definition flecs_c.h:644

Definition at line 644 of file flecs_c.h.

## ◆ ecs_move

#define ecs_move | ( |  | type | ) |

Value:
type##_move

Definition at line 665 of file flecs_c.h.

## ◆ ECS_ON_ADD

#define ECS_ON_ADD | ( |  | type,
|  |  | ptr,
|  |  | ... )

Value:
ECS_HOOK_IMPL(type, ecs_on_add(type), ptr, __VA_ARGS__)

Declare component hooks.

Example:

ECS_ON_SET(MyType, ptr, { printf("%d\n", ptr->value); });

Definition at line 654 of file flecs_c.h.

## ◆ ecs_on_add

#define ecs_on_add | ( |  | type | ) |

Value:
type##_on_add

Definition at line 667 of file flecs_c.h.

## ◆ ECS_ON_REMOVE

#define ECS_ON_REMOVE | ( |  | type,
|  |  | ptr,
|  |  | ... )

Value:
ECS_HOOK_IMPL(type, ecs_on_remove(type), ptr, __VA_ARGS__)

Definition at line 656 of file flecs_c.h.

## ◆ ecs_on_remove

#define ecs_on_remove | ( |  | type | ) |

Value:
type##_on_remove

Definition at line 668 of file flecs_c.h.

## ◆ ECS_ON_SET

#define ECS_ON_SET | ( |  | type,
|  |  | ptr,
|  |  | ... )

Value:
ECS_HOOK_IMPL(type, ecs_on_set(type), ptr, __VA_ARGS__)

Definition at line 658 of file flecs_c.h.

## ◆ ecs_on_set

#define ecs_on_set | ( |  | type | ) |

Value:
type##_on_set

Definition at line 666 of file flecs_c.h.

## ◆ ecs_set_hooks

#define ecs_set_hooks | ( |  | world,
|  |  | T,
|  |  | ... )

Value:
ecs_set_hooks_id(world, ecs_id(T), &(ecs_type_hooks_t)__VA_ARGS__)
ecs_set_hooks_id
void ecs_set_hooks_id(ecs_world_t *world, ecs_entity_t id, const ecs_type_hooks_t *hooks)
Register hooks for component.
ecs_type_hooks_t
Type that contains component lifecycle callbacks.
Definition flecs.h:864

Definition at line 601 of file flecs_c.h.