Skip to content
Flecs v4.1
flecs::entity_view Struct Reference

Entity view. More...

#include <entity_view.hpp>

Public Member Functions

 entity_view ()
 Default constructor.
 entity_view (flecs::world_t *world, flecs::id_t id)
 Wrap an existing entity ID.
 entity_view (entity_t id)
 Implicit conversion from flecs::entity_t to flecs::entity_view.
entity_t id () const
 Get entity ID.
bool is_valid () const
 Check if entity is valid.
 operator bool () const
 Conversion to bool.
bool is_alive () const
 Check if entity is alive.
flecs::string_view name () const
 Return the entity name.
flecs::string_view symbol () const
 Return the entity symbol.
flecs::string path (const char *sep="::", const char *init_sep="::") const
 Return the entity path.
flecs::string path_from (flecs::entity_t parent, const char *sep="::", const char *init_sep="::") const
 Return the entity path relative to a parent.
template<typename Parent>
flecs::string path_from (const char *sep="::", const char *init_sep="::") const
 Return the entity path relative to a typed parent.
bool enabled () const
 Check if entity is enabled (does not have the Disabled tag).
flecs::type type () const
 Get the entity's type.
flecs::table table () const
 Get the entity's table.
flecs::table_range range () const
 Get table range for the entity.
template<typename Func>
void each (const Func &func) const
 Iterate (component) IDs of an entity.
template<typename Func>
void each (flecs::id_t first, flecs::id_t second, const Func &func) const
 Iterate matching pair IDs of an entity.
template<typename Func>
void each (const flecs::entity_view &rel, const Func &func) const
 Iterate targets for a given relationship.
template<typename First, typename Func>
void each (const Func &func) const
 Iterate targets for a given relationship.
template<typename Func>
void children (flecs::entity_t rel, Func &&func) const
 Iterate children for an entity.
template<typename Rel, typename Func>
void children (Func &&func) const
 Iterate children for an entity.
template<typename Func>
void children (Func &&func) const
 Iterate children for an entity.
template<typename... T, typename... Args>
decltype(auto) try_get (Args... args) const
template<typename... T, typename... Args>
decltype(auto) try_get_second (Args... args) const
template<typename... T>
auto try_get_n () const
template<typename Func, if_t< is_callable< Func >::value > = 0>
bool get (const Func &func) const
template<typename... T, typename... Args>
decltype(auto) get (Args... args) const
template<typename... T, typename... Args>
decltype(auto) get_second (Args... args) const
template<typename... T>
auto get_n () const
template<typename... T, typename... Args>
decltype(auto) try_get_mut (Args... args) const
template<typename... T, typename... Args>
decltype(auto) try_get_mut_second (Args... args) const
template<typename... T>
auto try_get_mut_n () const
template<typename... T, typename... Args>
decltype(auto) get_mut (Args... args) const
template<typename... T, typename... Args>
decltype(auto) get_mut_second (Args... args) const
template<typename... T>
auto get_mut_n () const
template<typename Enum>
Enum get_constant () const
 Get enum constant for enum relationship.
template<typename First>
flecs::entity target (int32_t index=0) const
 Get target for a given pair.
flecs::entity target (flecs::entity_t first, int32_t index=0) const
 Get target for a given pair.
flecs::entity target_for (flecs::entity_t relationship, flecs::id_t id) const
 Get the target of a pair for a given relationship ID.
template<typename T>
flecs::entity target_for (flecs::entity_t relationship) const
 Get the target of a pair for a given relationship ID.
template<typename First, typename Second>
flecs::entity target_for (flecs::entity_t relationship) const
 Get the target of a pair for a given relationship ID.
int32_t depth (flecs::entity_t rel) const
 Get the depth for a given relationship.
template<typename Rel>
int32_t depth () const
 Get the depth for a given relationship.
flecs::entity parent () const
 Get parent of entity.
flecs::entity lookup (const char *path, bool search_path=false) const
 Lookup an entity by name.
template<typename... T, typename... Args>
bool has (Args... args) const
template<typename Second>
bool has_second (flecs::entity_t first) const
template<typename... T, typename... Args>
bool owns (Args... args) const
template<typename Second>
bool owns_second (flecs::entity_t first) const
template<typename... T, typename... Args>
bool enabled (Args... args) const
flecs::entity clone (bool clone_value=true, flecs::entity_t dst_id=0) const
 Clone an entity.
