Skip to content
Flecs v4.1

The world. More...

#include <world.hpp>

Public Member Functions

 world ()
 Create a world.
 world (int argc, char *argv[])
 Create a world with command-line arguments.
 world (world_t *w)
 Create a world from a C world.
 world (const world &obj)
 Copy constructor.
worldoperator= (const world &obj) noexcept
 Copy assignment operator.
 world (world &&obj) noexcept
 Move constructor.
worldoperator= (world &&obj) noexcept
 Move assignment operator.
void release ()
 Release the underlying world object.
 ~world ()
 Destructor.
 operator world_t * () const
 Implicit conversion to world_t*.
void make_owner ()
 Make the current world object the owner of the world.
void reset ()
 Delete and recreate the world.
world_tc_ptr () const
 Obtain a pointer to the C world object.
void atfini (ecs_fini_action_t action, void *ctx=nullptr) const
 Register action to be executed when world is destroyed.
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.
bool is_defer_suspended () const
 Test whether deferring is suspended.
void set_stage_count (int32_t stages) const
 Configure world to have N stages.
int32_t get_stage_count () const
 Get the number of configured stages.
int32_t get_stage_id () const
 Get current stage ID.
bool is_stage () const
 Test if this 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 an 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 a number of entities.
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_tset_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, typename A = _::value_type_t<T...>, if_not_t< is_callable< A >::value > = 0>
void set (A &&value) const
template<typename... T, typename A = _::value_type_t<T...>, if_not_t< is_callable< A >::value > = 0>
void set (const A &value) const
template<typename First, typename Second>
void set (Second second, First &&value) const
template<typename First, typename Second>
void set (Second second, const First &value) const
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, typename... Args>
decltype(auto) ensure (Args... args) const
template<typename T>
void modified () const
template<typename T>
ref< T > get_ref () const
 Get ref singleton component.
template<typename Func, if_t< is_callable< Func >::value > = 0>
void get (const Func &func) const
 Get a singleton component using a callback.
template<typename... T, typename... Args>
decltype(auto) try_get (Args... args) const
template<typename... T, typename... Args>
decltype(auto) get (Args... args) const
template<typename... T, typename... Args>
decltype(auto) try_get_mut (Args... args) const
template<typename... T, typename... Args>
decltype(auto) get_mut (Args... args) const
template<typename... T, typename... Args>
bool has (Args... args) const
template<typename... T, typename... Args>
void add (Args... args) const
template<typename... T, typename... Args>
void remove (Args... args) const
template<typename Func>
void children (Func &&f) const
 Iterate entities in root of world.
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 an alias for a component.
flecs::entity use (const char *name, const char *alias=nullptr) const
 Create an alias for an entity.
void use (flecs::entity entity, const char *alias=nullptr) const
 Create an alias for an entity.
template<typename... T, typename... Args>
int count (Args... args) const
template<typename Func>
void scope (id_t parent, const Func &func) const
 All entities created in the function are created in the scope.
template<typename T, typename Func>
void scope (const Func &func) const
 Same as scope(parent, func), but with T as parent.
template<typename... T, typename... Args>
void delete_with (Args... args) const
template<typename... T, typename... Args>
void remove_all (Args... args) const
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 is alive.
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
 Ensure an entity ID is alive.
void set_version (flecs::entity_t e) const
 Set the version of an entity to the provided value.
uint32_t get_version (flecs::entity_t e) const
 Get the version of the provided entity.
const flecs::world_info_tget_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_t id_if_registered ()
 Return the component ID if it has been registered.
template<typename... T, typename... Args>
const flecs::type_info_ttype_info (Args... args)
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 and object.
template<typename First>
flecs::id pair (entity_t o) const
 Get pair ID from relationship and object.
flecs::id pair (entity_t r, entity_t o) const
 Get pair ID from relationship and object.
template<typename T, typename... Args>
flecs::component< T > component (Args &&... args) const
 Find or register a component.
template<typename... Args>
flecs::untyped_component component (Args &&... args) const
 Find or register an 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 an enum constant to an entity.
template<typename E, if_t< is_enum< E >::value > = 0>
flecs::entity entity (E value) const
 Convert an enum constant to an entity.
template<typename T>
flecs::entity entity (const char *name=nullptr) const
 Create an entity 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 an enum constant to an entity.
template<typename T>
flecs::entity prefab (const char *name=nullptr) const
 Create a prefab that's associated with a type.
