Flecs: include/flecs/addons/module.h Source File
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
module.h
Go to the documentation of this file.
1
9
10#ifdef FLECS_MODULE
11
19
20#ifndef FLECS_MODULE_H
21#define FLECS_MODULE_H
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
46FLECS_API
47 ecs_entity_t ecs_import(
48 ecs_world_t *world,
49 ecs_module_action_t module,
50 const char *module_name);
51
60FLECS_API
61 ecs_entity_t ecs_import_c(
62 ecs_world_t *world,
63 ecs_module_action_t module,
64 const char *module_name_c);
65
84FLECS_API
85 ecs_entity_t ecs_import_from_library(
86 ecs_world_t *world,
87 const char *library_name,
88 const char *module_name);
89
91FLECS_API
92 ecs_entity_t ecs_module_init(
93 ecs_world_t *world,
94 const char *c_name,
95 const ecs_component_desc_t *desc);
96
98#define ECS_MODULE_DEFINE(world, id)\
99 {\
100 ecs_component_desc_t desc = {0};\
101 desc.entity = ecs_id(id);\
102 ecs_id(id) = ecs_module_init(world, #id, &desc);\
103 ecs_set_scope(world, ecs_id(id));\
104 }
105
107#define ECS_MODULE(world, id)\
108 ecs_entity_t ecs_id(id) = 0; ECS_MODULE_DEFINE(world, id)\
109 (void)ecs_id(id)
110
119#define ECS_IMPORT(world, id) ecs_import_c(world, id##Import, #id)
120
121#ifdef __cplusplus
122}
123#endif
124
125#endif
126
128
129#endif
ecs_import_from_library
FLECS_API ecs_entity_t ecs_import_from_library(ecs_world_t *world, const char *library_name, const char *module_name)
Import a module from a library.
ecs_module_init
FLECS_API ecs_entity_t ecs_module_init(ecs_world_t *world, const char *c_name, const ecs_component_desc_t *desc)
Register a new module.
ecs_import
FLECS_API ecs_entity_t ecs_import(ecs_world_t *world, ecs_module_action_t module, const char *module_name)
Import a module.
ecs_import_c
FLECS_API ecs_entity_t ecs_import_c(ecs_world_t *world, ecs_module_action_t module, const char *module_name_c)
Same as ecs_import(), but with name to scope conversion.
ecs_entity_t
ecs_id_t ecs_entity_t
An entity identifier.
Definition flecs.h:346
ecs_world_t
struct ecs_world_t ecs_world_t
A world is the container for all ECS data and supporting features.
Definition flecs.h:390
ecs_module_action_t
void(* ecs_module_action_t)(ecs_world_t *world)
Initialization action for modules.
Definition flecs.h:605
ecs_component_desc_t
Used with ecs_component_init().
Definition flecs.h:1051