flecs::entity mut (const flecs::world &stage) const
 Return a mutable entity handle for the current stage.
flecs::entity mut (const flecs::iter &it) const
 Same as mut(world), but for an iterator.
flecs::entity mut (const flecs::entity_view &e) const
 Same as mut(world), but for an entity.
flecs::string to_json (const flecs::entity_to_json_desc_t *desc=nullptr) const
 Serialize an entity to JSON.
const char * doc_name () const
 Get human-readable name.
const char * doc_brief () const
 Get brief description.
const char * doc_detail () const
 Get detailed description.
const char * doc_link () const
 Get link to external documentation.
const char * doc_color () const
 Get color.
const char * doc_uuid () const
 Get UUID.
int32_t alert_count (flecs::entity_t alert=0) const
 Return the number of alerts for an entity.
template<typename E>
to_constant () const
 Convert an entity to an enum constant.
void emit (flecs::entity_t evt) const
 Emit an event for an entity.
void emit (flecs::entity evt) const
 Emit an event for an entity.
template<typename Evt, if_t< is_empty< Evt >::value > = 0>
void emit () const
 Emit an event for an entity.
template<typename Evt, if_not_t< is_empty< Evt >::value > = 0>
void emit (const Evt &payload) const
 Emit an event with payload for an entity.
void enqueue (flecs::entity_t evt) const
 Enqueue an event for an entity.
void enqueue (flecs::entity evt) const
 Enqueue an event for an entity.
template<typename Evt, if_t< is_empty< Evt >::value > = 0>
void enqueue () const
 Enqueue an event for an entity.
template<typename Evt, if_not_t< is_empty< Evt >::value > = 0>
void enqueue (const Evt &payload) const
 Enqueue an event with payload for an entity.
int32_t alert_count (flecs::entity_t alert=0) const
 Return the number of alerts for an entity.
const char * doc_name () const
 Get human-readable name.
const char * doc_brief () const
 Get brief description.
const char * doc_detail () const
 Get detailed description.
const char * doc_link () const
 Get link to external documentation.
const char * doc_color () const
 Get color.
const char * doc_uuid () const
 Get UUID.
template<typename E>
to_constant () const
 Convert an entity to an enum constant.
void emit (flecs::entity_t evt) const
 Emit an event for an entity.
void emit (flecs::entity evt) const
 Emit an event for an entity.
template<typename Evt, if_t< is_empty< Evt >::value > = 0>
void emit () const
 Emit an event for an entity.
template<typename Evt, if_not_t< is_empty< Evt >::value > = 0>
void emit (const Evt &payload) const
 Emit an event with payload for an entity.
void enqueue (flecs::entity_t evt) const
 Enqueue an event for an entity.
void enqueue (flecs::entity evt) const
 Enqueue an event for an entity.
template<typename Evt, if_t< is_empty< Evt >::value > = 0>
void enqueue () const
 Enqueue an event for an entity.
template<typename Evt, if_not_t< is_empty< Evt >::value > = 0>
void enqueue (const Evt &payload) const
 Enqueue an event with payload for an entity.
flecs::string to_json (const flecs::entity_to_json_desc_t *desc=nullptr) const
 Serialize an entity to JSON.
Public Member Functions inherited from flecs::id
 id (flecs::id_t value)
 id (flecs::world_t *world, flecs::id_t value=0)
 id (flecs::world_t *world, flecs::id_t first, flecs::id_t second)
 id (flecs::world_t *world, const char *expr)
 id (flecs::id_t first, flecs::id_t second)
 id (const flecs::id &first, const flecs::id &second)
bool is_pair () const
 Test if ID is a pair (has first, second).
bool is_value_pair () const
 Test if ID is a value pair (has first, value).
bool is_wildcard () const
 Test if ID is a wildcard.
bool is_entity () const
 Test if ID is an entity.
flecs::entity entity () const
 Return ID as entity (only allowed when ID is a valid entity).
flecs::entity add_flags (flecs::id_t flags) const
 Return ID with flags added.
flecs::entity remove_flags (flecs::id_t flags) const
 Return ID with flags removed.
