Flecs: flecs::world Struct Reference
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
flecs::world Struct Reference
C++ API » Core » World

The world. More...

`#include <world.hpp>`

Inheritance diagram for flecs::world:
[legend]

## Public Member Functions
| world ()
| Create world.
| world (int argc, char *argv[])
| Create world with command line arguments.
| world (world_t *w)
| Create world from C world.
| world (const world &obj)
| Not allowed to copy a world.
world & | operator= (const world &obj) noexcept
| world (world &&obj) noexcept
world & | operator= (world &&obj) noexcept
void | release ()
| operator world_t * () const
void | make_owner ()
| Make current world object owner of the world.
void | reset ()
| Deletes and recreates the world.
world_t * | c_ptr () const
| Obtain pointer to C world object.
void | quit () const
| Signal application should quit.
void | atfini (ecs_fini_action_t action, void *ctx=nullptr) const
| Register action to be executed when world is destroyed.
bool | should_quit () const
| Test if quit() has been called.
ecs_ftime_t | frame_begin (float delta_time=0) const
| Begin frame.
void | frame_end () const
| End frame.
bool | readonly_begin (bool multi_threaded=false) const
| Begin readonly mode.
void | readonly_end () const
| End readonly mode.
bool | defer_begin () const
| Defer operations until end of frame.
bool | defer_end () const
| End block of operations to defer.
bool | is_deferred () const
| Test whether deferring is enabled.
void | set_stage_count (int32_t stages) const
| Configure world to have N stages.
int32_t | get_stage_count () const
| Get number of configured stages.
int32_t | get_stage_id () const
| Get current stage id.
bool | is_stage () const
| Test if is a stage.
void | merge () const
| Merge world or stage.
flecs::world | get_stage (int32_t stage_id) const
| Get stage-specific world pointer.
flecs::world | async_stage () const
| Create asynchronous stage.
flecs::world | get_world () const
| Get actual world.
bool | is_readonly () const
| Test whether the current world object is readonly.
void | set_ctx (void *ctx, ecs_ctx_free_t ctx_free=nullptr) const
| Set world context.
void * | get_ctx () const
| Get world context.
void | set_binding_ctx (void *ctx, ecs_ctx_free_t ctx_free=nullptr) const
| Set world binding context.
void * | get_binding_ctx () const
| Get world binding context.
void | dim (int32_t entity_count) const
| Preallocate memory for number of entities.
void | set_entity_range (entity_t min, entity_t max) const
| Set entity range.
void | enable_range_check (bool enabled=true) const
| Enforce that operations cannot modify entities outside of range.
flecs::entity | set_scope (const flecs::entity_t scope) const
| Set current scope.
flecs::entity | get_scope () const
| Get current scope.
template<typename T>
flecs::entity | set_scope () const
| Same as set_scope but with type.
flecs::entity_t * | set_lookup_path (const flecs::entity_t *search_path) const
| Set search path.
flecs::entity | lookup (const char *name, const char *sep="::", const char *root_sep="::", bool recursive=true) const
| Lookup entity by name.
template<typename T, if_t< !is_callable< T >::value > = 0>
void | set (const T &value) const
| Set singleton component.
template<typename T, if_t< !is_callable< T >::value > = 0>
void | set (T &&value) const
| Set singleton component.
template<typename First, typename Second, typename P = flecs::pair<First, Second>, typename A = actual_type_t<P>, if_not_t< flecs::is_pair< First >::value > = 0>
void | set (const A &value) const
| Set singleton pair.
template<typename First, typename Second, typename P = flecs::pair<First, Second>, typename A = actual_type_t<P>, if_not_t< flecs::is_pair< First >::value > = 0>
void | set (A &&value) const
| Set singleton pair.
template<typename First, typename Second>
void | set (Second second, const First &value) const
| Set singleton pair.
template<typename First, typename Second>
void | set (Second second, First &&value) const
| Set singleton pair.
template<typename Func, if_t< is_callable< Func >::value > = 0>
void | set (const Func &func) const
| Set singleton component inside a callback.
template<typename T, typename ... Args>
void | emplace (Args &&... args) const
template<typename T>
T & | ensure () const
| Ensure singleton component.
template<typename T>
void | modified () const
| Mark singleton component as modified.
template<typename T>
ref< T > | get_ref () const
| Get ref singleton component.
const void * | try_get (flecs::id_t id) const
| Get singleton component.
const void * | try_get (flecs::entity_t r, flecs::entity_t t) const
| Get singleton pair.
template<typename T>
const T * | try_get () const
| Get singleton component.
template<typename First, typename Second, typename P = flecs::pair<First, Second>, typename A = actual_type_t<P>>
const A * | try_get () const
| Get singleton pair.
template<typename First, typename Second>
const First * | try_get (Second second) const
| Get singleton pair.
const void * | get (flecs::id_t id) const
| Get singleton component.
const void * | get (flecs::entity_t r, flecs::entity_t t) const
| Get singleton component.
template<typename T>
const T & | get () const
template<typename First, typename Second, typename P = flecs::pair<First, Second>, typename A = actual_type_t<P>>
const A & | get () const
| Get singleton pair.
template<typename First, typename Second>
const First & | get (Second second) const
| Get singleton pair.
template<typename Func, if_t< is_callable< Func >::value > = 0>
void | get (const Func &func) const
| Get singleton component inside a callback.
void * | try_get_mut (flecs::id_t id) const
| Get mutable singleton component.
void * | try_get_mut (flecs::entity_t r, flecs::entity_t t) const
| Get mutable singleton pair.
template<typename T>
T * | try_get_mut () const
template<typename First, typename Second, typename P = flecs::pair<First, Second>, typename A = actual_type_t<P>>
A * | try_get_mut () const
| Get mutable singleton pair.
template<typename First, typename Second>
First * | try_get_mut (Second second) const
| Get mutable singleton pair.
void * | get_mut (flecs::id_t id) const
| Get mutable singleton component.
void * | get_mut (flecs::entity_t r, flecs::entity_t t) const
| Get mutable singleton pair.
template<typename T>
T & | get_mut () const
template<typename First, typename Second, typename P = flecs::pair<First, Second>, typename A = actual_type_t<P>>
A & | get_mut () const
| Get mutable singleton pair.
template<typename First, typename Second>
First & | get_mut (Second second) const
| Get mutable singleton pair.
template<typename T>
bool | has () const
| Test if world has singleton component.
template<typename First, typename Second>
bool | has () const
| Test if world has the provided pair.
template<typename First>
bool | has (flecs::id_t second) const
| Test if world has the provided pair.
bool | has (flecs::id_t first, flecs::id_t second) const
| Test if world has the provided pair.
template<typename T>
void | add () const
| Add singleton component.
template<typename First, typename Second>
void | add () const
| Adds a pair to the singleton component.
template<typename First>
void | add (flecs::entity_t second) const
| Adds a pair to the singleton component.
void | add (flecs::entity_t first, flecs::entity_t second) const
| Adds a pair to the singleton entity.
template<typename T>
void | remove () const
| Remove singleton component.
template<typename First, typename Second>
void | remove () const
| Removes the pair singleton component.
template<typename First>
void | remove (flecs::entity_t second) const
| Removes the pair singleton component.
void | remove (flecs::entity_t first, flecs::entity_t second) const
| Removes the pair singleton component.
template<typename Func>
void | children (Func &&f) const
| Iterate entities in root of world Accepts a callback with the following signature:
template<typename T>
flecs::entity | singleton () const
| Get singleton entity for type.
template<typename First>
flecs::entity | target (int32_t index=0) const
| Get target for a given pair from a singleton entity.
template<typename T>
flecs::entity | target (flecs::entity_t first, int32_t index=0) const
| Get target for a given pair from a singleton entity.
flecs::entity | target (flecs::entity_t first, int32_t index=0) const
| Get target for a given pair from a singleton entity.
template<typename T>
flecs::entity | use (const char *alias=nullptr) const
| Create alias for component.
flecs::entity | use (const char *name, const char *alias=nullptr) const
| Create alias for entity.
void | use (flecs::entity entity, const char *alias=nullptr) const
| Create alias for entity.
int | count (flecs::id_t component_id) const
| Count entities matching a component.
int | count (flecs::entity_t first, flecs::entity_t second) const
| Count entities matching a pair.
template<typename T>
int | count () const
| Count entities matching a component.
template<typename First>
int | count (flecs::entity_t second) const
| Count entities matching a pair.
template<typename First, typename Second>
int | count () const
| Count entities matching a pair.
template<typename Func>
void | with (id_t with_id, const Func &func) const
| All entities created in function are created with id.
template<typename T, typename Func>
void | with (const Func &func) const
| All entities created in function are created with type.
template<typename First, typename Second, typename Func>
void | with (const Func &func) const
| All entities created in function are created with pair.
template<typename First, typename Func>
void | with (id_t second, const Func &func) const
| All entities created in function are created with pair.
template<typename Func>
void | with (id_t first, id_t second, const Func &func) const
| All entities created in function are created with pair.
template<typename Func>
void | scope (id_t parent, const Func &func) const
| All entities created in function are created in scope.
template<typename T, typename Func>
void | scope (const Func &func) const
| Same as scope(parent, func), but with T as parent.
flecs::scoped_world | scope (id_t parent) const
| Use provided scope for operations ran on returned world.
template<typename T>
flecs::scoped_world | scope () const
flecs::scoped_world | scope (const char *name) const
void | delete_with (id_t the_id) const
| Delete all entities with specified id.
void | delete_with (entity_t first, entity_t second) const
| Delete all entities with specified pair.
template<typename T>
void | delete_with () const
| Delete all entities with specified component.
template<typename First, typename Second>
void | delete_with () const
| Delete all entities with specified pair.
template<typename First>
void | delete_with (entity_t second) const
| Delete all entities with specified pair.
void | remove_all (id_t the_id) const
| Remove all instances of specified id.
void | remove_all (entity_t first, entity_t second) const
| Remove all instances of specified pair.
template<typename T>
void | remove_all () const
| Remove all instances of specified component.
template<typename First, typename Second>
void | remove_all () const
| Remove all instances of specified pair.
template<typename First>
void | remove_all (entity_t second) const
| Remove all instances of specified pair.
template<typename Func>
void | defer (const Func &func) const
| Defer all operations called in function.
void | defer_suspend () const
| Suspend deferring operations.
void | defer_resume () const
| Resume deferring operations.
bool | exists (flecs::entity_t e) const
| Check if entity id exists in the world.
bool | is_alive (flecs::entity_t e) const
| Check if entity id exists in the world.
bool | is_valid (flecs::entity_t e) const
| Check if entity id is valid.
flecs::entity | get_alive (flecs::entity_t e) const
| Get alive entity for id.
flecs::entity | make_alive (flecs::entity_t e) const
void | set_version (flecs::entity_t e) const
| Set version of entity to provided.
void | run_post_frame (ecs_fini_action_t action, void *ctx) const
const flecs::world_info_t * | get_info () const
| Get the world info.
ecs_ftime_t | delta_time () const
| Get delta_time.
void | shrink () const
| Free unused memory.
void | exclusive_access_begin (const char *thread_name=nullptr)
| Begin exclusive access.
void | exclusive_access_end (bool lock_world=false)
| End exclusive access.
template<typename T>
flecs::id | id () const
| Get id from a type.
template<typename ... Args>
flecs::id | id (Args &&... args) const
| Id factory.
template<typename First, typename Second>
flecs::id | pair () const
| Get pair id from relationship, object.
template<typename First>
flecs::id | pair (entity_t o) const
| Get pair id from relationship, object.
flecs::id | pair (entity_t r, entity_t o) const
| Get pair id from relationship, object.
template<typename T, typename... Args>
flecs::component< T > | component (Args &&... args) const
| Find or register component.
template<typename... Args>
flecs::untyped_component | component (Args &&... args) const
| Find or register untyped component.
template<typename... Args>
flecs::entity | entity (Args &&... args) const
| Create an entity.
template<typename E, if_t< is_enum< E >::value > = 0>
flecs::id | id (E value) const
| Convert enum constant to entity.
template<typename E, if_t< is_enum< E >::value > = 0>
flecs::entity | entity (E value) const
| Convert enum constant to entity.
template<typename... Args>
flecs::entity | prefab (Args &&... args) const
| Create a prefab.
template<typename T>
flecs::entity | entity (const char *name=nullptr) const
| Create an entity that's associated with a type.
template<typename T>
flecs::entity | prefab (const char *name=nullptr) const
| Create a prefab that's associated with a type.
flecs::event_builder | event (flecs::entity_t evt) const
| Create a new event.
template<typename E>
flecs::event_builder_typed< E > | event () const
| Create a new event.
template<typename E, if_t< is_enum< E >::value > = 0>
flecs::entity | to_entity (E constant) const
| Convert enum constant to entity.
template<typename T>
flecs::timer | timer () const
| Find or register a singleton timer.
template<typename... Args>
flecs::timer | timer (Args &&... args) const
| Find or register a timer.
void | randomize_timers () const
| Enable randomization of initial time values for timers.
int | script_run (const char *name, const char *str) const
| Run script.
int | script_run_file (const char *filename) const
| Run script from file.
script_builder | script (const char *name=nullptr) const
| Build script.
flecs::string | to_expr (flecs::entity_t tid, const void *value)
| Convert value to string.
template<typename T>
flecs::string | to_expr (const T *value)
| Convert value to string.
flecs::string | to_json (flecs::entity_t tid, const void *value)
| Serialize untyped value to JSON.
template<typename T>
flecs::string | to_json (const T *value)
| Serialize value to JSON.
flecs::string | to_json ()
| Serialize world to JSON.
const char * | from_json (flecs::entity_t tid, void *value, const char *json, flecs::from_json_desc_t *desc=nullptr)
| Deserialize value from JSON.
template<typename T>
const char * | from_json (T *value, const char *json, flecs::from_json_desc_t *desc=nullptr)
| Deserialize value from JSON.
const char * | from_json (const char *json, flecs::from_json_desc_t *desc=nullptr)
| Deserialize JSON into world.
const char * | from_json_file (const char *json, flecs::from_json_desc_t *desc=nullptr)
| Deserialize JSON file into world.
template<typename... Args>
flecs::metric_builder | metric (Args &&... args) const
| Create metric.
template<typename... Comps, typename... Args>
flecs::alert_builder< Comps... > | alert (Args &&... args) const
| Create alert.
void | init_builtin_components ()
template<typename... Comps, typename... Args>
flecs::alert_builder< Comps... > | alert (Args &&... args) const
| Create alert.
template<typename T, typename... Args>
flecs::component< T > | component (Args &&... args) const
| Find or register component.
template<typename... Args>
flecs::untyped_component | component (Args &&... args) const
| Find or register untyped component.
template<typename... Args>
flecs::entity | entity (Args &&... args) const
| Create an entity.
template<typename E, if_t< is_enum< E >::value > = 0>
flecs::id | id (E value) const
| Convert enum constant to entity.
template<typename E, if_t< is_enum< E >::value > = 0>
flecs::entity | entity (E value) const
| Convert enum constant to entity.
template<typename... Args>
flecs::entity | prefab (Args &&... args) const
| Create a prefab.
template<typename T>
flecs::entity | entity (const char *name=nullptr) const
| Create an entity that's associated with a type.
template<typename T>
flecs::entity | prefab (const char *name=nullptr) const
| Create a prefab that's associated with a type.
template<typename E, if_t< is_enum< E >::value > = 0>
flecs::entity | to_entity (E constant) const
| Convert enum constant to entity.
flecs::event_builder | event (flecs::entity_t evt) const
| Create a new event.
template<typename E>
flecs::event_builder_typed< E > | event () const
| Create a new event.
template<typename T>
flecs::id | id () const
| Get id from a type.
template<typename ... Args>
flecs::id | id (Args &&... args) const
| Id factory.
template<typename First, typename Second>
flecs::id | pair () const
| Get pair id from relationship, object.
template<typename First>
flecs::id | pair (entity_t o) const
| Get pair id from relationship, object.
flecs::id | pair (entity_t r, entity_t o) const
| Get pair id from relationship, object.
flecs::string | to_json (flecs::entity_t tid, const void *value)
| Serialize untyped value to JSON.
template<typename T>
flecs::string | to_json (const T *value)
| Serialize value to JSON.
flecs::string | to_json ()
| Serialize world to JSON.
const char * | from_json (flecs::entity_t tid, void *value, const char *json, flecs::from_json_desc_t *desc=nullptr)
| Deserialize value from JSON.
template<typename T>
const char * | from_json (T *value, const char *json, flecs::from_json_desc_t *desc=nullptr)
| Deserialize value from JSON.
const char * | from_json (const char *json, flecs::from_json_desc_t *desc=nullptr)
| Deserialize JSON into world.
const char * | from_json_file (const char *json, flecs::from_json_desc_t *desc=nullptr)
| Deserialize JSON file into world.
template<typename... Args>
flecs::metric_builder | metric (Args &&... args) const
| Create metric.
template<typename... Comps, typename... Args>
observer_builder< Comps... > | observer (Args &&... args) const
template<typename... Comps, typename... Args>
system_builder< Comps... > | system (Args &&... args) const
template<typename T>
flecs::timer | timer () const
| Find or register a singleton timer.
flecs::app_builder | app ()
| Return app builder.
flecs::app_builder | app ()
| Return app builder.

