Flecs v4.0
A fast entity component system (ECS) for C & C++
|
Modules organize components, systems and more in reusable units of code. More...
Macros | |
#define | ECS_MODULE_DEFINE(world, id) |
Define module. | |
#define | ECS_MODULE(world, id) |
Create a module. | |
#define | ECS_IMPORT(world, id) ecs_import_c(world, id##Import, #id) |
Wrapper around ecs_import(). | |
Functions | |
FLECS_API ecs_entity_t | ecs_import (ecs_world_t *world, ecs_module_action_t module, const char *module_name) |
Import a module. | |
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. | |
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. | |
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. | |
Modules organize components, systems and more in reusable units of code.
#define ECS_IMPORT | ( | world, | |
id ) ecs_import_c(world, id##Import, #id) |
Wrapper around ecs_import().
This macro provides a convenient way to load a module with the world. It can be used like this:
#define ECS_MODULE | ( | world, | |
id ) |
Create a module.
#define ECS_MODULE_DEFINE | ( | world, | |
id ) |
Define module.
FLECS_API ecs_entity_t ecs_import | ( | ecs_world_t * | world, |
ecs_module_action_t | module, | ||
const char * | module_name ) |
Import a module.
This operation will load a modules and store the public module handles in the handles_out out parameter. The module name will be used to verify if the module was already loaded, in which case it won't be reimported. The name will be translated from PascalCase to an entity path (pascal.case) before the lookup occurs.
Module contents will be stored as children of the module entity. This prevents modules from accidentally defining conflicting identifiers. This is enforced by setting the scope before and after loading the module to the module entity id.
A more convenient way to import a module is by using the ECS_IMPORT macro.
world | The world. |
module | The module import function. |
module_name | The name of the module. |
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.
PascalCase names are automatically converted to scoped names.
world | The world. |
module | The module import function. |
module_name_c | The name of the module. |
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.
Similar to ecs_import(), except that this operation will attempt to load the module from a dynamic library.
A library may contain multiple modules, which is why both a library name and a module name need to be provided. If only a library name is provided, the library name will be reused for the module name.
The library will be looked up using a canonical name, which is in the same form as a module, like flecs.components.transform
. To transform this identifier to a platform specific library name, the operation relies on the module_to_dl callback of the os_api which the application has to override if the default does not yield the correct library name.
world | The world. |
library_name | The name of the library to load. |
module_name | The name of the module to load. |