flecs::entity remove_flags () const
 Return ID without flags.
flecs::entity remove_generation () const
 Return ID without generation.
flecs::entity type_id () const
 Return component type of ID.
bool has_flags (flecs::id_t flags) const
 Test if ID has specified flags.
bool has_flags () const
 Test if ID has any flags.
flecs::entity flags () const
 Return ID flags set on ID.
bool has_relation (flecs::id_t first) const
 Test if ID has the specified first element.
flecs::entity first () const
 Get first element from a pair.
flecs::entity second () const
 Get second element from a pair.
flecs::string str () const
 Convert ID to string.
flecs::string flags_str () const
 Convert flags of ID to string.
flecs::id_t raw_id () const
 Return flecs::id_t value.
 operator flecs::id_t () const
flecs::world world () const
 Get the world.

Additional Inherited Members

Protected Attributes inherited from flecs::id
flecs::world_tworld_
 World is optional, but guarantees that entity identifiers extracted from the ID are valid.
flecs::id_t id_
 The raw ID value.

Detailed Description

Entity view.

Class with read operations for entities. Base for flecs::entity.

Definition at line 30 of file entity_view.hpp.

Constructor & Destructor Documentation

◆ entity_view() [1/3]

flecs::entity_view::entity_view ( )
inline

Default constructor.

Creates an empty entity view.

Definition at line 33 of file entity_view.hpp.

◆ entity_view() [2/3]

flecs::entity_view::entity_view ( flecs::world_t * world,
flecs::id_t id )
inlineexplicit

Wrap an existing entity ID.

Parameters
worldThe world in which the entity is created.
idThe entity ID.

Definition at line 40 of file entity_view.hpp.

◆ entity_view() [3/3]

flecs::entity_view::entity_view ( entity_t id)
inline

Implicit conversion from flecs::entity_t to flecs::entity_view.

Definition at line 47 of file entity_view.hpp.

Member Function Documentation

◆ alert_count()

int32_t alert_count ( flecs::entity_t alert = 0) const

Return the number of alerts for an entity.

Definition at line 11 of file entity_view.inl.

◆ children() [1/3]

template<typename Func>
void flecs::entity_view::children ( flecs::entity_t rel,
Func && func ) const
inline

Iterate children for an entity.

The function parameter must match the following signature:

flecs::entity target(int32_t index=0) const
Get target for a given pair.
Definition impl.hpp:36
Entity.
Definition entity.hpp:30
Parameters
relThe relationship to follow.
funcThe function invoked for each child.

Definition at line 228 of file entity_view.hpp.

◆ children() [2/3]

template<typename Func>
void flecs::entity_view::children ( Func && func) const
inline

Iterate children for an entity.

The function parameter must match the following signature:

This operation follows the ChildOf relationship.

Parameters
funcThe function invoked for each child.

Definition at line 272 of file entity_view.hpp.

◆ children() [3/3]

template<typename Rel, typename Func>
void flecs::entity_view::children ( Func && func) const
inline

Iterate children for an entity.

The function parameter must match the following signature:

Template Parameters
RelThe relationship to follow.
Parameters
funcThe function invoked for each child.

Definition at line 256 of file entity_view.hpp.

◆ clone()

flecs::entity flecs::entity_view::clone ( bool clone_value = true,
flecs::entity_t dst_id = 0 ) const
inline

Clone an entity.

Create a copy of the current entity with all of its components.

Parameters
clone_valueIf true, clone component values. If false, only clone the entity's type.
dst_idIf nonzero, clone to this entity ID instead of creating a new one.
Returns
The cloned entity.

Definition at line 183 of file impl.hpp.

◆ depth() [1/2]

template<typename Rel>
int32_t flecs::entity_view::depth ( ) const
inline

Get the depth for a given relationship.

Template Parameters
RelThe relationship.
Returns
The depth.

Definition at line 442 of file entity_view.hpp.

◆ depth() [2/2]

int32_t flecs::entity_view::depth ( flecs::entity_t rel) const
inline

Get the depth for a given relationship.

Parameters
relThe relationship.
Returns
The depth.

Definition at line 432 of file entity_view.hpp.

◆ doc_brief()