## Public Attributes
world_t * | world_
template<typename... Args>
flecs::term | term (Args &&... args) const
| Create a term.
template<typename T>
flecs::term | term () const
| Create a term for a (component) type.
template<typename First, typename Second>
flecs::term | term () const
| Create a term for a pair.
flecs::observer | observer (flecs::entity e) const
| Observer builder.
template<typename... Components, typename... Args>
flecs::observer_builder< Components... > | observer (Args &&... args) const
| Create a new observer.
template<typename... Comps, typename... Args>
flecs::query< Comps... > | query (Args &&... args) const
| Create a query.
flecs::query | query (flecs::entity query_entity) const
| Create a query from entity.
template<typename... Comps, typename... Args>
flecs::query_builder< Comps... > | query_builder (Args &&... args) const
| Create a query builder.
template<typename Func>
void | each (Func &&func) const
| Iterate over all entities with components in argument list of function.
template<typename T, typename Func>
void | each (Func &&func) const
| Iterate over all entities with provided component.
template<typename Func>
void | each (flecs::id_t term_id, Func &&func) const
| Iterate over all entities with provided (component) id.
template<typename Module>
flecs::entity | module (const char *name=nullptr) const
| Define a module.
template<typename Module>
flecs::entity | import ()
| Import a module.
flecs::pipeline_builder | pipeline () const
| Create a new pipeline.
template<typename Pipeline, if_not_t< is_enum< Pipeline >::value > = 0>
flecs::pipeline_builder | pipeline () const
| Create a new pipeline.
void | set_pipeline (const flecs::entity pip) const
| Set pipeline.
template<typename Pipeline>
void | set_pipeline () const
| Set pipeline.
flecs::entity | get_pipeline () const
| Get pipeline.
bool | progress (ecs_ftime_t delta_time=0.0) const
| Progress world one tick.
void | run_pipeline (const flecs::entity_t pip, ecs_ftime_t delta_time=0.0) const
| Run pipeline.
template<typename Pipeline, if_not_t< is_enum< Pipeline >::value > = 0>
void | run_pipeline (ecs_ftime_t delta_time=0.0) const
| Run pipeline.
void | set_time_scale (ecs_ftime_t mul) const
| Set timescale.
void | set_target_fps (ecs_ftime_t target_fps) const
| Set target FPS.
void | reset_clock () const
| Reset simulation clock.
void | set_threads (int32_t threads) const
| Set number of threads.
int32_t | get_threads () const
| Set number of threads.
void | set_task_threads (int32_t task_threads) const
| Set number of task threads.
bool | using_task_threads () const
| Returns true if task thread use has been requested.
flecs::system | system (flecs::entity e) const
| Upcast entity to a system.
template<typename... Components, typename... Args>
flecs::system_builder< Components... > | system (Args &&... args) const
| Create a new system.
flecs::cursor | cursor (flecs::entity_t tid, void *ptr)
| Return meta cursor to value.
template<typename T>
flecs::cursor | cursor (void *ptr)
| Return meta cursor to value.
flecs::entity | primitive (flecs::meta::primitive_kind_t kind)
| Create primitive type.
flecs::entity | array (flecs::entity_t elem_id, int32_t array_count)
| Create array type.
template<typename T>
flecs::entity | array (int32_t array_count)
| Create array type.
flecs::entity | vector (flecs::entity_t elem_id)
| Create vector type.
template<typename T>
flecs::entity | vector ()
| Create vector type.
flecs::cursor | cursor (flecs::entity_t tid, void *ptr)
| Return meta cursor to value.
template<typename T>
flecs::cursor | cursor (void *ptr)
| Return meta cursor to value.
flecs::entity | primitive (flecs::meta::primitive_kind_t kind)
| Create primitive type.
flecs::entity | array (flecs::entity_t elem_id, int32_t array_count)
| Create array type.
template<typename T>
flecs::entity | array (int32_t array_count)
| Create array type.
flecs::entity | vector (flecs::entity_t elem_id)
| Create vector type.
template<typename T>
flecs::entity | vector ()
| Create vector type.
template<typename Module>
flecs::entity | module (const char *name=nullptr) const
| Define a module.
template<typename Module>
flecs::entity | import ()
| Import a module.
flecs::observer | observer (flecs::entity e) const
| Observer builder.
template<typename... Components, typename... Args>
flecs::observer_builder< Components... > | observer (Args &&... args) const
| Create a new observer.
flecs::pipeline_builder | pipeline () const
| Create a new pipeline.
template<typename Pipeline, if_not_t< is_enum< Pipeline >::value > = 0>
flecs::pipeline_builder | pipeline () const
| Create a new pipeline.
void | set_pipeline (const flecs::entity pip) const
| Set pipeline.
template<typename Pipeline>
void | set_pipeline () const
| Set pipeline.
flecs::entity | get_pipeline () const
| Get pipeline.
bool | progress (ecs_ftime_t delta_time=0.0) const
| Progress world one tick.
void | run_pipeline (const flecs::entity_t pip, ecs_ftime_t delta_time=0.0) const
| Run pipeline.
template<typename Pipeline, if_not_t< is_enum< Pipeline >::value > = 0>
void | run_pipeline (ecs_ftime_t delta_time=0.0) const
| Run pipeline.
void | set_time_scale (ecs_ftime_t mul) const
| Set timescale.
void | set_target_fps (ecs_ftime_t target_fps) const
| Set target FPS.
void | reset_clock () const
| Reset simulation clock.
void | set_threads (int32_t threads) const
| Set number of threads.
int32_t | get_threads () const
| Set number of threads.
void | set_task_threads (int32_t task_threads) const
| Set number of task threads.
bool | using_task_threads () const
| Returns true if task thread use has been requested.
template<typename... Comps, typename... Args>
flecs::query< Comps... > | query (Args &&... args) const
| Create a query.
flecs::query | query (flecs::entity query_entity) const
| Create a query from entity.
template<typename... Comps, typename... Args>
flecs::query_builder< Comps... > | query_builder (Args &&... args) const
| Create a query builder.
template<typename Func>
void | each (Func &&func) const
| Iterate over all entities with components in argument list of function.
template<typename T, typename Func>
void | each (Func &&func) const
| Iterate over all entities with provided component.
template<typename Func>
void | each (flecs::id_t term_id, Func &&func) const
| Iterate over all entities with provided (component) id.
flecs::system | system (flecs::entity e) const
| Upcast entity to a system.
template<typename... Components, typename... Args>
flecs::system_builder< Components... > | system (Args &&... args) const
| Create a new system.
template<typename... Args>
flecs::term | term (Args &&... args) const
| Create a term.
template<typename T>
flecs::term | term () const
| Create a term for a (component) type.
template<typename First, typename Second>
flecs::term | term () const
| Create a term for a pair.