template<typename... Args>
flecs::entity prefab (Args &&... args) const
 Create a prefab.
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 a script.
int script_run_file (const char *filename) const
 Run a script from a file.
script_builder script (const char *name=nullptr) const
 Build a script.
parsed_script script_parse (const char *name, const char *code, const ecs_script_eval_desc_t *desc=nullptr, ecs_script_eval_result_t *result=nullptr) const
int script_update (flecs::entity_t script, const char *code, flecs::entity_t instance=0) const
function_builder function (const char *name) const
function_builder method (flecs::entity_t type, const char *name) const
template<typename T>
function_builder method (const char *name) const
template<typename T>
flecs::entity const_var (const char *name, const T &value, flecs::entity_t parent=0) const
template<typename T>
flecs::entity mut_var (const char *name, const T &value, flecs::entity_t parent=0) const
template<typename T>
int set_mut_var (const char *name, const T &value) const
flecs::string to_expr (flecs::entity_t tid, const void *value)
 Convert a value to a string.
template<typename T>
flecs::string to_expr (const T *value)
 Convert a value to a string.
template<typename T>
get_const_var (const char *name, const T &default_value={}) const
 Get the value of an exported script variable.
template<typename T>
void get_const_var (const char *name, T &out, const T &default_value={}) const
 Get the value of an exported script variable.
template<typename T>
get_mut_var (const char *name, const T &default_value={}) const
 Get the value of an exported script mut variable.
template<typename T>
void get_mut_var (const char *name, T &out, const T &default_value={}) const
 Get the value of an exported script mut variable.
flecs::string to_json (flecs::entity_t tid, const void *value) const
 Serialize an untyped value to JSON.
template<typename T>
flecs::string to_json (const T *value) const
 Serialize a value to JSON.
flecs::string to_json () const
 Serialize the world to JSON.
const char * from_json (flecs::entity_t tid, void *value, const char *json, flecs::from_json_desc_t *desc=nullptr)
 Deserialize a value from JSON.
template<typename T>
const char * from_json (T *value, const char *json, flecs::from_json_desc_t *desc=nullptr)
 Deserialize a value from JSON.
const char * from_json (const char *json, flecs::from_json_desc_t *desc=nullptr)
 Deserialize JSON into the world.
const char * from_json_file (const char *json, flecs::from_json_desc_t *desc=nullptr)
 Deserialize a JSON file into the world.
template<typename... Args>
flecs::metric_builder metric (Args &&... args) const
 Create a metric.
template<typename... Comps, typename... Args>
flecs::alert_builder< Comps... > alert (Args &&... args) const
 Create an alert.
void init_builtin_components ()
 Initialize built-in components.
template<typename... Comps, typename... Args>
flecs::alert_builder< Comps... > alert (Args &&... args) const
 Create an alert.
template<typename T, typename... Args>
flecs::component< T > component (Args &&... args) const
 Find or register a component.
template<typename... Args>
flecs::untyped_component component (Args &&... args) const
 Find or register an 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 an enum constant to an entity.
template<typename E, if_t< is_enum< E >::value > = 0>
flecs::entity entity (E value) const
 Convert an enum constant to an entity.
template<typename T>
flecs::entity entity (const char *name=nullptr) const
 Create an entity that's associated with a type.
template<typename E, if_t< is_enum< E >::value > = 0>
flecs::entity to_entity (E constant) const
 Convert an enum constant to an 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 and object.
template<typename First>
flecs::id pair (entity_t o) const
 Get pair ID from relationship and object.
flecs::id pair (entity_t r, entity_t o) const
 Get pair ID from relationship and object.
flecs::string to_json (flecs::entity_t tid, const void *value) const
 Serialize an untyped value to JSON.
template<typename T>
flecs::string to_json (const T *value) const
 Serialize a value to JSON.
flecs::string to_json () const
 Serialize the world to JSON.
const char * from_json (flecs::entity_t tid, void *value, const char *json, flecs::from_json_desc_t *desc=nullptr)
 Deserialize a value from JSON.
template<typename T>
const char * from_json (T *value, const char *json, flecs::from_json_desc_t *desc=nullptr)
 Deserialize a value from JSON.
const char * from_json (const char *json, flecs::from_json_desc_t *desc=nullptr)
 Deserialize JSON into the world.
const char * from_json_file (const char *json, flecs::from_json_desc_t *desc=nullptr)
 Deserialize a JSON file into the world.
template<typename... Args>
flecs::metric_builder metric (Args &&... args) const
 Create a metric.
