45 : flecs::
id( nullptr,
id ) { }
67 explicit operator bool()
const {
117 template <
typename Parent>
122 bool enabled()
const {
123 return !
ecs_has_id(world_, id_, flecs::Disabled);
156 template <
typename Func>
157 void each(
const Func& func)
const;
168 template <
typename Func>
169 void each(flecs::id_t
first, flecs::id_t
second,
const Func& func)
const;
181 template <
typename Func>
194 template <
typename First,
typename Func>
195 void each(
const Func& func)
const {
209 template <
typename Func>
210 void children(flecs::entity_t rel, Func&& func)
const {
214 if (id_ == flecs::Wildcard || id_ == flecs::Any) {
237 template <
typename Rel,
typename Func>
253 template <
typename Func>
255 children(flecs::ChildOf, FLECS_MOV(func));
267 template <typename T, if_t< is_actual<T>::value > = 0>
271 "operation invalid for empty type");
272 return static_cast<const T*
>(
ecs_get_id(world_, id_, comp_id));
283 template <
typename T,
typename A = actual_type_t<T>,
284 if_t< flecs::is_pair<T>::value > = 0>
288 "operation invalid for empty type");
289 return static_cast<const A*
>(
ecs_get_id(world_, id_, comp_id));
298 template <
typename First,
typename Second,
typename P = pair<First, Second>,
299 typename A = actual_type_t<P>, if_not_t< flecs::is_pair<First>::value > = 0>
301 return this->try_get<P>();
310 template<typename First, typename Second, if_not_t< is_enum<Second>::value> = 0>
314 "operation invalid for empty type");
315 return static_cast<const First*
>(
325 template<typename First, typename Second, if_t< is_enum<Second>::value && !std::is_same<First, Second>::value > = 0>
327 const auto& et = enum_type<Second>(this->world_);
329 return try_get<First>(
target);
361 template<
typename Second>
365 ECS_INVALID_PARAMETER,
"pair is not a component");
367 ECS_INVALID_PARAMETER,
"type of pair is not Second");
369 "operation invalid for empty type");
370 return static_cast<const Second*
>(
381 template<
typename First,
typename Second>
383 return try_get<pair_object<First, Second>>();
395 template <typename T, if_t< is_actual<T>::value > = 0>
397 const T *r = try_get<T>();
398 ecs_assert(r !=
nullptr, ECS_INVALID_OPERATION,
399 "invalid get: entity does not have component (use try_get)");
411 template <
typename T,
typename A = actual_type_t<T>,
412 if_t< flecs::is_pair<T>::value > = 0>
414 const A *r = try_get<T>();
415 ecs_assert(r !=
nullptr, ECS_INVALID_OPERATION,
416 "invalid get: entity does not have component (use try_get)");
428 template <
typename First,
typename Second,
typename P = pair<First, Second>,
429 typename A = actual_type_t<P>, if_not_t< flecs::is_pair<First>::value > = 0>
431 return this->get<P>();
442 template<typename First, typename Second, if_not_t< is_enum<Second>::value> = 0>
444 const First *r = try_get<First>(
second);
445 ecs_assert(r !=
nullptr, ECS_INVALID_OPERATION,
446 "invalid get: entity does not have component (use try_get)");
458 template<typename First, typename Second, if_t< is_enum<Second>::value && !std::is_same<First, Second>::value > = 0>
459 const First&
get(Second constant)
const {
460 const auto& et = enum_type<Second>(this->world_);
462 return get<First>(
target);
471 const void*
get(flecs::id_t comp)
const {
472 const void *r =
ecs_get_id(world_, id_, comp);
473 ecs_assert(r !=
nullptr, ECS_INVALID_OPERATION,
474 "invalid get: entity does not have component (use try_get)");
490 ecs_assert(r !=
nullptr, ECS_INVALID_OPERATION,
491 "invalid get: entity does not have component (use try_get)");
529 template <typename Func, if_t< is_callable<Func>::value > = 0>
530 bool get(
const Func& func)
const;
539 template<
typename Second>
541 const Second *r = try_get_second<Second>(
first);
542 ecs_assert(r !=
nullptr, ECS_INVALID_OPERATION,
543 "invalid get: entity does not have component (use try_get)");
554 template<
typename First,
typename Second>
556 const Second *r = try_get<First, Second>();
557 ecs_assert(r !=
nullptr, ECS_INVALID_OPERATION,
558 "invalid get: entity does not have component (use try_get)");
571 template <typename T, if_t< is_actual<T>::value > = 0>
575 "operation invalid for empty type");
587 template <
typename T,
typename A = actual_type_t<T>,
588 if_t< flecs::is_pair<T>::value > = 0>
592 "operation invalid for empty type");
602 template <
typename First,
typename Second,
typename P = pair<First, Second>,
603 typename A = actual_type_t<P>, if_not_t< flecs::is_pair<First>::value > = 0>
605 return this->try_get_mut<P>();
614 template<typename First, typename Second, if_not_t< is_enum<Second>::value> = 0>
618 "operation invalid for empty type");
619 return static_cast<First*
>(
629 template<typename First, typename Second, if_t< is_enum<Second>::value && !std::is_same<First, Second>::value > = 0>
631 const auto& et = enum_type<Second>(this->world_);
633 return get_mut<First>(
target);
665 template<
typename Second>
669 ECS_INVALID_PARAMETER,
"pair is not a component");
671 ECS_INVALID_PARAMETER,
"type of pair is not Second");
673 "operation invalid for empty type");
674 return static_cast<Second*
>(
685 template<
typename First,
typename Second>
687 return get_mut<pair_object<First, Second>>();
699 template <typename T, if_t< is_actual<T>::value > = 0>
701 T* r = try_get_mut<T>();
702 ecs_assert(r !=
nullptr, ECS_INVALID_OPERATION,
703 "invalid get_mut: entity does not have component (use try_get_mut)");
715 template <
typename T,
typename A = actual_type_t<T>,
716 if_t< flecs::is_pair<T>::value > = 0>
718 A* r = try_get_mut<T>();
719 ecs_assert(r !=
nullptr, ECS_INVALID_OPERATION,
720 "invalid get_mut: entity does not have component (use try_get_mut)");
730 template <
typename First,
typename Second,
typename P = pair<First, Second>,
731 typename A = actual_type_t<P>, if_not_t< flecs::is_pair<First>::value > = 0>
733 A* r = try_get_mut<First, Second>();
734 ecs_assert(r !=
nullptr, ECS_INVALID_OPERATION,
735 "invalid get_mut: entity does not have component (use try_get_mut)");
745 template<typename First, typename Second, if_not_t< is_enum<Second>::value> = 0>
747 First* r = try_get_mut<First>(
second);
748 ecs_assert(r !=
nullptr, ECS_INVALID_OPERATION,
749 "invalid get_mut: entity does not have component (use try_get_mut)");
759 template<typename First, typename Second, if_t< is_enum<Second>::value && !std::is_same<First, Second>::value > = 0>
761 const auto& et = enum_type<Second>(this->world_);
763 return get_mut<First>(
target);
774 ecs_assert(r !=
nullptr, ECS_INVALID_OPERATION,
775 "invalid get_mut: entity does not have component (use try_get_mut)");
789 ecs_assert(r !=
nullptr, ECS_INVALID_OPERATION,
790 "invalid get_mut: entity does not have component (use try_get_mut)");
801 template<
typename Second>
803 Second *r = try_get_mut_second<Second>(
first);
804 ecs_assert(r !=
nullptr, ECS_INVALID_OPERATION,
805 "invalid get_mut: entity does not have component (use try_get_mut)");
816 template<
typename First,
typename Second>
818 Second *r = try_get_mut_second<First, Second>();
819 ecs_assert(r !=
nullptr, ECS_INVALID_OPERATION,
820 "invalid get_mut: entity does not have component (use try_get_mut)");
825 template<
typename Enum>
836 template<
typename First>
869 template <
typename T>
872 template <
typename First,
typename Second>
880 int32_t
depth(flecs::entity_t rel)
const {
889 template<
typename Rel>
916 bool has(flecs::id_t e)
const {
925 template <
typename T>
933 if (is_enum<T>::value) {
934 return ecs_has_pair(world_, id_, cid, flecs::Wildcard);
946 template <typename E, if_t< is_enum<E>::value > = 0>
949 auto o = enum_type<E>(world_).entity(value);
951 "Constant was not found in Enum reflection data."
952 " Did you mean to use has<E>() instead of has(E)?");
953 return ecs_has_pair(world_, id_, r, o);
962 template <
typename First,
typename Second>
973 template<typename First, typename Second, if_not_t< is_enum<Second>::value > = 0>
985 template <
typename Second>
996 template<typename First, typename E, if_t< is_enum<E>::value && !std::is_same<First, E>::value > = 0>
998 const auto& et = enum_type<E>(this->world_);
999 flecs::entity_t
second = et.entity(value);
1000 return has<First>(
second);
1029 template <
typename First>
1051 template <
typename T>
1063 template <
typename First,
typename Second>
1084 template<
typename T>
1105 template <
typename First>
1116 template <
typename First,
typename Second>
1121 flecs::entity clone(
bool clone_value =
true, flecs::entity_t dst_id = 0)
const;
component< T > & constant(const char *name, T value)
Add constant.
#define ecs_assert(condition, error_code,...)
Assert.
const ecs_type_info_t * ecs_get_type_info(const ecs_world_t *world, ecs_id_t component)
Get the type info for an component.
bool ecs_children_next(ecs_iter_t *it)
Progress an iterator created with ecs_children().
ecs_iter_t ecs_children_w_rel(const ecs_world_t *world, ecs_entity_t relationship, ecs_entity_t parent)
Same as ecs_children() but with custom relationship argument.
bool ecs_is_enabled_id(const ecs_world_t *world, ecs_entity_t entity, ecs_id_t component)
Test if component is enabled.
bool ecs_owns_id(const ecs_world_t *world, ecs_entity_t entity, ecs_id_t component)
Test if an entity owns a component.
int32_t ecs_get_depth(const ecs_world_t *world, ecs_entity_t entity, ecs_entity_t rel)
Return depth for entity in tree for the specified relationship.
bool ecs_has_id(const ecs_world_t *world, ecs_entity_t entity, ecs_id_t component)
Test if an entity has a component.
const void * ecs_get_id(const ecs_world_t *world, ecs_entity_t entity, ecs_id_t component)
Get an immutable pointer to a component.
void * ecs_get_mut_id(const ecs_world_t *world, ecs_entity_t entity, ecs_id_t component)
Get a mutable pointer to a component.
bool ecs_is_valid(const ecs_world_t *world, ecs_entity_t e)
Test whether an entity is valid.
bool ecs_is_alive(const ecs_world_t *world, ecs_entity_t e)
Test whether an entity is alive.
char * ecs_get_path_w_sep(const ecs_world_t *world, ecs_entity_t parent, ecs_entity_t child, const char *sep, const char *prefix)
Get a path identifier for an entity.
const char * ecs_get_symbol(const ecs_world_t *world, ecs_entity_t entity)
Get the symbol of an entity.
const char * ecs_get_name(const ecs_world_t *world, ecs_entity_t entity)
Get the name of an entity.
const ecs_world_t * ecs_get_world(const ecs_poly_t *poly)
Get world from poly.
Component added to enum type entities.
flecs::type type() const
Get the entity's type.
entity_view(entity_t id)
Implicit conversion from flecs::entity_t to flecs::entity_view.
int32_t depth(flecs::entity_t rel) const
Get depth for given relationship.
bool enabled() const
Test if pair is enabled.
const Second * try_get_second(flecs::entity_t first) const
Get the second part for a pair.
bool has(flecs::id_t first, flecs::id_t second) const
Check if entity has the provided pair.
First & get_mut(Second constant) const
Get a mutable pair.
T & get_mut() const
Get mutable component value.
A & get_mut() const
Get mutable component value.
flecs::string_view name() const
Return the entity name.
bool owns(flecs::id_t second) const
Check if entity owns the provided pair.
const A * try_get() const
Get a pair.
bool is_valid() const
Check if entity is valid.
flecs::string path(const char *sep="::", const char *init_sep="::") const
Return the entity path.
const void * try_get(flecs::entity_t first, flecs::entity_t second) const
Get a pair (untyped).
flecs::string_view symbol() const
Return the entity symbol.
void each(const Func &func) const
Iterate targets for a given relationship.
A & get_mut() const
Get a mutable pair.
flecs::table_range range() const
Get table range for the entity.
void * get_mut(flecs::entity_t first, flecs::entity_t second) const
Get a mutable pair (untyped).
const Second & get_second(flecs::entity_t first) const
Get the second part for a pair.
const Second & get_second() const
Get the second part for a pair.
bool owns() const
Check if entity owns the provided pair.
const T & get() const
Get component value.
bool has(E value) const
Check if entity has the provided pair.
int32_t depth() const
Get depth for given relationship.
entity_view(flecs::world_t *world, flecs::id_t id)
Wrap an existing entity id.
bool enabled(flecs::id_t id) const
Test if id is enabled.
flecs::entity target_for(flecs::entity_t relationship, flecs::id_t id) const
Get the target of a pair for a given relationship id.
bool has_second(flecs::entity_t first) const
Check if entity has the provided pair.
const First * try_get(Second constant) const
Get a pair.
Second * try_get_mut_second(flecs::entity_t first) const
Get the second part for a pair.
flecs::entity lookup(const char *path, bool search_path=false) const
Lookup an entity by name.
const First & get(Second second) const
Get a pair.
void children(Func &&func) const
Iterate children for entity.
const void * try_get(flecs::id_t comp) const
Get component value (untyped).
bool owns(flecs::id_t e) const
Check if entity owns the provided entity.
Second & get_mut_second(flecs::entity_t first) const
Get the second part for a pair.
const First & get(Second constant) const
Get a pair.
flecs::table table() const
Get the entity's table.
flecs::string path_from(flecs::entity_t parent, const char *sep="::", const char *init_sep="::") const
Return the entity path relative to a parent.
Second * get_mut_second() const
Get the second part for a pair.
bool enabled(flecs::id_t second) const
Test if pair is enabled.
bool has(Second second) const
Check if entity has the provided pair.
A * try_get_mut() const
Get mutable component value.
bool has(flecs::id_t e) const
Check if entity has the provided entity.
bool owns() const
Check if entity owns the provided component.
flecs::entity parent() const
Get parent of entity.
const First * try_get(Second second) const
Get a pair.
void * get_mut(flecs::id_t comp) const
Get mutable component value (untyped).
A * try_get_mut() const
Get a mutable pair.
void each(const Func &func) const
Iterate (component) ids of an entity.
const void * get(flecs::entity_t first, flecs::entity_t second) const
Get a pair (untyped).
bool is_alive() const
Check if entity is alive.
const A & get() const
Get a pair.
bool has() const
Check if entity has the provided component.
T * try_get_mut() const
Get mutable component value.
bool owns(flecs::id_t first, flecs::id_t second) const
Check if entity owns the provided pair.
void * try_get_mut(flecs::id_t comp) const
Get mutable component value (untyped).
void children(Func &&func) const
Iterate children for entity.
const A & get() const
Get component value.
Enum get_constant() const
Get enum constant for enum relationship.
First & get_mut(Second second) const
Get a mutable pair.
Second * try_get_mut_second() const
Get the second part for a pair.
void * try_get_mut(flecs::entity_t first, flecs::entity_t second) const
Get a mutable pair (untyped).
First * try_get_mut(Second second) const
Get a mutable pair.
entity_t id() const
Get entity id.
flecs::entity target(int32_t index=0) const
Get target for a given pair.
const T * try_get() const
Get component value.
const void * get(flecs::id_t comp) const
Get component value (untyped).
bool has() const
Check if entity has the provided pair.
flecs::string path_from(const char *sep="::", const char *init_sep="::") const
Return the entity path relative to a parent.
First * try_get_mut(Second constant) const
Get a mutable pair.
bool enabled() const
Test if component is enabled.
const Second * try_get_second() const
Get the second part for a pair.
void children(flecs::entity_t rel, Func &&func) const
Iterate children for entity.
flecs::entity mut(const flecs::world &stage) const
Return mutable entity handle for current stage When an entity handle created from the world is used w...
bool has(E value) const
Check if entity has the provided enum constant.
bool enabled(flecs::id_t first, flecs::id_t second) const
Test if pair is enabled.
const A * try_get() const
Get component value.
Class that wraps around a flecs::id_t.
flecs::entity second() const
Get second element from a pair.
flecs::entity first() const
Get first element from a pair.
Class for iterating over query results.