## Detailed Description

The world.

The world is the container of all ECS data and systems. If the world is deleted, all data in the world will be deleted as well.

Definition at line 172 of file world.hpp.

## Constructor & Destructor Documentation

## ◆ world() [1/5]

flecs::world::world | ( |  | ) |
| inlineexplicit

Create world.

Definition at line 175 of file world.hpp.

## ◆ world() [2/5]

flecs::world::world | ( | int | argc,
|  | char * | argv[] )
| inlineexplicit

Create world with command line arguments.

Currently command line arguments are not interpreted, but they may be used in the future to configure Flecs parameters.

Definition at line 184 of file world.hpp.

## ◆ world() [3/5]

flecs::world::world | ( | world_t * | w | ) |
| inlineexplicit

Create world from C world.

Definition at line 191 of file world.hpp.

## ◆ world() [4/5]

flecs::world::world | ( | const world & | obj | ) |
| inline

Not allowed to copy a world.

May only take a reference.

Definition at line 200 of file world.hpp.

## ◆ world() [5/5]

flecs::world::world | ( | world && | obj | ) |
| inlinenoexcept

Definition at line 212 of file world.hpp.

## ◆ ~world()

flecs::world::~world | ( |  | ) |
| inline

Definition at line 243 of file world.hpp.

## Member Function Documentation

## ◆ add() [1/4]

template<typename T>

void flecs::world::add | ( |  | ) | const
| inline

Add singleton component.

Definition at line 263 of file world.hpp.

## ◆ add() [2/4]

template<typename First, typename Second>

void flecs::world::add | ( |  | ) | const
| inline

Adds a pair to the singleton component.

Template Parameters

  First | The first element of the pair
  Second | The second element of the pair

Definition at line 269 of file world.hpp.

## ◆ add() [3/4]

void flecs::world::add | ( | flecs::entity_t | first,
|  | flecs::entity_t | second ) const
| inline

Adds a pair to the singleton entity.

Parameters

  first | The first element of the pair
  second | The second element of the pair

Definition at line 280 of file world.hpp.

## ◆ add() [4/4]

template<typename First>

void flecs::world::add | ( | flecs::entity_t | second | ) | const
| inline

Adds a pair to the singleton component.

Template Parameters

  First | The first element of the pair

Parameters

  second | The second element of the pair.

Definition at line 275 of file world.hpp.

## ◆ app()

flecs::app_builder app | ( |  | ) |

Return app builder.

The app builder is a convenience wrapper around a loop that runs world::progress. An app allows for writing platform agnostic code, as it provides hooks to modules for overtaking the main loop which is required for frameworks like emscripten.

Definition at line 19 of file mixin.inl.

## ◆ async_stage()

flecs::world flecs::world::async_stage | ( |  | ) | const
| inline

Create asynchronous stage.

An asynchronous stage can be used to asynchronously queue operations for later merging with the world. An asynchronous stage is similar to a regular stage, except that it does not allow reading from the world.

Asynchronous stages are never merged automatically, and must therefore be manually merged with the ecs_merge function. It is not necessary to call defer_begin or defer_end before and after enqueuing commands, as an asynchronous stage unconditionally defers operations.

The application must ensure that no commands are added to the stage while the stage is being merged.

Returns
  The stage.

Definition at line 512 of file world.hpp.

## ◆ atfini()

void flecs::world::atfini | ( | ecs_fini_action_t | action,
|  | void * | ctx = nullptr ) const
| inline

Register action to be executed when world is destroyed.