template<typename... Comps, typename... Args>
observer_builder< Comps... > observer (Args &&... args) const
template<typename T>
flecs::entity prefab (const char *name=nullptr) const
 Create a prefab that's associated with a type.
template<typename... Args>
flecs::entity prefab (Args &&... args) const
 Create a prefab.
template<>
const char * get_const_var (const char *name, const char *const &default_value) const
template<>
void get_const_var (const char *name, const char *&out, const char *const &default_value) 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 an app builder.
flecs::app_builder app ()
 Return an app builder.

Public Attributes

world_tworld_
 Pointer to the underlying C 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 world mixin.
template<typename... Components, typename... Args>
flecs::observer_builder< Components... > observer (Args &&... args) const
 Create a new observer.
template<typename... Comps, typename... Args>
conditional_t< sizeof...(Args)==0 &&_::is_sparse_query< Comps... >::value, flecs::sparse_query< Comps... >, flecs::query< Comps... > > query (Args &&... args) const
 Create a query.
flecs::query query (flecs::entity query_entity) const
 Create a query from an 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 the argument list of the function.
template<typename T, typename Func>
void each (Func &&func) const
 Iterate over all entities with the provided component.
template<typename Func>
void each (flecs::id_t term_id, Func &&func) const
 Iterate over all entities with the provided (component) ID.
const ecs_entity_range_trange_new (uint32_t min, uint32_t max) const
 Create a new entity id range.
void range_set (const ecs_entity_range_t *range) const
 Set the active entity id range.
const ecs_entity_range_trange_get () const
 Get the currently active entity id range.
ecs_ftime_t frame_begin (ecs_ftime_t delta_time=0) const
 Begin frame.
void frame_end () const
 End frame.
void run_post_frame (ecs_fini_action_t action, void *ctx) const
 Run callback after completing the frame.
void quit () const
 Signal application should quit.
bool should_quit () const
 Test if quit() has been called.
void set_time_scale (ecs_ftime_t mul) const
 Set the time scale.
void set_target_fps (ecs_ftime_t target_fps) const
 Set the target FPS.
void reset_clock () const
 Reset the simulation clock.
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 char *name=nullptr) 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 the pipeline.
template<typename Pipeline>
void set_pipeline () const
 Set the pipeline.
flecs::entity get_pipeline () const
 Get the pipeline.
bool progress (ecs_ftime_t delta_time=0.0) const
 Progress the world one tick.
void run_pipeline (const flecs::entity_t pip, ecs_ftime_t delta_time=0.0) const
 Run a pipeline.
template<typename Pipeline, if_not_t< is_enum< Pipeline >::value > = 0>
void run_pipeline (ecs_ftime_t delta_time=0.0) const
 Run a pipeline.
void set_threads (int32_t threads) const
 Set the number of threads.
int32_t get_threads () const
 Get the number of threads.
void set_task_threads (int32_t task_threads) const
 Set the number of task threads.
bool using_task_threads () const
 Return true if task thread use has been requested.
flecs::system system (flecs::entity e) const
 Upcast an 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 a meta cursor to a value.
template<typename T>
flecs::cursor cursor (void *ptr)
 Return a meta cursor to a value.
flecs::entity primitive (flecs::meta::primitive_kind_t kind)
 Create a primitive type.
flecs::entity array (flecs::entity_t elem_id, int32_t array_count)
 Create an array type.
template<typename T>
flecs::entity array (int32_t array_count)
 Create an array type.
flecs::entity vector (flecs::entity_t elem_id)
 Create a vector type.
template<typename T>
flecs::entity vector ()
 Create a vector type.
const ecs_entity_range_trange_new (uint32_t min, uint32_t max) const
 Create a new entity id range.
void range_set (const ecs_entity_range_t *range) const
 Set the active entity id range.
const ecs_entity_range_trange_get () const
 Get the currently active entity id range.
ecs_ftime_t frame_begin (ecs_ftime_t delta_time=0) const
 Begin frame.
void frame_end () const
 End frame.
void run_post_frame (ecs_fini_action_t action, void *ctx) const
 Run callback after completing the frame.
void quit () const
 Signal application should quit.
bool should_quit () const
 Test if quit() has been called.
void set_time_scale (ecs_ftime_t mul) const
 Set the time scale.
void set_target_fps (ecs_ftime_t target_fps) const
 Set the target FPS.
void reset_clock () const
 Reset the simulation clock.