const char * doc_brief ( ) const

Get brief description.

See also
ecs_doc_get_brief()
flecs::doc::get_brief()
flecs::entity_builder::set_doc_brief()

Definition at line 28 of file entity_view.inl.

◆ doc_color()

const char * doc_color ( ) const

◆ doc_detail()

const char * doc_detail ( ) const

Get detailed description.

See also
ecs_doc_get_detail()
flecs::doc::get_detail()
flecs::entity_builder::set_doc_detail()

Definition at line 41 of file entity_view.inl.

◆ doc_link()

const char * doc_link ( ) const

Get link to external documentation.

See also
ecs_doc_get_link()
flecs::doc::get_link()
flecs::entity_builder::set_doc_link()

Definition at line 54 of file entity_view.inl.

◆ doc_name()

const char * doc_name ( ) const

Get human-readable name.

See also
ecs_doc_get_name()
flecs::doc::get_name()
flecs::entity_builder::set_doc_name()

Definition at line 15 of file entity_view.inl.

◆ doc_uuid()

const char * doc_uuid ( ) const

◆ each() [1/4]

template<typename Func>
void flecs::entity_view::each ( const flecs::entity_view & rel,
const Func & func ) const
inline

Iterate targets for a given relationship.

The function parameter must match the following signature:

Parameters
relThe relationship for which to iterate the targets.
funcThe function invoked for each target.

Definition at line 165 of file impl.hpp.

◆ each() [2/4]

template<typename First, typename Func>
void flecs::entity_view::each ( const Func & func) const
inline

Iterate targets for a given relationship.

The function parameter must match the following signature:

Template Parameters
FirstThe relationship for which to iterate the targets.
Parameters
funcThe function invoked for each target.

Definition at line 213 of file entity_view.hpp.

◆ each() [3/4]

template<typename Func>
void flecs::entity_view::each ( const Func & func) const
inline

Iterate (component) IDs of an entity.

The function parameter must match the following signature:

void(*)(flecs::id id)
entity_t id() const
Get entity ID.
Class that wraps around a flecs::id_t.
Definition decl.hpp:27
Parameters
funcThe function invoked for each ID.

Definition at line 155 of file impl.hpp.

◆ each() [4/4]

template<typename Func>
void flecs::entity_view::each ( flecs::id_t first,
flecs::id_t second,
const Func & func ) const
inline

Iterate matching pair IDs of an entity.

The function parameter must match the following signature:

void(*)(flecs::id id)
Parameters
firstThe first element of the pair to match.
secondThe second element of the pair to match.
funcThe function invoked for each ID.

Definition at line 160 of file impl.hpp.

◆ emit() [1/8]

template<typename Evt, if_t< is_empty< Evt >::value > = 0>
void emit ( ) const
inline

Emit an event for an entity.

Template Parameters
EvtThe event to emit.

Definition at line 34 of file entity_view.hpp.

◆ emit() [2/8]

template<typename Evt, if_t< is_empty< Evt >::value > = 0>
void emit ( ) const

Emit an event for an entity.

Template Parameters
EvtThe event to emit.

Definition at line 33 of file entity_view.inl.

◆ emit() [3/8]

template<typename Evt, if_not_t< is_empty< Evt >::value > = 0>
void emit ( const Evt & payload) const
inline

Emit an event with payload for an entity.

Template Parameters
EvtThe event to emit.

Definition at line 45 of file entity_view.hpp.

◆ emit() [4/8]

template<typename Evt, if_not_t< is_empty< Evt >::value > = 0>
void emit ( const Evt & payload) const

Emit an event with payload for an entity.

Template Parameters
EvtThe event to emit.

Definition at line 44 of file entity_view.inl.

◆ emit() [5/8]

void flecs::entity_view::emit ( flecs::entity evt) const
inline

Emit an event for an entity.

Parameters
evtThe event to emit.

Definition at line 60 of file impl.hpp.

◆ emit() [6/8]

void emit ( flecs::entity evt) const

Emit an event for an entity.

Parameters
evtThe event to emit.

◆ emit() [7/8]

void emit ( flecs::entity_t evt) const
inline

Emit an event for an entity.

Parameters
evtThe event to emit.

Definition at line 13 of file entity_view.hpp.