Definition at line 285 of file world.hpp.

## ◆ c_ptr()

world_t * flecs::world::c_ptr | ( |  | ) | const
| inline

Obtain pointer to C world object.

Definition at line 272 of file world.hpp.

## ◆ children()

template<typename Func>

void flecs::world::children | ( | Func && | f | ) | const
| inline

Iterate entities in root of world Accepts a callback with the following signature:

void(*)(flecs::entity e);
flecs::entity
Entity.
Definition entity.hpp:30

Definition at line 309 of file world.hpp.

## ◆ component()

template<typename... Args>

flecs::untyped_component component | ( | Args &&... | args | ) | const

Find or register untyped component.

Method available on flecs::world class.

## ◆ count() [1/5]

template<typename T>

int flecs::world::count | ( |  | ) | const
| inline

Count entities matching a component.

Template Parameters

  T | The component type.

Definition at line 1034 of file world.hpp.

## ◆ count() [2/5]

template<typename First, typename Second>

int flecs::world::count | ( |  | ) | const
| inline

Count entities matching a pair.

Template Parameters

  First | The first element of the pair.
  Second | The second element of the pair.

Definition at line 1054 of file world.hpp.

## ◆ count() [3/5]

int flecs::world::count | ( | flecs::entity_t | first,
|  | flecs::entity_t | second ) const
| inline

Count entities matching a pair.

Parameters

  first | The first element of the pair.
  second | The second element of the pair.

Definition at line 1025 of file world.hpp.

## ◆ count() [4/5]

template<typename First>

int flecs::world::count | ( | flecs::entity_t | second | ) | const
| inline

Count entities matching a pair.

Template Parameters

  First | The first element of the pair.

Parameters

  second | The second element of the pair.

Definition at line 1044 of file world.hpp.

## ◆ count() [5/5]

int flecs::world::count | ( | flecs::id_t | component_id | ) | const
| inline

Count entities matching a component.

Parameters

  component_id | The component id.

Definition at line 1016 of file world.hpp.

## ◆ cursor()

flecs::cursor cursor | ( | flecs::entity_t | tid,
|  | void * | ptr )

Return meta cursor to value.

Definition at line 14 of file world.inl.

## ◆ defer()

template<typename Func>

void flecs::world::defer | ( | const Func & | func | ) | const
| inline

Defer all operations called in function.

See also
  flecs::world::defer_begin()
  flecs::world::defer_end()
  flecs::world::defer_is_deferred()
  flecs::world::defer_resume()
  flecs::world::defer_suspend()

Definition at line 1190 of file world.hpp.

## ◆ defer_begin()

bool flecs::world::defer_begin | ( |  | ) | const
| inline

Defer operations until end of frame.

When this operation is invoked while iterating, operations inbetween the defer_begin() and defer_end() operations are executed at the end of the frame.

This operation is thread safe.

Returns
  true if world changed from non-deferred mode to deferred mode.

See also
  ecs_defer_begin()
  flecs::world::defer()
  flecs::world::defer_end()
  flecs::world::is_deferred()
  flecs::world::defer_resume()
  flecs::world::defer_suspend()

Definition at line 372 of file world.hpp.

## ◆ defer_end()

bool flecs::world::defer_end | ( |  | ) | const
| inline

End block of operations to defer.

See defer_begin().

This operation is thread safe.

Returns
  true if world changed from deferred mode to non-deferred mode.

See also
  ecs_defer_end()
  flecs::world::defer()
  flecs::world::defer_begin()
  flecs::world::is_deferred()
  flecs::world::defer_resume()
  flecs::world::defer_suspend()

Definition at line 390 of file world.hpp.

## ◆ defer_resume()

void flecs::world::defer_resume | ( |  | ) | const
| inline

Resume deferring operations.

See also
  ecs_defer_resume()
  flecs::world::defer()
  flecs::world::defer_begin()
  flecs::world::defer_end()
  flecs::world::defer_is_deferred()
  flecs::world::defer_suspend()

Definition at line 1218 of file world.hpp.

## ◆ defer_suspend()

void flecs::world::defer_suspend | ( |  | ) | const
| inline

Suspend deferring operations.

See also
  ecs_defer_suspend()
  flecs::world::defer()
  flecs::world::defer_begin()
  flecs::world::defer_end()
  flecs::world::defer_is_deferred()
  flecs::world::defer_resume()

Definition at line 1205 of file world.hpp.

## ◆ delete_with() [1/5]

template<typename T>

void flecs::world::delete_with | ( |  | ) | const
| inline

Delete all entities with specified component.

Definition at line 1137 of file world.hpp.

## ◆ delete_with() [2/5]

template<typename First, typename Second>

void flecs::world::delete_with | ( |  | ) | const
| inline

Delete all entities with specified pair.

Definition at line 1143 of file world.hpp.

## ◆ delete_with() [3/5]

void flecs::world::delete_with | ( | entity_t | first,
|  | entity_t | second ) const
| inline

Delete all entities with specified pair.

Definition at line 1131 of file world.hpp.

## ◆ delete_with() [4/5]

template<typename First>

void flecs::world::delete_with | ( | entity_t | second | ) | const
| inline

Delete all entities with specified pair.

Definition at line 1149 of file world.hpp.

## ◆ delete_with() [5/5]

void flecs::world::delete_with | ( | id_t | the_id | ) | const
| inline

Delete all entities with specified id.

Definition at line 1126 of file world.hpp.

## ◆ delta_time()

ecs_ftime_t flecs::world::delta_time | ( |  | ) | const
| inline

Get delta_time.

Definition at line 1287 of file world.hpp.

## ◆ dim()

void flecs::world::dim | ( | int32_t | entity_count | ) | const
| inline

Preallocate memory for number of entities.

This function preallocates memory for the entity index.

Parameters

  entity_count | Number of entities to preallocate memory for.

See also
  ecs_dim()

Definition at line 607 of file world.hpp.

## ◆ emplace()

template<typename T, typename ... Args>

void flecs::world::emplace | ( | Args &&... | args | ) | const
| inline

Definition at line 728 of file world.hpp.

## ◆ enable_range_check()

void flecs::world::enable_range_check | ( | bool | enabled = true | ) | const
| inline

Enforce that operations cannot modify entities outside of range.

This function ensures that only entities within the specified range can be modified. Use this function if specific parts of the code only are allowed to modify a certain set of entities, as could be the case for networked applications.

Parameters

  enabled | True if range check should be enabled, false if not.

See also
  ecs_enable_range_check()

Definition at line 633 of file world.hpp.

## ◆ ensure()

template<typename T>

T & flecs::world::ensure | ( |  | ) | const
| inline

Ensure singleton component.

Definition at line 97 of file world.hpp.

## ◆ event() [1/2]

template<typename E>

flecs::event_builder_typed< E > event | ( |  | ) | const

Create a new event.

Template Parameters

  E | The event type.

Returns
  Event builder.

## ◆ event() [2/2]

flecs::event_builder event | ( | flecs::entity_t | evt | ) | const

Create a new event.

Parameters

  evt | The event id.

Returns
  Event builder.

## ◆ exclusive_access_begin()

void flecs::world::exclusive_access_begin | ( | const char * | thread_name = nullptr | ) |
| inline

Begin exclusive access.

Parameters

  thread_name | Optional thread name for improved debug messages.

See also
  ecs_exclusive_access_begin()

Definition at line 1304 of file world.hpp.

## ◆ exclusive_access_end()

void flecs::world::exclusive_access_end | ( | bool | lock_world = false | ) |
| inline

End exclusive access.

Parameters

  lock_world | Lock world for all threads, allow readonly operations.

See also
  ecs_exclusive_access_end()

Definition at line 1313 of file world.hpp.

## ◆ exists()

bool flecs::world::exists | ( | flecs::entity_t | e | ) | const
| inline

Check if entity id exists in the world.

See also
  ecs_exists()
  flecs::world::is_alive()
  flecs::world::is_valid()

Definition at line 1228 of file world.hpp.

## ◆ frame_begin()

ecs_ftime_t flecs::world::frame_begin | ( | float | delta_time = 0 | ) | const
| inline

Begin frame.

When an application does not use progress() to control the main loop, it can still use Flecs features such as FPS limiting and time measurements. This operation needs to be invoked whenever a new frame is about to get processed.

Calls to frame_begin() must always be followed by frame_end().

The function accepts a delta_time parameter, which will get passed to systems. This value is also used to compute the amount of time the function needs to sleep to ensure it does not exceed the target_fps, when it is set. When 0 is provided for delta_time, the time will be measured.

This function should only be ran from the main thread.

Parameters

  delta_time | Time elapsed since the last frame.

Returns
  The provided delta_time, or measured time if 0 was provided.

See also
  ecs_frame_begin()
  flecs::world::frame_end()

Definition at line 316 of file world.hpp.

## ◆ frame_end()

void flecs::world::frame_end | ( |  | ) | const
| inline

End frame.

This operation must be called at the end of the frame, and always after frame_begin().

This function should only be ran from the main thread.

See also
  ecs_frame_end()
  flecs::world::frame_begin()

Definition at line 329 of file world.hpp.

## ◆ from_json() [1/3]

const char * from_json | ( | const char * | json,
|  | flecs::from_json_desc_t * | desc = nullptr )