flecs::cursor cursor (flecs::entity_t tid, void *ptr)
 Return a meta cursor to a value.
template<typename T>
flecs::cursor cursor (void *ptr)
 Return a meta cursor to a value.
flecs::entity primitive (flecs::meta::primitive_kind_t kind)
 Create a primitive type.
flecs::entity array (flecs::entity_t elem_id, int32_t array_count)
 Create an array type.
template<typename T>
flecs::entity array (int32_t array_count)
 Create an array type.
flecs::entity vector (flecs::entity_t elem_id)
 Create a vector type.
template<typename T>
flecs::entity vector ()
 Create a 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 world mixin.
template<typename... Components, typename... Args>
flecs::observer_builder< Components... > observer (Args &&... args) const
 Create a new observer.
flecs::pipeline_builder pipeline (const char *name=nullptr) 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 the pipeline.
template<typename Pipeline>
void set_pipeline () const
 Set the pipeline.
flecs::entity get_pipeline () const
 Get the pipeline.
bool progress (ecs_ftime_t delta_time=0.0) const
 Progress the world one tick.
void run_pipeline (const flecs::entity_t pip, ecs_ftime_t delta_time=0.0) const
 Run a pipeline.
template<typename Pipeline, if_not_t< is_enum< Pipeline >::value > = 0>
void run_pipeline (ecs_ftime_t delta_time=0.0) const
 Run a pipeline.
void set_threads (int32_t threads) const
 Set the number of threads.
int32_t get_threads () const
 Get the number of threads.
void set_task_threads (int32_t task_threads) const
 Set the number of task threads.
bool using_task_threads () const
 Return true if task thread use has been requested.
template<typename... Comps, typename... Args>
conditional_t< sizeof...(Args)==0 &&_::is_sparse_query< Comps... >::value, flecs::sparse_query< Comps... >, flecs::query< Comps... > > query (Args &&... args) const
 Create a query.
flecs::query query (flecs::entity query_entity) const
 Create a query from an 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 the argument list of the function.
template<typename T, typename Func>
void each (Func &&func) const
 Iterate over all entities with the provided component.
template<typename Func>
void each (flecs::id_t term_id, Func &&func) const
 Iterate over all entities with the provided (component) ID.
flecs::system system (flecs::entity e) const
 Upcast an 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 129 of file world.hpp.

Constructor & Destructor Documentation

◆ world() [1/5]

flecs::world::world ( )
inlineexplicit

Create a world.

Definition at line 132 of file world.hpp.

◆ world() [2/5]

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

Create a 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 141 of file world.hpp.

◆ world() [3/5]

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

Create a world from a C world.

Definition at line 148 of file world.hpp.

◆ world() [4/5]

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

Copy constructor.

Increases reference count on the world.

Definition at line 157 of file world.hpp.

◆ world() [5/5]

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

Move constructor.

Transfers world ownership.

Definition at line 171 of file world.hpp.

◆ ~world()

flecs::world::~world ( )
inline

Destructor.

Releases the world reference.

Definition at line 205 of file world.hpp.

Member Function Documentation

◆ add()

template<typename... T, typename... Args>
void flecs::world::add ( Args... args) const
inline

Definition at line 678 of file world.hpp.

◆ app()

Return an 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 an 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 443 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 241 of file world.hpp.

◆ c_ptr()

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

Obtain a pointer to the C world object.

Definition at line 235 of file world.hpp.

◆ children()

template<typename Func>
void flecs::world::children ( Func && f) const
inline

Iterate entities in root of world.

Try to get a singleton value by component ID (returns nullptr if not found).

Accepts a callback with the following signature:

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

Definition at line 116 of file world.hpp.

◆ component()

template<typename... Args>
flecs::untyped_component component ( Args &&... args) const

Find or register an untyped component.

Method available on the flecs::world class.

◆ count()

template<typename... T, typename... Args>
int flecs::world::count ( Args... args) const
inline

Definition at line 764 of file world.hpp.

◆ cursor()

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

Return a meta cursor to a value.

Definition at line 14 of file world.inl.

◆ defer()

template<typename Func>
void flecs::world::defer ( const Func & func) const
inline

◆ defer_begin()

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

Defer operations until end of frame.

When this operation is invoked while iterating, operations in between 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()
flecs::world::is_defer_suspended()

Definition at line 285 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()
flecs::world::is_defer_suspended()

Definition at line 304 of file world.hpp.

◆ defer_resume()

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

◆ defer_suspend()

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

◆ delete_with()