◆ emit() [8/8]

void emit ( flecs::entity_t evt) const

Emit an event for an entity.

Parameters
evtThe event to emit.

Definition at line 12 of file entity_view.inl.

◆ enabled() [1/2]

bool flecs::entity_view::enabled ( ) const
inline

Check if entity is enabled (does not have the Disabled tag).

Returns
True if the entity is enabled, false otherwise.

Definition at line 138 of file entity_view.hpp.

◆ enabled() [2/2]

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

Definition at line 484 of file entity_view.hpp.

◆ enqueue() [1/8]

template<typename Evt, if_t< is_empty< Evt >::value > = 0>
void enqueue ( ) const
inline

Enqueue an event for an entity.

Template Parameters
EvtThe event to enqueue.

Definition at line 80 of file entity_view.hpp.

◆ enqueue() [2/8]

template<typename Evt, if_t< is_empty< Evt >::value > = 0>
void enqueue ( ) const

Enqueue an event for an entity.

Template Parameters
EvtThe event to enqueue.

Definition at line 79 of file entity_view.inl.

◆ enqueue() [3/8]

template<typename Evt, if_not_t< is_empty< Evt >::value > = 0>
void enqueue ( const Evt & payload) const
inline

Enqueue an event with payload for an entity.

Template Parameters
EvtThe event to enqueue.

Definition at line 91 of file entity_view.hpp.

◆ enqueue() [4/8]

template<typename Evt, if_not_t< is_empty< Evt >::value > = 0>
void enqueue ( const Evt & payload) const

Enqueue an event with payload for an entity.

Template Parameters
EvtThe event to enqueue.

Definition at line 90 of file entity_view.inl.

◆ enqueue() [5/8]

void flecs::entity_view::enqueue ( flecs::entity evt) const
inline

Enqueue an event for an entity.

Parameters
evtThe event to enqueue.

Definition at line 64 of file impl.hpp.

◆ enqueue() [6/8]

void enqueue ( flecs::entity evt) const

Enqueue an event for an entity.

Parameters
evtThe event to enqueue.

◆ enqueue() [7/8]

void enqueue ( flecs::entity_t evt) const
inline

Enqueue an event for an entity.

Parameters
evtThe event to enqueue.

Definition at line 59 of file entity_view.hpp.

◆ enqueue() [8/8]

void enqueue ( flecs::entity_t evt) const

Enqueue an event for an entity.

Parameters
evtThe event to enqueue.

Definition at line 58 of file entity_view.inl.

◆ get() [1/2]

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

Definition at line 300 of file entity_view.hpp.

◆ get() [2/2]

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

Definition at line 173 of file impl.hpp.

◆ get_constant()

template<typename Enum>
Enum flecs::entity_view::get_constant ( ) const
inline

Get enum constant for enum relationship.

Template Parameters
EnumThe enum type.
Returns
The enum constant value.

Definition at line 30 of file impl.hpp.

◆ get_mut()

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

Definition at line 338 of file entity_view.hpp.

◆ get_mut_n()

template<typename... T>
auto flecs::entity_view::get_mut_n ( ) const
inline

Definition at line 350 of file entity_view.hpp.

◆ get_mut_second()

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

Definition at line 344 of file entity_view.hpp.

◆ get_n()

template<typename... T>
auto flecs::entity_view::get_n ( ) const
inline

Definition at line 312 of file entity_view.hpp.

◆ get_second()

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

Definition at line 306 of file entity_view.hpp.

◆ has()

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

Definition at line 464 of file entity_view.hpp.

◆ has_second()

template<typename Second>
bool flecs::entity_view::has_second ( flecs::entity_t first) const
inline

Definition at line 469 of file entity_view.hpp.

◆ id()

entity_t flecs::entity_view::id ( ) const
inline

Get entity ID.

Returns
The integer entity ID.

Definition at line 53 of file entity_view.hpp.

◆ is_alive()

bool flecs::entity_view::is_alive ( ) const
inline

Check if entity is alive.

Returns
True if the entity is alive, false otherwise.
See also
ecs_is_alive()

Definition at line 80 of file entity_view.hpp.

◆ is_valid()

bool flecs::entity_view::is_valid ( ) const
inline

Check if entity is valid.