Deserialize JSON into world.

Definition at line 61 of file world.inl.

## ◆ from_json() [2/3]

const char * from_json | ( | flecs::entity_t | tid,
|  | void * | value,
|  | const char * | json,
|  | flecs::from_json_desc_t * | desc = nullptr )

Deserialize value from JSON.

Definition at line 41 of file world.inl.

## ◆ from_json() [3/3]

template<typename T>

const char * from_json | ( | T * | value,
|  | const char * | json,
|  | flecs::from_json_desc_t * | desc = nullptr )

Deserialize value from JSON.

Definition at line 51 of file world.inl.

## ◆ from_json_file()

const char * from_json_file | ( | const char * | json,
|  | flecs::from_json_desc_t * | desc = nullptr )

Deserialize JSON file into world.

Definition at line 70 of file world.inl.

## ◆ get() [1/6]

template<typename T>

const T & flecs::world::get | ( |  | ) | const
| inline

Definition at line 166 of file world.hpp.

## ◆ get() [2/6]

template<typename First, typename Second, typename P, typename A>

const A & flecs::world::get | ( |  | ) | const
| inline

Get singleton pair.

Definition at line 172 of file world.hpp.

## ◆ get() [3/6]

template<typename Func, if_t< is_callable< Func >::value >>

void flecs::world::get | ( | const Func & | func | ) | const
| inline

Get singleton component inside a callback.

Definition at line 343 of file world.hpp.

## ◆ get() [4/6]

const void * flecs::world::get | ( | flecs::entity_t | r,
|  | flecs::entity_t | t ) const
| inline

Get singleton component.

Definition at line 160 of file world.hpp.

## ◆ get() [5/6]

const void * flecs::world::get | ( | flecs::id_t | id | ) | const
| inline

Get singleton component.

Definition at line 155 of file world.hpp.

## ◆ get() [6/6]

template<typename First, typename Second>

const First & flecs::world::get | ( | Second | second | ) | const

Get singleton pair.

Definition at line 178 of file world.hpp.

## ◆ get_alive()

flecs::entity flecs::world::get_alive | ( | flecs::entity_t | e | ) | const
| inline

Get alive entity for id.

Returns the entity with the current generation.

See also
  ecs_get_alive()

Definition at line 356 of file world.hpp.

## ◆ get_binding_ctx()

void * flecs::world::get_binding_ctx | ( |  | ) | const
| inline

Get world binding context.

This operation retrieves a previously set world binding context.

Returns
  The context set with set_binding_ctx(). If no context was set, the function returns NULL.

See also
  ecs_get_binding_ctx()
  flecs::world::set_binding_ctx()

Definition at line 596 of file world.hpp.

## ◆ get_ctx()

void * flecs::world::get_ctx | ( |  | ) | const
| inline

Get world context.

This operation retrieves a previously set world context.

Returns
  The context set with set_binding_ctx(). If no context was set, the function returns NULL.

See also
  ecs_get_ctx()
  flecs::world::set_ctx()

Definition at line 568 of file world.hpp.

## ◆ get_info()

const flecs::world_info_t * flecs::world::get_info | ( |  | ) | const
| inline

Get the world info.

See also
  ecs_get_world_info()

Definition at line 1282 of file world.hpp.

## ◆ get_mut() [1/5]

template<typename T>

T & flecs::world::get_mut | ( |  | ) | const
| inline

Definition at line 222 of file world.hpp.

## ◆ get_mut() [2/5]

template<typename First, typename Second, typename P, typename A>

A & flecs::world::get_mut | ( |  | ) | const
| inline

Get mutable singleton pair.

Definition at line 228 of file world.hpp.

## ◆ get_mut() [3/5]

void * flecs::world::get_mut | ( | flecs::entity_t | r,
|  | flecs::entity_t | t ) const
| inline

Get mutable singleton pair.

Definition at line 216 of file world.hpp.

## ◆ get_mut() [4/5]

void * flecs::world::get_mut | ( | flecs::id_t | id | ) | const
| inline

Get mutable singleton component.

Definition at line 211 of file world.hpp.

## ◆ get_mut() [5/5]

template<typename First, typename Second>

First & flecs::world::get_mut | ( | Second | second | ) | const
| inline

Get mutable singleton pair.

Definition at line 234 of file world.hpp.

## ◆ get_ref()

template<typename T>

ref< T > flecs::world::get_ref | ( |  | ) | const
| inline

Get ref singleton component.

Definition at line 122 of file world.hpp.

## ◆ get_scope()

flecs::entity flecs::world::get_scope | ( |  | ) | const
| inline

Get current scope.

Returns
  The current scope.

See also
  ecs_get_scope()
  flecs::world::set_scope()

Definition at line 81 of file world.hpp.

## ◆ get_stage()

flecs::world flecs::world::get_stage | ( | int32_t | stage_id | ) | const
| inline

Get stage-specific world pointer.

Flecs threads can safely invoke the API as long as they have a private context to write to, also referred to as the stage. This function returns a pointer to a stage, disguised as a world pointer.

Note that this function does not(!) create a new world. It simply wraps the existing world in a thread-specific context, which the API knows how to unwrap. The reason the stage is returned as an ecs_world_t is so that it can be passed transparently to the existing API functions, vs. having to create a dediated API for threading.

Parameters

  stage_id | The index of the stage to retrieve.

Returns
  A thread-specific pointer to the world.

Definition at line 493 of file world.hpp.

## ◆ get_stage_count()

int32_t flecs::world::get_stage_count | ( |  | ) | const
| inline

Get number of configured stages.

Return number of stages set by set_stage_count().

Returns
  The number of stages used for threading.

See also
  ecs_get_stage_count()
  flecs::world::set_stage_count()

Definition at line 436 of file world.hpp.

## ◆ get_stage_id()

int32_t flecs::world::get_stage_id | ( |  | ) | const
| inline

Get current stage id.

The stage id can be used by an application to learn about which stage it is using, which typically corresponds with the worker thread id.

Returns
  The stage id.

Definition at line 446 of file world.hpp.

## ◆ get_world()

flecs::world flecs::world::get_world | ( |  | ) | const
| inline

Get actual world.

If the current object points to a stage, this operation will return the actual world.

Returns
  The actual world.

Definition at line 524 of file world.hpp.

## ◆ has() [1/4]

template<typename T>

bool flecs::world::has | ( |  | ) | const
| inline

Test if world has singleton component.

Definition at line 240 of file world.hpp.

## ◆ has() [2/4]

template<typename First, typename Second>

bool flecs::world::has | ( |  | ) | const
| inline

Test if world has the provided pair.

Template Parameters

  First | The first element of the pair
  Second | The second element of the pair

Definition at line 246 of file world.hpp.

## ◆ has() [3/4]

bool flecs::world::has | ( | flecs::id_t | first,
|  | flecs::id_t | second ) const
| inline

Test if world has the provided pair.

Parameters

  first | The first element of the pair
  second | The second element of the pair

Definition at line 257 of file world.hpp.

## ◆ has() [4/4]

template<typename First>

bool flecs::world::has | ( | flecs::id_t | second | ) | const
| inline

Test if world has the provided pair.

Template Parameters

  First | The first element of the pair

Parameters

  second | The second element of the pair.

Definition at line 252 of file world.hpp.

## ◆ id() [1/2]

template<typename T>

flecs::id flecs::world::id | ( |  | ) | const
| inline

Get id from a type.

Definition at line 70 of file impl.hpp.

## ◆ id() [2/2]

template<typename ... Args>

flecs::id flecs::world::id | ( | Args &&... | args | ) | const
| inline

Id factory.

Definition at line 75 of file impl.hpp.

## ◆ init_builtin_components()

void flecs::world::init_builtin_components | ( |  | ) |
| inline

Definition at line 11 of file world.hpp.

## ◆ is_alive()

bool flecs::world::is_alive | ( | flecs::entity_t | e | ) | const
| inline

Check if entity id exists in the world.

See also
  ecs_is_alive()
  flecs::world::exists()
  flecs::world::is_valid()

Definition at line 1238 of file world.hpp.

## ◆ is_deferred()

bool flecs::world::is_deferred | ( |  | ) | const
| inline

Test whether deferring is enabled.

Returns
  True if deferred, false if not.

See also
  ecs_is_deferred()
  flecs::world::defer()
  flecs::world::defer_begin()
  flecs::world::defer_end()
  flecs::world::defer_resume()
  flecs::world::defer_suspend()

Definition at line 405 of file world.hpp.

## ◆ is_readonly()

bool flecs::world::is_readonly | ( |  | ) | const
| inline

Test whether the current world object is readonly.

This function allows the code to test whether the currently used world object is readonly or whether it allows for writing.

Returns
  True if the world or stage is readonly.

See also
  ecs_stage_is_readonly()
  flecs::world::readonly_begin()
  flecs::world::readonly_end()

Definition at line 540 of file world.hpp.

## ◆ is_stage()

bool flecs::world::is_stage | ( |  | ) | const
| inline

Test if is a stage.

If this function returns false, it is guaranteed that this is a valid world object.

Returns
  True if the world is a stage, false if not.

Definition at line 456 of file world.hpp.

## ◆ is_valid()