template<typename... T, typename... Args>
void flecs::world::delete_with ( Args... args) const
inline

Definition at line 787 of file world.hpp.

◆ delta_time()

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

Get delta_time.

Definition at line 905 of file world.hpp.

◆ dim()

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

Preallocate memory for a number of entities.

This function preallocates memory for the entity index.

Parameters
entity_countNumber of entities to preallocate memory for.
See also
ecs_dim()

Definition at line 537 of file world.hpp.

◆ emplace()

template<typename T, typename ... Args>
void flecs::world::emplace ( Args &&... args) const
inline

Definition at line 617 of file world.hpp.

◆ ensure()

template<typename... T, typename... Args>
decltype(auto) flecs::world::ensure ( Args... args) const
inline

Definition at line 624 of file world.hpp.

◆ event() [1/2]

template<typename E>
flecs::event_builder_typed< E > event ( ) const

Create a new event.

Template Parameters
EThe event type.
Returns
Event builder.

◆ event() [2/2]

Create a new event.

Parameters
evtThe 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_nameOptional thread name for improved debug messages.
See also
ecs_exclusive_access_begin()

Definition at line 922 of file world.hpp.

◆ exclusive_access_end()

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

End exclusive access.

Parameters
lock_worldLock world for all threads, allow readonly operations.
See also
ecs_exclusive_access_end()

Definition at line 931 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 843 of file world.hpp.

◆ frame_begin()

ecs_ftime_t frame_begin ( ecs_ftime_t delta_time = 0) const

Begin frame.

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

Parameters
delta_timeTime elapsed since the last frame.
Returns
The provided delta_time, or measured time if 0 was provided.
See also
ecs_frame_begin()

◆ from_json() [1/3]

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

Deserialize JSON into the 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 a 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 a 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 a JSON file into the world.

Definition at line 70 of file world.inl.

◆ get() [1/2]

template<typename... T, typename... Args>
decltype(auto) flecs::world::get ( Args... args) const
inline

Definition at line 654 of file world.hpp.

◆ get() [2/2]

template<typename Func, if_t< is_callable< Func >::value >>
void flecs::world::get ( const Func & func) const
inline

Get a singleton component using a callback.

Definition at line 155 of file world.hpp.

◆ get_alive()

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

Get alive entity for ID.

Get an alive entity from an ID.

Return the entity with the current generation.

See also
ecs_get_alive()

Definition at line 170 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 nullptr.
See also
ecs_get_binding_ctx()
flecs::world::set_binding_ctx()

Definition at line 526 of file world.hpp.

◆ get_const_var() [1/2]

template<>
void flecs::world::get_const_var ( const char * name,
const char *& out,
const char *const & default_value ) const
inline

Definition at line 189 of file impl.hpp.

◆ get_const_var() [2/2]

template<>
const char * flecs::world::get_const_var ( const char * name,
const char *const & default_value ) const
inline

Definition at line 176 of file impl.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_ctx(). If no context was set, the function returns nullptr.
See also
ecs_get_ctx()
flecs::world::set_ctx()

Definition at line 498 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 900 of file world.hpp.

◆ get_mut()

template<typename... T, typename... Args>
decltype(auto) flecs::world::get_mut ( Args... args) const
inline

Definition at line 666 of file world.hpp.

◆ get_ref()

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

Get ref singleton component.

Get a ref for a singleton component.

Definition at line 109 of file world.hpp.

◆ get_scope()

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

Get current scope.

Get the current scope.

Returns
The current scope.
See also
ecs_get_scope()
flecs::world::set_scope()

Definition at line 91 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 dedicated API for threading.

Parameters
stage_idThe index of the stage to retrieve.
Returns
A thread-specific pointer to the world.

Definition at line 424 of file world.hpp.

◆ get_stage_count()

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

Get the number of configured stages.

Return the 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 367 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 377 of file world.hpp.

◆ get_version()

uint32_t flecs::world::get_version ( flecs::entity_t e) const
inline

Get the version of the provided entity.

See also
ecs_get_version()

Definition at line 892 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 455 of file world.hpp.

◆ has()

template<typename... T, typename... Args>
bool flecs::world::has ( Args... args) const
inline

Definition at line 672 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 72 of file impl.hpp.

◆ id() [2/2]

template<typename ... Args>
flecs::id flecs::world::id ( Args &&... args) const
inline

ID factory.

Definition at line 77 of file impl.hpp.

◆ id_if_registered()