An entity is valid if:

  • its ID is not 0
  • the ID contains a valid bit pattern for an entity
  • the entity is alive (see is_alive())
Returns
True if the entity is valid, false otherwise.
See also
ecs_is_valid()

Definition at line 66 of file entity_view.hpp.

◆ lookup()

flecs::entity flecs::entity_view::lookup ( const char * path,
bool search_path = false ) const
inline

Lookup an entity by name.

Lookup an entity in the scope of this entity. The provided path may contain double colons as scope separators, for example: "Foo::Bar".

Parameters
pathThe name of the entity to lookup.
search_pathWhen false, only the entity's scope is searched.
Returns
The found entity, or entity::null if no entity matched.

Definition at line 177 of file impl.hpp.

◆ mut() [1/3]

flecs::entity flecs::entity_view::mut ( const flecs::entity_view & e) const
inline

Same as mut(world), but for an entity.

This operation allows for the construction of a mutable entity handle from another entity. This is useful in each() functions, which only provide a handle to the entity being iterated over.

Parameters
eAnother mutable entity.
Returns
An entity handle that allows for mutations in the current stage.

Definition at line 84 of file impl.hpp.

◆ mut() [2/3]

flecs::entity flecs::entity_view::mut ( const flecs::iter & it) const
inline

Same as mut(world), but for an iterator.

This operation allows for the construction of a mutable entity handle from an iterator.

Parameters
itAn iterator that contains a reference to the world or stage.
Returns
An entity handle that allows for mutations in the current stage.

Definition at line 78 of file impl.hpp.

◆ mut() [3/3]

flecs::entity flecs::entity_view::mut ( const flecs::world & stage) const
inline

Return a mutable entity handle for the current stage.

When an entity handle created from the world is used while the world is in staged mode, it will only allow for read-only operations since structural changes are not allowed on the world while in staged mode.

To do mutations on the entity, this operation provides a handle to the entity that uses the stage instead of the actual world.

Note that staged entity handles should never be stored persistently, in components or elsewhere. An entity handle should always point to the main world.

Also note that this operation is not necessary when doing mutations on an entity outside of a system. It is allowed to do entity operations directly on the world, as long as the world is not in staged mode.

Parameters
stageThe current stage.
Returns
An entity handle that allows for mutations in the current stage.

Definition at line 72 of file impl.hpp.

◆ name()

flecs::string_view flecs::entity_view::name ( ) const
inline

Return the entity name.

Returns
The entity name.

Definition at line 88 of file entity_view.hpp.

◆ operator bool()

flecs::entity_view::operator bool ( ) const
inlineexplicit

Conversion to bool.

Returns true if entity is valid.

Definition at line 71 of file entity_view.hpp.

◆ owns()

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

Definition at line 474 of file entity_view.hpp.

◆ owns_second()

template<typename Second>
bool flecs::entity_view::owns_second ( flecs::entity_t first) const
inline

Definition at line 479 of file entity_view.hpp.

◆ parent()

flecs::entity flecs::entity_view::parent ( ) const
inline

Get parent of entity.

Short for target(flecs::ChildOf).

Returns
The parent of the entity.

Definition at line 68 of file impl.hpp.

◆ path()

flecs::string flecs::entity_view::path ( const char * sep = "::",
const char * init_sep = "::" ) const
inline

Return the entity path.

Parameters
sepThe separator used between path elements.
init_sepThe initial separator prepended to the path.
Returns
The hierarchical entity path.

Definition at line 106 of file entity_view.hpp.

◆ path_from() [1/2]

template<typename Parent>
flecs::string flecs::entity_view::path_from ( const char * sep = "::",
const char * init_sep = "::" ) const
inline

Return the entity path relative to a typed parent.

Template Parameters
ParentThe parent type to compute the path relative to.
Parameters
sepThe separator used between path elements.
init_sepThe initial separator prepended to the path.
Returns
The relative hierarchical entity path.

Definition at line 130 of file entity_view.hpp.

◆ path_from() [2/2]

flecs::string flecs::entity_view::path_from ( flecs::entity_t parent,
const char * sep = "::",
const char * init_sep = "::" ) const
inline

Return the entity path relative to a parent.