bool flecs::world::is_valid | ( | flecs::entity_t | e | ) | const
| inline

Check if entity id is valid.

Invalid entities cannot be used with API functions.

See also
  ecs_is_valid()
  flecs::world::exists()
  flecs::world::is_alive()

Definition at line 1249 of file world.hpp.

## ◆ lookup()

entity flecs::world::lookup | ( | const char * | name,
|  | const char * | sep = "::",
|  | const char * | root_sep = "::",
|  | bool | recursive = true ) const
| inline

Lookup entity by name.

Parameters

  name | Entity name.
  recursive | When false, only the current scope is searched.

Returns
  The entity if found, or 0 if not found.

Definition at line 90 of file world.hpp.

## ◆ make_alive()

flecs::entity flecs::world::make_alive | ( | flecs::entity_t | e | ) | const
| inline

See also
  ecs_make_alive()

Definition at line 361 of file world.hpp.

## ◆ make_owner()

void flecs::world::make_owner | ( |  | ) |
| inline

Make current world object owner of the world.

This may only be called on one flecs::world object, an may only be called once. Failing to do so will result in undefined behavior.

This operation allows a custom (C) world to be wrapped by a C++ object, and transfer ownership so that the world is automatically cleaned up.

Definition at line 257 of file world.hpp.

## ◆ merge()

void flecs::world::merge | ( |  | ) | const
| inline

Merge world or stage.

When automatic merging is disabled, an application can call this operation on either an individual stage, or on the world which will merge all stages. This operation may only be called when staging is not enabled (either after progress() or after readonly_end()).

This operation may be called on an already merged stage or world.

See also
  ecs_merge()

Definition at line 475 of file world.hpp.

## ◆ modified()

template<typename T>

void flecs::world::modified | ( |  | ) | const
| inline

Mark singleton component as modified.

Definition at line 104 of file world.hpp.

## ◆ module()

template<typename Module>

flecs::entity module | ( | const char * | name = nullptr | ) | const

Define a module.

This operation is not mandatory, but can be called inside the module ctor to obtain the entity associated with the module, or override the module name.

Template Parameters

  Module | module class.

Returns
  Module entity.

## ◆ observer() [1/2]

template<typename... Comps, typename... Args>

observer_builder< Comps... > flecs::world::observer | ( | Args &&... | args | ) | const
| inline

Definition at line 46 of file impl.hpp.

## ◆ observer() [2/2]

flecs::observer observer | ( | flecs::entity | e | ) | const

Observer builder.

Upcast entity to an observer. The provided entity must be an observer.

Parameters

  e | The entity.

Returns
  An observer object.

## ◆ operator world_t *()

flecs::world::operator world_t * | ( |  | ) | const
| inline

Definition at line 248 of file world.hpp.

## ◆ operator=() [1/2]

world & flecs::world::operator= | ( | const world & | obj | ) |
| inlinenoexcept

Definition at line 205 of file world.hpp.

## ◆ operator=() [2/2]

world & flecs::world::operator= | ( | world && | obj | ) |
| inlinenoexcept

Definition at line 217 of file world.hpp.

## ◆ pair() [1/3]

template<typename First, typename Second>

flecs::id flecs::world::pair | ( |  | ) | const
| inline

Get pair id from relationship, object.

Definition at line 80 of file impl.hpp.

## ◆ pair() [2/3]

template<typename First>

flecs::id flecs::world::pair | ( | entity_t | o | ) | const
| inline

Get pair id from relationship, object.

Definition at line 89 of file impl.hpp.

## ◆ pair() [3/3]

flecs::id flecs::world::pair | ( | entity_t | r,
|  | entity_t | o ) const
| inline

Get pair id from relationship, object.

Definition at line 100 of file impl.hpp.

## ◆ pipeline()

flecs::pipeline_builder pipeline | ( |  | ) | const

Create a new pipeline.

Returns
  A pipeline builder.

## ◆ query()

template<typename... Comps, typename... Args>

flecs::query< Comps... > query | ( | Args &&... | args | ) | const

Create a query.

See also
  ecs_query_init

## ◆ quit()

void flecs::world::quit | ( |  | ) | const
| inline

Signal application should quit.

After calling this operation, the next call to progress() returns false.

Definition at line 279 of file world.hpp.

## ◆ randomize_timers()

void flecs::world::randomize_timers | ( |  | ) | const
| inline

Enable randomization of initial time values for timers.

See also
  ecs_randomize_timers

Definition at line 56 of file impl.hpp.

## ◆ readonly_begin()

bool flecs::world::readonly_begin | ( | bool | multi_threaded = false | ) | const
| inline

Begin readonly mode.

Parameters

  multi_threaded | Whether to enable readonly/multi threaded mode.

Returns
  Whether world is currently readonly.

See also
  ecs_readonly_begin()
  flecs::world::is_readonly()
  flecs::world::readonly_end()

Definition at line 343 of file world.hpp.

## ◆ readonly_end()

void flecs::world::readonly_end | ( |  | ) | const
| inline

End readonly mode.

See also
  ecs_readonly_end()
  flecs::world::is_readonly()
  flecs::world::readonly_begin()

Definition at line 353 of file world.hpp.

## ◆ release()

void flecs::world::release | ( |  | ) |
| inline

Definition at line 226 of file world.hpp.

## ◆ remove() [1/4]

template<typename T>

void flecs::world::remove | ( |  | ) | const
| inline

Remove singleton component.

Definition at line 286 of file world.hpp.

## ◆ remove() [2/4]

template<typename First, typename Second>

void flecs::world::remove | ( |  | ) | const
| inline

Removes the pair singleton component.

Template Parameters

  First | The first element of the pair
  Second | The second element of the pair

Definition at line 292 of file world.hpp.

## ◆ remove() [3/4]

void flecs::world::remove | ( | flecs::entity_t | first,
|  | flecs::entity_t | second ) const
| inline

Removes the pair singleton component.

Parameters

  first | The first element of the pair
  second | The second element of the pair

Definition at line 303 of file world.hpp.

## ◆ remove() [4/4]

template<typename First>

void flecs::world::remove | ( | flecs::entity_t | second | ) | const
| inline

Removes the pair singleton component.

Template Parameters

  First | The first element of the pair

Parameters

  second | The second element of the pair.

Definition at line 298 of file world.hpp.

## ◆ remove_all() [1/5]

template<typename T>

void flecs::world::remove_all | ( |  | ) | const
| inline

Remove all instances of specified component.

Definition at line 1165 of file world.hpp.

## ◆ remove_all() [2/5]

template<typename First, typename Second>

void flecs::world::remove_all | ( |  | ) | const
| inline

Remove all instances of specified pair.

Definition at line 1171 of file world.hpp.

## ◆ remove_all() [3/5]

void flecs::world::remove_all | ( | entity_t | first,
|  | entity_t | second ) const
| inline

Remove all instances of specified pair.

Definition at line 1159 of file world.hpp.

## ◆ remove_all() [4/5]

template<typename First>

void flecs::world::remove_all | ( | entity_t | second | ) | const
| inline

Remove all instances of specified pair.

Definition at line 1177 of file world.hpp.

## ◆ remove_all() [5/5]

void flecs::world::remove_all | ( | id_t | the_id | ) | const
| inline

Remove all instances of specified id.

Definition at line 1154 of file world.hpp.

## ◆ reset()

void flecs::world::reset | ( |  | ) |
| inline

Deletes and recreates the world.

Definition at line 262 of file world.hpp.

## ◆ run_post_frame()

void flecs::world::run_post_frame | ( | ecs_fini_action_t | action,
|  | void * | ctx ) const
| inline

Definition at line 1274 of file world.hpp.

## ◆ scope() [1/5]

template<typename T>

flecs::scoped_world flecs::world::scope | ( |  | ) | const
| inline

Definition at line 408 of file world.hpp.

## ◆ scope() [2/5]

flecs::scoped_world flecs::world::scope | ( | const char * | name | ) | const
| inline

Definition at line 413 of file world.hpp.

## ◆ scope() [3/5]

template<typename T, typename Func>

void flecs::world::scope | ( | const Func & | func | ) | const
| inline

Same as scope(parent, func), but with T as parent.

Definition at line 1110 of file world.hpp.

## ◆ scope() [4/5]

flecs::scoped_world flecs::world::scope | ( | id_t | parent | ) | const
| inline

Use provided scope for operations ran on returned world.

Operations need to be ran in a single statement.

Definition at line 403 of file world.hpp.

## ◆ scope() [5/5]

template<typename Func>

void flecs::world::scope | ( | id_t | parent,
|  | const Func & | func ) const
| inline

All entities created in function are created in scope.

All operations called in function (such as lookup) are relative to scope.

Definition at line 1101 of file world.hpp.

## ◆ set() [1/7]

template<typename First, typename Second, typename P = flecs::pair<First, Second>, typename A = actual_type_t<P>, if_not_t< flecs::is_pair< First >::value > = 0>

void flecs::world::set | ( | A && | value | ) | const
| inline

Set singleton pair.

Definition at line 708 of file world.hpp.

## ◆ set() [2/7]

template<typename First, typename Second, typename P = flecs::pair<First, Second>, typename A = actual_type_t<P>, if_not_t< flecs::is_pair< First >::value > = 0>