template<typename T>
flecs::id_t flecs::world::id_if_registered ( )
inline

Return the component ID if it has been registered.

This operation is similar to world::id(), but will never automatically register the component.

Template Parameters
TThe type for which to obtain the ID.

Definition at line 942 of file world.hpp.

◆ init_builtin_components()

void flecs::world::init_builtin_components ( )
inline

Initialize built-in components.

Definition at line 12 of file world.hpp.

◆ is_alive()

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

Check if entity is alive.

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

Definition at line 853 of file world.hpp.

◆ is_defer_suspended()

bool flecs::world::is_defer_suspended ( ) const
inline

Test whether deferring is suspended.

Returns
True if defer is suspended, false if not.
See also
ecs_is_defer_suspended()
flecs::world::defer()
flecs::world::defer_begin()
flecs::world::defer_end()
flecs::world::is_deferred()
flecs::world::defer_resume()
flecs::world::defer_suspend()

Definition at line 336 of file world.hpp.

◆ is_deferred()

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

◆ 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 471 of file world.hpp.

◆ is_stage()

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

Test if this 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 387 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 864 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.

Look up an entity by name.

Parameters
nameEntity name.
sepThe scope separator.
root_sepThe root scope separator.
recursiveWhen false, only the current scope is searched.
Returns
The entity if found, or 0 if not found.

Definition at line 102 of file world.hpp.

◆ make_alive()

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

Ensure an entity ID is alive.

See also
ecs_make_alive()

Definition at line 176 of file world.hpp.

◆ make_owner()

void flecs::world::make_owner ( )
inline

Make the current world object the owner of the world.

This may only be called on one flecs::world object, and 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 219 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 406 of file world.hpp.

◆ modified()

template<typename T>
void flecs::world::modified ( ) const
inline

Definition at line 631 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
Modulemodule 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 90 of file impl.hpp.

◆ observer() [2/2]

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

Observer world mixin.

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

Parameters
eThe entity.
Returns
An observer object.

◆ operator world_t *()

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

Implicit conversion to world_t*.

Definition at line 210 of file world.hpp.

◆ operator=() [1/2]

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

Copy assignment operator.

Increases reference count on the world.

Definition at line 163 of file world.hpp.

◆ operator=() [2/2]

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

Move assignment operator.

Transfers world ownership.

Definition at line 177 of file world.hpp.

◆ pair() [1/3]

template<typename First, typename Second>
flecs::id flecs::world::pair ( ) const
inline

Get pair ID from relationship and object.

Definition at line 82 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 and object.

Definition at line 91 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 and object.

Definition at line 102 of file impl.hpp.

◆ pipeline()

flecs::pipeline_builder pipeline ( const char * name = nullptr) const

Create a new pipeline.

Parameters
nameThe pipeline name (optional).
Returns
A pipeline builder.

◆ query()

template<typename... Comps, typename... Args>
conditional_t< sizeof...(Args)==0 &&_::is_sparse_query< Comps... >::value, flecs::sparse_query< Comps... >, flecs::query< Comps... > > query ( Args &&... args) const

Create a query.

Returns a flecs::sparse_query when all components have the dont_fragment trait and don't declare the on_instantiate::inherit policy.

See also
ecs_query_init()

◆ randomize_timers()

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

Enable randomization of initial time values for timers.

Randomize timers for all systems.

See also
ecs_randomize_timers()

Definition at line 67 of file impl.hpp.

◆ range_new()

const ecs_entity_range_t * range_new ( uint32_t min,
uint32_t max ) const

Create a new entity id range.

See also
ecs_entity_range_new()

◆ readonly_begin()

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

Begin readonly mode.

Parameters
multi_threadedWhether 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 255 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 265 of file world.hpp.

◆ release()

void flecs::world::release ( )
inline

Release the underlying world object.

If this is the last handle, the world will be finalized.

Definition at line 187 of file world.hpp.

◆ remove()

template<typename... T, typename... Args>
void flecs::world::remove ( Args... args) const
inline

Definition at line 684 of file world.hpp.

◆ remove_all()

template<typename... T, typename... Args>
void flecs::world::remove_all ( Args... args) const
inline

Definition at line 792 of file world.hpp.

◆ reset()

void flecs::world::reset ( )
inline

Delete and recreate the world.

Definition at line 224 of file world.hpp.

◆ scope() [1/2]

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 781 of file world.hpp.

◆ scope() [2/2]

template<typename Func>
void flecs::world::scope ( id_t parent,
const Func & func ) const
inline