Parameters
parentThe parent entity to compute the path relative to.
sepThe separator used between path elements.
init_sepThe initial separator prepended to the path.
Returns
The relative hierarchical entity path.

Definition at line 117 of file entity_view.hpp.

◆ range()

flecs::table_range flecs::entity_view::range ( ) const
inline

Get table range for the entity.

Return a range with the entity's row as offset and count set to 1. If the entity is not stored in a table, the function returns a range with count 0.

Returns
The entity's table range.

Definition at line 102 of file impl.hpp.

◆ symbol()

flecs::string_view flecs::entity_view::symbol ( ) const
inline

Return the entity symbol.

Returns
The entity symbol.

Definition at line 96 of file entity_view.hpp.

◆ table()

flecs::table flecs::entity_view::table ( ) const
inline

Get the entity's table.

Returns
The entity's table.

Definition at line 98 of file impl.hpp.

◆ target() [1/2]

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

Get target for a given pair.

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 42 of file impl.hpp.

◆ target() [2/2]

template<typename First>
flecs::entity flecs::entity_view::target ( int32_t index = 0) const
inline

Get target for a given pair.

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 36 of file impl.hpp.

◆ target_for() [1/3]

template<typename First, typename Second>
flecs::entity flecs::entity_view::target_for ( flecs::entity_t relationship) const
inline

Get the target of a pair for a given relationship ID.

Template Parameters
FirstThe first element of the pair to lookup.
SecondThe second element of the pair to lookup.
Parameters
relationshipThe relationship to follow.
Returns
The entity for which the target has been found.

Definition at line 64 of file impl.hpp.

◆ target_for() [2/3]

template<typename T>
flecs::entity flecs::entity_view::target_for ( flecs::entity_t relationship) const
inline

Get the target of a pair for a given relationship ID.

Template Parameters
TThe component type to lookup.
Parameters
relationshipThe relationship to follow.
Returns
The entity for which the target has been found.

Definition at line 59 of file impl.hpp.

◆ target_for() [3/3]

flecs::entity flecs::entity_view::target_for ( flecs::entity_t relationship,
flecs::id_t id ) const
inline

Get the target of a pair for a given relationship ID.

This operation returns the first entity that has the provided component ID by following the specified relationship. If the entity itself has the component ID, then the entity will be returned. If the component ID cannot be found on the entity or by following the relationship, the operation will return 0.

This operation can be used to lookup, for example, which prefab is providing a component by specifying the IsA pair:

// Is Position provided by the entity or one of its base entities?
const ecs_entity_t EcsIsA
Used to express inheritance relationships.
FLECS_API const ecs_entity_t ecs_id(EcsDocDescription)
Component ID for EcsDocDescription.
ecs_entity_t ecs_get_target_for_id(const ecs_world_t *world, ecs_entity_t entity, ecs_entity_t rel, ecs_id_t component)
Get the target of a relationship for a given component.
flecs::entity entity() const
Return ID as entity (only allowed when ID is a valid entity).
Definition impl.hpp:10
flecs::world world() const
Get the world.
Definition impl.hpp:60
Parameters
relationshipThe relationship to follow.
idThe component ID to lookup.
Returns
The entity for which the target has been found.

Definition at line 50 of file impl.hpp.

◆ to_json()

flecs::string to_json ( const flecs::entity_to_json_desc_t * desc = nullptr) const

Serialize an entity to JSON.

Definition at line 11 of file entity_view.inl.

◆ try_get()

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

Definition at line 278 of file entity_view.hpp.

◆ try_get_mut()

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

Definition at line 319 of file entity_view.hpp.

◆ try_get_mut_n()

template<typename... T>
auto flecs::entity_view::try_get_mut_n ( ) const
inline

Definition at line 331 of file entity_view.hpp.

◆ try_get_mut_second()

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

Definition at line 325 of file entity_view.hpp.

◆ try_get_n()

template<typename... T>
auto flecs::entity_view::try_get_n ( ) const
inline

Definition at line 290 of file entity_view.hpp.

◆ try_get_second()

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

Definition at line 284 of file entity_view.hpp.

◆ type()

flecs::type flecs::entity_view::type ( ) const
inline

Get the entity's type.

Returns
The entity's type.

Definition at line 94 of file impl.hpp.


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