void flecs::world::set | ( | const A & | value | ) | const
| inline

Set singleton pair.

Definition at line 700 of file world.hpp.

## ◆ set() [3/7]

template<typename Func, if_t< is_callable< Func >::value >>

void flecs::world::set | ( | const Func & | func | ) | const
| inline

Set singleton component inside a callback.

Definition at line 350 of file world.hpp.

## ◆ set() [4/7]

template<typename T, if_t< !is_callable< T >::value > = 0>

void flecs::world::set | ( | const T & | value | ) | const
| inline

Set singleton component.

Definition at line 684 of file world.hpp.

## ◆ set() [5/7]

template<typename First, typename Second>

void flecs::world::set | ( | Second | second,
|  | const First & | value ) const
| inline

Set singleton pair.

Definition at line 110 of file world.hpp.

## ◆ set() [6/7]

template<typename First, typename Second>

void flecs::world::set | ( | Second | second,
|  | First && | value ) const
| inline

Set singleton pair.

Definition at line 116 of file world.hpp.

## ◆ set() [7/7]

template<typename T, if_t< !is_callable< T >::value > = 0>

void flecs::world::set | ( | T && | value | ) | const
| inline

Set singleton component.

Definition at line 691 of file world.hpp.

## ◆ set_binding_ctx()

void flecs::world::set_binding_ctx | ( | void * | ctx,
|  | ecs_ctx_free_t | ctx_free = nullptr ) const
| inline

Set world binding context.

Same as set_ctx() but for binding context. A binding context is intended specifically for language bindings to store binding specific data.

Parameters

  ctx | A pointer to a user defined structure.
  ctx_free | A function that is invoked with ctx when the world is freed.

See also
  ecs_set_binding_ctx()
  flecs::world::get_binding_ctx()

Definition at line 583 of file world.hpp.

## ◆ set_ctx()

void flecs::world::set_ctx | ( | void * | ctx,
|  | ecs_ctx_free_t | ctx_free = nullptr ) const
| inline

Set world context.

Set a context value that can be accessed by anyone that has a reference to the world.

Parameters

  ctx | A pointer to a user defined structure.
  ctx_free | A function that is invoked with ctx when the world is freed.

See also
  ecs_set_ctx()
  flecs::world::get_ctx()

Definition at line 555 of file world.hpp.

## ◆ set_entity_range()

void flecs::world::set_entity_range | ( | entity_t | min,
|  | entity_t | max ) const
| inline

Set entity range.

This function limits the range of issued entity ids between min and max.

Parameters

  min | Minimum entity id issued.
  max | Maximum entity id issued.

See also
  ecs_set_entity_range()

Definition at line 619 of file world.hpp.

## ◆ set_lookup_path()

flecs::entity_t * flecs::world::set_lookup_path | ( | const flecs::entity_t * | search_path | ) | const
| inline

Set search path.

See also
  ecs_set_lookup_path()
  flecs::world::lookup()

Definition at line 669 of file world.hpp.

## ◆ set_scope() [1/2]

template<typename T>

flecs::entity flecs::world::set_scope | ( |  | ) | const
| inline

Same as set_scope but with type.

See also
  ecs_set_scope()
  flecs::world::get_scope()

Definition at line 86 of file world.hpp.

## ◆ set_scope() [2/2]

flecs::entity flecs::world::set_scope | ( | const flecs::entity_t | scope | ) | const
| inline

Set current scope.

Parameters

  scope | The scope to set.

Returns
  The current scope;

See also
  ecs_set_scope()
  flecs::world::get_scope()

Definition at line 77 of file world.hpp.

## ◆ set_stage_count()

void flecs::world::set_stage_count | ( | int32_t | stages | ) | const
| inline

Configure world to have N stages.

This initializes N stages, which allows applications to defer operations to multiple isolated defer queues. This is typically used for applications with multiple threads, where each thread gets its own queue, and commands are merged when threads are synchronized.

Note that set_threads() already creates the appropriate number of stages. The set_stage_count() operation is useful for applications that want to manage their own stages and/or threads.

Parameters

  stages | The number of stages.

See also
  ecs_set_stage_count()
  flecs::world::get_stage_count()

Definition at line 424 of file world.hpp.

## ◆ set_version()

void flecs::world::set_version | ( | flecs::entity_t | e | ) | const
| inline

Set version of entity to provided.

See also
  ecs_set_version()

Definition at line 1269 of file world.hpp.

## ◆ should_quit()

bool flecs::world::should_quit | ( |  | ) | const
| inline

Test if quit() has been called.

Definition at line 291 of file world.hpp.

## ◆ shrink()

void flecs::world::shrink | ( |  | ) | const
| inline

Free unused memory.

See also
  ecs_shrink()

Definition at line 1295 of file world.hpp.

## ◆ singleton()

template<typename T>

flecs::entity flecs::world::singleton | ( |  | ) | const
| inline

Get singleton entity for type.

Definition at line 314 of file world.hpp.

## ◆ system() [1/2]

template<typename... Comps, typename... Args>

system_builder< Comps... > flecs::world::system | ( | Args &&... | args | ) | const
| inline

Definition at line 119 of file impl.hpp.

## ◆ system() [2/2]

flecs::system system | ( | flecs::entity | e | ) | const

Upcast entity to a system.

The provided entity must be a system.

Parameters

  e | The entity.

Returns
  A system object.

## ◆ target() [1/3]

template<typename T>

flecs::entity flecs::world::target | ( | flecs::entity_t | first,
|  | int32_t | index = 0 ) const
| inline

Get target for a given pair from a singleton entity.

This operation returns the target for a given pair. The optional index can be used to iterate through targets, in case the entity has multiple instances for the same relationship.

Parameters

  first | The first element of the pair for which to retrieve the target.
  index | The index (0 for the first instance of the relationship).

Definition at line 326 of file world.hpp.

## ◆ target() [2/3]

flecs::entity flecs::world::target | ( | flecs::entity_t | first,
|  | int32_t | index = 0 ) const
| inline

Get target for a given pair from a singleton entity.

This operation returns the target for a given pair. The optional index can be used to iterate through targets, in case the entity has multiple instances for the same relationship.

Parameters

  first | The first element of the pair for which to retrieve the target.
  index | The index (0 for the first instance of the relationship).

Definition at line 334 of file world.hpp.

## ◆ target() [3/3]

template<typename First>

flecs::entity flecs::world::target | ( | int32_t | index = 0 | ) | const
| inline

Get target for a given pair from a singleton entity.

This operation returns the target for a given pair. The optional index can be used to iterate through targets, in case the entity has multiple instances for the same relationship.

Template Parameters

  First | The first element of the pair.

Parameters

  index | The index (0 for the first instance of the relationship).

Definition at line 319 of file world.hpp.

## ◆ timer()

template<typename... Args>

flecs::timer flecs::world::timer | ( | Args &&... | args | ) | const
| inline

Find or register a timer.

Definition at line 52 of file impl.hpp.

## ◆ to_json() [1/3]

flecs::string to_json | ( |  | ) |

Serialize world to JSON.

Definition at line 32 of file world.inl.

## ◆ to_json() [2/3]

template<typename T>

flecs::string to_json | ( | const T * | value | ) |

Serialize value to JSON.

Definition at line 22 of file world.inl.

## ◆ to_json() [3/3]

flecs::string to_json | ( | flecs::entity_t | tid,
|  | const void * | value )

Serialize untyped value to JSON.

Definition at line 11 of file world.inl.

## ◆ try_get() [1/5]

template<typename T>

const T * flecs::world::try_get | ( |  | ) | const
| inline

Get singleton component.

Definition at line 138 of file world.hpp.

## ◆ try_get() [2/5]

template<typename First, typename Second, typename P, typename A>

const A * flecs::world::try_get | ( |  | ) | const
| inline

Get singleton pair.

Definition at line 144 of file world.hpp.

## ◆ try_get() [3/5]

const void * flecs::world::try_get | ( | flecs::entity_t | r,
|  | flecs::entity_t | t ) const
| inline

Get singleton pair.

Definition at line 132 of file world.hpp.

## ◆ try_get() [4/5]

const void * flecs::world::try_get | ( | flecs::id_t | id | ) | const
| inline

Get singleton component.

Definition at line 127 of file world.hpp.

## ◆ try_get() [5/5]

template<typename First, typename Second>

const First * flecs::world::try_get | ( | Second | second | ) | const
| inline

Get singleton pair.

Definition at line 150 of file world.hpp.

## ◆ try_get_mut() [1/5]

template<typename T>

T * flecs::world::try_get_mut | ( |  | ) | const
| inline

Definition at line 194 of file world.hpp.

## ◆ try_get_mut() [2/5]

template<typename First, typename Second, typename P, typename A>

A * flecs::world::try_get_mut | ( |  | ) | const
| inline

Get mutable singleton pair.

Definition at line 200 of file world.hpp.

## ◆ try_get_mut() [3/5]

void * flecs::world::try_get_mut | ( | flecs::entity_t | r,
|  | flecs::entity_t | t ) const
| inline

Get mutable singleton pair.

Definition at line 188 of file world.hpp.

## ◆ try_get_mut() [4/5]

void * flecs::world::try_get_mut | ( | flecs::id_t | id | ) | const
| inline