All entities created in the function are created in the scope.

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

Definition at line 772 of file world.hpp.

◆ set() [1/5]

template<typename... T, typename A = _::value_type_t<T...>, if_not_t< is_callable< A >::value > = 0>
void flecs::world::set ( A && value) const
inline

Definition at line 588 of file world.hpp.

◆ set() [2/5]

template<typename... T, typename A = _::value_type_t<T...>, if_not_t< is_callable< A >::value > = 0>
void flecs::world::set ( const A & value) const
inline

Definition at line 594 of file world.hpp.

◆ set() [3/5]

template<typename Func, if_t< is_callable< Func >::value >>
void flecs::world::set ( const Func & func) const
inline

Set singleton component inside a callback.

Set a singleton component using a callback.

Definition at line 163 of file world.hpp.

◆ set() [4/5]

template<typename First, typename Second>
void flecs::world::set ( Second second,
const First & value ) const
inline

Definition at line 606 of file world.hpp.

◆ set() [5/5]

template<typename First, typename Second>
void flecs::world::set ( Second second,
First && value ) const
inline

Definition at line 600 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
ctxA pointer to a user-defined structure.
ctx_freeA 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 513 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
ctxA pointer to a user-defined structure.
ctx_freeA function that is invoked with ctx when the world is freed.
See also
ecs_set_ctx()
flecs::world::get_ctx()

Definition at line 485 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 573 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.

Set the current scope to a type.

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

Definition at line 97 of file world.hpp.

◆ set_scope() [2/2]

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

Set current scope.

Set the current scope.

Parameters
scopeThe scope to set.
Returns
The previous scope.
See also
ecs_set_scope()
flecs::world::get_scope()

Definition at line 86 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
stagesThe number of stages.
See also
ecs_set_stage_count()
flecs::world::get_stage_count()

Definition at line 355 of file world.hpp.

◆ set_version()

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

Set the version of an entity to the provided value.

See also
ecs_set_version()

Definition at line 884 of file world.hpp.

◆ shrink()

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

Free unused memory.

See also
ecs_shrink()

Definition at line 913 of file world.hpp.

◆ singleton()

template<typename T>
flecs::entity flecs::world::singleton ( ) const
inline

Get singleton entity for type.

Get the singleton entity for a component type.

Definition at line 122 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 186 of file impl.hpp.

◆ system() [2/2]

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

Upcast an entity to a system.

The provided entity must be a system.

Parameters
eThe entity.
Returns
A system object.

◆ target() [1/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.

Get the target entity for a relationship.

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
firstThe first element of the pair for which to retrieve the target.
indexThe index (0 for the first instance of the relationship).
Returns
The target entity.

Definition at line 145 of file world.hpp.

◆ target() [2/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.

Get the target entity for a relationship on a component 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
TThe singleton type.
Parameters
firstThe first element of the pair for which to retrieve the target.
indexThe index (0 for the first instance of the relationship).
Returns
The target entity.

Definition at line 136 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.

Get the target entity for a relationship on a singleton.

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
FirstThe first element of the pair.
Parameters
indexThe index (0 for the first instance of the relationship).
Returns
The target entity.

Definition at line 128 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 62 of file impl.hpp.

◆ to_json() [1/3]

flecs::string to_json ( ) const

Serialize the 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) const

Serialize a 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 ) const

Serialize an untyped value to JSON.

Definition at line 11 of file world.inl.

◆ try_get()

template<typename... T, typename... Args>
decltype(auto) flecs::world::try_get ( Args... args) const
inline

Definition at line 648 of file world.hpp.

◆ try_get_mut()

template<typename... T, typename... Args>
decltype(auto) flecs::world::try_get_mut ( Args... args) const
inline

Definition at line 660 of file world.hpp.

◆ type_info()

template<typename... T, typename... Args>
const flecs::type_info_t * flecs::world::type_info ( Args... args)
inline

Definition at line 952 of file world.hpp.

◆ use() [1/3]

template<typename T>
flecs::entity flecs::world::use ( const char * alias = nullptr) const
inline

Create an alias for a component.

Import a type (entity/component) as an alias.

Template Parameters
TThe type to create an alias for.
Parameters
aliasAlias for the component.
Returns
Entity representing the component.

Definition at line 54 of file world.hpp.

◆ use() [2/3]

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

Create an alias for an entity.

Import an entity by name as an alias.

Parameters
nameName of the entity.
aliasAlias for the entity.