Get mutable singleton component.

Definition at line 183 of file world.hpp.

## ◆ try_get_mut() [5/5]

template<typename First, typename Second>

First * flecs::world::try_get_mut | ( | Second | second | ) | const
| inline

Get mutable singleton pair.

Definition at line 206 of file world.hpp.

## ◆ use() [1/3]

template<typename T>

flecs::entity flecs::world::use | ( | const char * | alias = nullptr | ) | const
| inline

Create alias for component.

Template Parameters

  T | to create an alias for.

Parameters

  alias | Alias for the component.

Returns
  Entity representing the component.

Definition at line 48 of file world.hpp.

## ◆ use() [2/3]

flecs::entity flecs::world::use | ( | const char * | name,
|  | const char * | alias = nullptr ) const
| inline

Create alias for entity.

Parameters

  name | Name of the entity.
  alias | Alias for the entity.

Definition at line 59 of file world.hpp.

## ◆ use() [3/3]

void flecs::world::use | ( | flecs::entity | entity,
|  | const char * | alias = nullptr ) const
| inline

Create alias for entity.

Parameters

  entity | Entity for which to create the alias.
  alias | Alias for the entity.

Definition at line 67 of file world.hpp.

## ◆ with() [1/5]

template<typename T, typename Func>

void flecs::world::with | ( | const Func & | func | ) | const
| inline

All entities created in function are created with type.

Definition at line 1072 of file world.hpp.

## ◆ with() [2/5]

template<typename First, typename Second, typename Func>

void flecs::world::with | ( | const Func & | func | ) | const
| inline

All entities created in function are created with pair.

Definition at line 1079 of file world.hpp.

## ◆ with() [3/5]

template<typename Func>

void flecs::world::with | ( | id_t | first,
|  | id_t | second,
|  | const Func & | func ) const
| inline

All entities created in function are created with pair.

Definition at line 1093 of file world.hpp.

## ◆ with() [4/5]

template<typename First, typename Func>

void flecs::world::with | ( | id_t | second,
|  | const Func & | func ) const
| inline

All entities created in function are created with pair.

Definition at line 1086 of file world.hpp.

## ◆ with() [5/5]

template<typename Func>

void flecs::world::with | ( | id_t | with_id,
|  | const Func & | func ) const
| inline

All entities created in function are created with id.

Definition at line 1063 of file world.hpp.

## Friends And Related Symbol Documentation

## ◆ cursor()

template<typename T>

flecs::cursor cursor | ( | void * | ptr | ) |
| related

Return meta cursor to value.

Definition at line 20 of file world.inl.

## ◆ each() [1/2]

template<typename Func>

void each | ( | Func && | func | ) | const
| related

Iterate over all entities with components in argument list of function.

The function parameter must match the following signature:

void(*)(T&, U&, ...)

or:

void(*)(flecs::entity, T&, U&, ...)

## ◆ each() [2/2]

template<typename T, typename Func>

void each | ( | Func && | func | ) | const
| related

Iterate over all entities with provided component.

The function parameter must match the following signature:

void(*)(T&)

or:

void(*)(flecs::entity, T&)

## ◆ get_pipeline()

flecs::entity get_pipeline | ( |  | ) | const
| related

Get pipeline.

See also
  ecs_get_pipeline

## ◆ get_threads()

int32_t get_threads | ( |  | ) | const
| related

Set number of threads.

See also
  ecs_get_stage_count

## ◆ import()

template<typename Module>

flecs::entity import | ( |  | ) |
| related

Import a module.

Template Parameters

  Module | module class.

Returns
  Module entity.

## ◆ observer()

template<typename... Components, typename... Args>

flecs::observer_builder< Components... > observer | ( | Args &&... | args | ) | const
| related

Create a new observer.

Template Parameters

  Components | The components to match on.
  Args | Arguments passed to the constructor of flecs::observer_builder.

Returns
  Observer builder.

## ◆ pipeline()

template<typename Pipeline, if_not_t< is_enum< Pipeline >::value > = 0>

flecs::pipeline_builder pipeline | ( |  | ) | const
| related

Create a new pipeline.

Template Parameters

  Pipeline | Type associated with pipeline.

Returns
  A pipeline builder.

## ◆ progress()

bool progress | ( | ecs_ftime_t | delta_time = 0.0 | ) | const
| related

Progress world one tick.

See also
  ecs_progress

## ◆ query()

flecs::query query | ( | flecs::entity | query_entity | ) | const
| related

Create a query from entity.

See also
  ecs_query_init

## ◆ query_builder()

template<typename... Comps, typename... Args>

flecs::query_builder< Comps... > query_builder | ( | Args &&... | args | ) | const
| related

Create a query builder.

See also
  ecs_query_init

## ◆ reset_clock()

void reset_clock | ( |  | ) | const
| related

Reset simulation clock.

See also
  ecs_reset_clock

## ◆ run_pipeline() [1/2]

void run_pipeline | ( | const flecs::entity_t | pip,
|  | ecs_ftime_t | delta_time = 0.0 ) const
| related

Run pipeline.

See also
  ecs_run_pipeline

## ◆ run_pipeline() [2/2]

template<typename Pipeline, if_not_t< is_enum< Pipeline >::value > = 0>

void run_pipeline | ( | ecs_ftime_t | delta_time = 0.0 | ) | const
| related

Run pipeline.

Template Parameters

  Pipeline | Type associated with pipeline.

See also
  ecs_run_pipeline

## ◆ set_pipeline() [1/2]

template<typename Pipeline>

void set_pipeline | ( |  | ) | const
| related

Set pipeline.

See also
  ecs_set_pipeline

## ◆ set_pipeline() [2/2]

void set_pipeline | ( | const flecs::entity | pip | ) | const
| related

Set pipeline.

See also
  ecs_set_pipeline

## ◆ set_target_fps()

void set_target_fps | ( | ecs_ftime_t | target_fps | ) | const
| related

Set target FPS.

See also
  ecs_set_target_fps

## ◆ set_task_threads()

void set_task_threads | ( | int32_t | task_threads | ) | const
| related

Set number of task threads.

See also
  ecs_set_task_threads

## ◆ set_threads()

void set_threads | ( | int32_t | threads | ) | const
| related

Set number of threads.

See also
  ecs_set_threads

## ◆ set_time_scale()

void set_time_scale | ( | ecs_ftime_t | mul | ) | const
| related

Set timescale.

See also
  ecs_set_time_scale

## ◆ system()

template<typename... Components, typename... Args>

flecs::system_builder< Components... > system | ( | Args &&... | args | ) | const
| related

Create a new system.

Template Parameters

  Components | The components to match on.
  Args | Arguments passed to the constructor of flecs::system_builder.

Returns
  System builder.

## ◆ using_task_threads()

bool using_task_threads | ( |  | ) | const
| related

Returns true if task thread use has been requested.

See also
  ecs_using_task_threads

## Member Data Documentation

## ◆ world_

world_t* flecs::world::world_

Definition at line 1360 of file world.hpp.

The documentation for this struct was generated from the following files:

- include/flecs/addons/cpp/world.hpp
- include/flecs/addons/cpp/impl/world.hpp
- include/flecs/addons/cpp/mixins/alerts/impl.hpp
- include/flecs/addons/cpp/mixins/alerts/mixin.inl
- include/flecs/addons/cpp/mixins/app/mixin.inl
- include/flecs/addons/cpp/mixins/component/impl.hpp
- include/flecs/addons/cpp/mixins/component/mixin.inl
- include/flecs/addons/cpp/mixins/entity/impl.hpp
- include/flecs/addons/cpp/mixins/entity/mixin.inl
- include/flecs/addons/cpp/mixins/enum/impl.hpp
- include/flecs/addons/cpp/mixins/enum/mixin.inl
- include/flecs/addons/cpp/mixins/event/impl.hpp
- include/flecs/addons/cpp/mixins/event/mixin.inl
- include/flecs/addons/cpp/mixins/id/impl.hpp
- include/flecs/addons/cpp/mixins/id/mixin.inl
- include/flecs/addons/cpp/mixins/json/world.inl
- include/flecs/addons/cpp/mixins/meta/world.inl
- include/flecs/addons/cpp/mixins/metrics/impl.hpp
- include/flecs/addons/cpp/mixins/metrics/mixin.inl
- include/flecs/addons/cpp/mixins/module/impl.hpp
- include/flecs/addons/cpp/mixins/module/mixin.inl
- include/flecs/addons/cpp/mixins/observer/impl.hpp
- include/flecs/addons/cpp/mixins/observer/mixin.inl
- include/flecs/addons/cpp/mixins/pipeline/impl.hpp
- include/flecs/addons/cpp/mixins/pipeline/mixin.inl
- include/flecs/addons/cpp/mixins/query/impl.hpp
- include/flecs/addons/cpp/mixins/query/mixin.inl
- include/flecs/addons/cpp/mixins/system/impl.hpp
- include/flecs/addons/cpp/mixins/system/mixin.inl
- include/flecs/addons/cpp/mixins/term/impl.hpp
- include/flecs/addons/cpp/mixins/term/mixin.inl
- include/flecs/addons/cpp/mixins/timer/impl.hpp
- include/flecs/addons/cpp/mixins/timer/mixin.inl