Definition at line 66 of file world.hpp.

◆ use() [3/3]

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

Create an alias for an entity.

Import an entity as an alias.

Parameters
entityEntity for which to create the alias.
aliasAlias for the entity.

Definition at line 75 of file world.hpp.

◆ cursor()

template<typename T>
flecs::cursor cursor ( void * ptr)
related

Return a meta cursor to a value.

Definition at line 20 of file world.inl.

◆ each() [1/2]

template<typename T, typename Func>
void each ( Func && func) const
related

Iterate over all entities with the provided component.

The function parameter must match the following signature:

void(*)(T&)

or:

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

◆ each() [2/2]

template<typename Func>
void each ( Func && func) const
related

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

The function parameter must match the following signature:

void(*)(flecs::entity)

or:

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

or:

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

◆ frame_end()

void frame_end ( ) const
related

End frame.

See also
ecs_frame_end()

◆ get_pipeline()

flecs::entity get_pipeline ( ) const
related

Get the pipeline.

See also
ecs_get_pipeline()

◆ get_threads()

int32_t get_threads ( ) const
related

Get the number of threads.

See also
ecs_get_stage_count()

◆ import()

template<typename Module>
flecs::entity import ( )
related

Import a module.

Template Parameters
Modulemodule 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
ComponentsThe components to match on.
ArgsArguments passed to the constructor of flecs::observer_builder.
Returns
An 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
PipelineType associated with the pipeline.
Returns
A pipeline builder.

◆ progress()

bool progress ( ecs_ftime_t delta_time = 0.0) const
related

Progress the world one tick.

See also
ecs_progress()

◆ query()

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

Create a query from an 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()

◆ quit()

void quit ( ) const
related

Signal application should quit.

See also
ecs_quit()

◆ range_get()

const ecs_entity_range_t * range_get ( ) const
related

Get the currently active entity id range.

See also
ecs_entity_range_get()

◆ range_set()

void range_set ( const ecs_entity_range_t * range) const
related

Set the active entity id range.

See also
ecs_entity_range_set()

◆ reset_clock()

void reset_clock ( ) const
related

Reset the 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 a 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 a pipeline.

Template Parameters
PipelineType associated with the pipeline.
See also
ecs_run_pipeline()

◆ run_post_frame()

void run_post_frame ( ecs_fini_action_t action,
void * ctx ) const
related

Run callback after completing the frame.

See also
ecs_run_post_frame()

◆ set_pipeline() [1/2]

template<typename Pipeline>
void set_pipeline ( ) const
related

Set the pipeline.

See also
ecs_set_pipeline()

◆ set_pipeline() [2/2]

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

Set the pipeline.

See also
ecs_set_pipeline()

◆ set_target_fps()

void set_target_fps ( ecs_ftime_t target_fps) const
related

Set the target FPS.

See also
ecs_set_target_fps()

◆ set_task_threads()

void set_task_threads ( int32_t task_threads) const
related

Set the number of task threads.

See also
ecs_set_task_threads()

◆ set_threads()

void set_threads ( int32_t threads) const
related

Set the number of threads.

See also
ecs_set_threads()

◆ set_time_scale()

void set_time_scale ( ecs_ftime_t mul) const
related

Set the time scale.

See also
ecs_set_time_scale()

◆ should_quit()

bool should_quit ( ) const
related

Test if quit() has been called.

See also
ecs_should_quit()

◆ system()

template<typename... Components, typename... Args>
flecs::system_builder< Components... > system ( Args &&... args) const
related

Create a new system.

Template Parameters
ComponentsThe components to match on.
ArgsArguments passed to the constructor of flecs::system_builder.
Returns
A system builder.

◆ using_task_threads()

bool using_task_threads ( ) const
related

Return true if task thread use has been requested.

See also
ecs_using_task_threads()

Member Data Documentation

◆ world_

world_t* flecs::world::world_

Pointer to the underlying C world.

Definition at line 1009 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/entity_ranges/impl.hpp
  • include/flecs/addons/cpp/mixins/entity_ranges/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/frame/impl.hpp
  • include/flecs/addons/cpp/mixins/frame/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/impl.hpp
  • 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/prefab/impl.hpp
  • include/flecs/addons/cpp/mixins/prefab/mixin.inl
  • include/flecs/addons/cpp/mixins/query/impl.hpp
  • include/flecs/addons/cpp/mixins/query/mixin.inl
  • include/flecs/addons/cpp/mixins/script/impl.hpp
  • 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