Flecs v4.1
A fast entity component system (ECS) for C & C++
Loading...
Searching...
No Matches
entity_view.hpp
Go to the documentation of this file.
1
13#pragma once
14
16
22namespace flecs
23{
24
30struct entity_view : public id {
31
33 entity_view() : flecs::id() { }
34
41 : flecs::id(world
42 ? const_cast<flecs::world_t*>(ecs_get_world(world))
43 : nullptr
44 , id ) { }
45
48 : flecs::id( nullptr, id ) { }
49
53 entity_t id() const {
54 return id_;
55 }
56
66 bool is_valid() const {
67 return world_ && ecs_is_valid(world_, id_);
68 }
69
71 explicit operator bool() const {
72 return is_valid();
73 }
74
80 bool is_alive() const {
81 return world_ && ecs_is_alive(world_, id_);
82 }
83
91
99
106 flecs::string path(const char *sep = "::", const char *init_sep = "::") const {
107 return path_from(0, sep, init_sep);
108 }
109
117 flecs::string path_from(flecs::entity_t parent, const char *sep = "::", const char *init_sep = "::") const {
118 char *path = ecs_get_path_w_sep(world_, parent, id_, sep, init_sep);
119 return flecs::string(path);
120 }
121
129 template <typename Parent>
130 flecs::string path_from(const char *sep = "::", const char *init_sep = "::") const {
131 return path_from(_::type<Parent>::id(world_), sep, init_sep);
132 }
133
138 bool enabled() const {
139 return !ecs_has_id(world_, id_, flecs::Disabled);
140 }
141
146 flecs::type type() const;
147
152 flecs::table table() const;
153
162
172 template <typename Func>
173 void each(const Func& func) const;
174
186 template <typename Func>
187 void each(flecs::id_t first, flecs::id_t second, const Func& func) const;
188
199 template <typename Func>
200 void each(const flecs::entity_view& rel, const Func& func) const;
201
212 template <typename First, typename Func>
213 void each(const Func& func) const {
214 return each(_::type<First>::id(world_), func);
215 }
216
227 template <typename Func>
228 void children(flecs::entity_t rel, Func&& func) const {
229 /* When the entity is a wildcard, this would attempt to query for all
230 * entities with (ChildOf, *) or (ChildOf, _) instead of querying for
231 * the children of the wildcard entity. */
232 if (id_ == flecs::Wildcard || id_ == flecs::Any) {
233 /* This is correct, wildcard entities don't have children. */
234 return;
235 }
236
238
240 while (ecs_children_next(&it)) {
241 _::each_delegate<Func>(FLECS_MOV(func)).invoke(&it);
242 }
243 }
244
255 template <typename Rel, typename Func>
256 void children(Func&& func) const {
257 children(_::type<Rel>::id(world_), FLECS_MOV(func));
258 }
259
271 template <typename Func>
272 void children(Func&& func) const {
273 children(flecs::ChildOf, FLECS_MOV(func));
274 }
275
276
277 /* try_get */
278
285 template <typename T, if_t< is_actual<T>::value > = 0>
286 const T* try_get() const {
287 auto comp_id = _::type<T>::id(world_);
289 "operation invalid for empty type");
290 return static_cast<const T*>(_::get_ptr<T>(world_, id_, comp_id));
291 }
292
301 template <typename T, typename A = actual_type_t<T>,
302 if_t< flecs::is_pair<T>::value > = 0>
303 const A* try_get() const {
304 auto comp_id = _::type<T>::id(world_);
306 "operation invalid for empty type");
307 return static_cast<const A*>(ecs_get_id(world_, id_, comp_id));
308 }
309
317 template <typename First, typename Second, typename P = pair<First, Second>,
318 typename A = actual_type_t<P>, if_not_t< flecs::is_pair<First>::value > = 0>
319 const A* try_get() const {
320 return this->try_get<P>();
321 }
322
330 template<typename First, typename Second, if_not_t< is_enum<Second>::value> = 0>
331 const First* try_get(Second second) const {
334 "operation invalid for empty type");
335 return static_cast<const First*>(
336 ecs_get_id(world_, id_, ecs_pair(first, second)));
337 }
338
346 template<typename First, typename Second, if_t< is_enum<Second>::value && !std::is_same<First, Second>::value > = 0>
347 const First* try_get(Second constant) const {
348 const auto& et = enum_type<Second>(this->world_);
350 return try_get<First>(target);
351 }
352
359 const void* try_get(flecs::id_t comp) const {
360 return ecs_get_id(world_, id_, comp);
361 }
362
373 return ecs_get_id(world_, id_, ecs_pair(first, second));
374 }
375
381 template<typename... Ts>
382 auto try_get_n() const {
383 flecs_static_assert(sizeof...(Ts) > 1, "try_get_n requires at least two components");
384 flecs_static_assert(sizeof...(Ts) < 9, "try_get_n cannot fetch more than eight components");
385 return typename tuple_builder<sizeof...(Ts), Ts...>::type_const_ptr {try_get<Ts>()...};
386 }
387
396 template<typename Second>
397 const Second* try_get_second(flecs::entity_t first) const {
398 auto second = _::type<Second>::id(world_);
399 ecs_assert( ecs_get_type_info(world_, ecs_pair(first, second)) != nullptr,
400 ECS_INVALID_PARAMETER, "pair is not a component");
401 ecs_assert( ecs_get_type_info(world_, ecs_pair(first, second))->component == second,
402 ECS_INVALID_PARAMETER, "type of pair is not Second");
404 "operation invalid for empty type");
405 return static_cast<const Second*>(
406 ecs_get_id(world_, id_, ecs_pair(first, second)));
407 }
408
417 template<typename First, typename Second>
418 const Second* try_get_second() const {
419 return try_get<pair_object<First, Second>>();
420 }
421
422
423 /* get */
424
431 template <typename T, if_t< is_actual<T>::value > = 0>
432 const T& get() const {
433 const T *r = try_get<T>();
434 ecs_assert(r != nullptr, ECS_INVALID_OPERATION,
435 "invalid get: entity does not have component '%s' (use try_get)",
436 flecs::_::type_name<T>());
437 return *r;
438 }
439
448 template <typename T, typename A = actual_type_t<T>,
449 if_t< flecs::is_pair<T>::value > = 0>
450 const A& get() const {
451 const A *r = try_get<T>();
452 ecs_assert(r != nullptr, ECS_INVALID_OPERATION,
453 "invalid get: entity does not have component '%s' (use try_get)",
454 flecs::_::type_name<T>());
455 return *r;
456 }
457
466 template <typename First, typename Second, typename P = pair<First, Second>,
467 typename A = actual_type_t<P>, if_not_t< flecs::is_pair<First>::value > = 0>
468 const A& get() const {
469 return this->get<P>();
470 }
471
480 template<typename First, typename Second, if_not_t< is_enum<Second>::value> = 0>
481 const First& get(Second second) const {
482 const First *r = try_get<First>(second);
483 ecs_assert(r != nullptr, ECS_INVALID_OPERATION,
484 "invalid get: entity does not have pair (use try_get)");
485 return *r;
486 }
487
496 template<typename First, typename Second, if_t< is_enum<Second>::value && !std::is_same<First, Second>::value > = 0>
497 const First& get(Second constant) const {
498 const auto& et = enum_type<Second>(this->world_);
499 flecs::entity_t target = et.entity(constant);
500 return get<First>(target);
501 }
502
509 const void* get(flecs::id_t comp) const {
510 const void *r = ecs_get_id(world_, id_, comp);
511 ecs_assert(r != nullptr, ECS_INVALID_OPERATION,
512 "invalid get: entity does not have component (use try_get)");
513 return r;
514 }
515
526 const void* get(flecs::entity_t first, flecs::entity_t second) const {
527 const void *r = ecs_get_id(world_, id_, ecs_pair(first, second));
528 ecs_assert(r != nullptr, ECS_INVALID_OPERATION,
529 "invalid get: entity does not have pair (use try_get)");
530 return r;
531 }
532
565 template <typename Func, if_t< is_callable<Func>::value > = 0>
566 bool get(const Func& func) const;
567
573 template<typename... Ts>
574 auto get_n() const {
575 flecs_static_assert(sizeof...(Ts) > 1, "get_n requires at least two components");
576 flecs_static_assert(sizeof...(Ts) < 9, "get_n cannot fetch more than eight components");
577 return typename tuple_builder<sizeof...(Ts), Ts...>::type_const {get<Ts>()...};
578 }
579
589 template<typename Second>
590 const Second& get_second(flecs::entity_t first) const {
591 const Second *r = try_get_second<Second>(first);
592 ecs_assert(r != nullptr, ECS_INVALID_OPERATION,
593 "invalid get_second: entity does not have pair (use try_get_second)");
594 return *r;
595 }
596
606 template<typename First, typename Second>
607 const Second& get_second() const {
608 const Second *r = try_get<First, Second>();
609 ecs_assert(r != nullptr, ECS_INVALID_OPERATION,
610 "invalid get_second: entity does not have pair (use try_get_second)");
611 return *r;
612 }
613
614
615 /* try_get_mut */
616
623 template <typename T, if_t< is_actual<T>::value > = 0>
624 T* try_get_mut() const {
625 auto comp_id = _::type<T>::id(world_);
627 "operation invalid for empty type");
628 return static_cast<T*>(_::get_mut_ptr<T>(world_, id_, comp_id));
629 }
630
639 template <typename T, typename A = actual_type_t<T>,
640 if_t< flecs::is_pair<T>::value > = 0>
641 A* try_get_mut() const {
642 auto comp_id = _::type<T>::id(world_);
644 "operation invalid for empty type");
645 return static_cast<A*>(ecs_get_mut_id(world_, id_, comp_id));
646 }
647
655 template <typename First, typename Second, typename P = pair<First, Second>,
656 typename A = actual_type_t<P>, if_not_t< flecs::is_pair<First>::value > = 0>
657 A* try_get_mut() const {
658 return this->try_get_mut<P>();
659 }
660
668 template<typename First, typename Second, if_not_t< is_enum<Second>::value> = 0>
669 First* try_get_mut(Second second) const {
670 auto first = _::type<First>::id(world_);
672 "operation invalid for empty type");
673 return static_cast<First*>(
674 ecs_get_mut_id(world_, id_, ecs_pair(first, second)));
675 }
676
684 template<typename First, typename Second, if_t< is_enum<Second>::value && !std::is_same<First, Second>::value > = 0>
685 First* try_get_mut(Second constant) const {
686 const auto& et = enum_type<Second>(this->world_);
687 flecs::entity_t target = et.entity(constant);
688 return try_get_mut<First>(target);
689 }
690
697 void* try_get_mut(flecs::id_t comp) const {
698 return ecs_get_mut_id(world_, id_, comp);
699 }
700
710 void* try_get_mut(flecs::entity_t first, flecs::entity_t second) const {
711 return ecs_get_mut_id(world_, id_, ecs_pair(first, second));
712 }
713
719 template<typename... Ts>
720 auto try_get_mut_n() const {
721 flecs_static_assert(sizeof...(Ts) > 1, "try_get_mut_n requires at least two components");
722 flecs_static_assert(sizeof...(Ts) < 9, "try_get_mut_n cannot fetch more than eight components");
723 return typename tuple_builder<sizeof...(Ts), Ts...>::type_ptr {try_get_mut<Ts>()...};
724 }
725
734 template<typename Second>
735 Second* try_get_mut_second(flecs::entity_t first) const {
736 auto second = _::type<Second>::id(world_);
737 ecs_assert( ecs_get_type_info(world_, ecs_pair(first, second)) != nullptr,
738 ECS_INVALID_PARAMETER, "pair is not a component");
739 ecs_assert( ecs_get_type_info(world_, ecs_pair(first, second))->component == second,
740 ECS_INVALID_PARAMETER, "type of pair is not Second");
742 "operation invalid for empty type");
743 return static_cast<Second*>(
744 ecs_get_mut_id(world_, id_, ecs_pair(first, second)));
745 }
746
755 template<typename First, typename Second>
756 Second* try_get_mut_second() const {
757 return try_get_mut<pair_object<First, Second>>();
758 }
759
760
761 /* get_mut */
762
769 template <typename T, if_t< is_actual<T>::value > = 0>
770 T& get_mut() const {
771 T* r = try_get_mut<T>();
772 ecs_assert(r != nullptr, ECS_INVALID_OPERATION,
773 "invalid get_mut: entity does not have component (use try_get_mut)");
774 return *r;
775 }
776
785 template <typename T, typename A = actual_type_t<T>,
786 if_t< flecs::is_pair<T>::value > = 0>
787 A& get_mut() const {
788 A* r = try_get_mut<T>();
789 ecs_assert(r != nullptr, ECS_INVALID_OPERATION,
790 "invalid get_mut: entity does not have component (use try_get_mut)");
791 return *r;
792 }
793
802 template <typename First, typename Second, typename P = pair<First, Second>,
803 typename A = actual_type_t<P>, if_not_t< flecs::is_pair<First>::value > = 0>
804 A& get_mut() const {
805 A* r = try_get_mut<First, Second>();
806 ecs_assert(r != nullptr, ECS_INVALID_OPERATION,
807 "invalid get_mut: entity does not have pair (use try_get_mut)");
808 return *r;
809 }
810
819 template<typename First, typename Second, if_not_t< is_enum<Second>::value> = 0>
820 First& get_mut(Second second) const {
821 First* r = try_get_mut<First>(second);
822 ecs_assert(r != nullptr, ECS_INVALID_OPERATION,
823 "invalid get_mut: entity does not have pair (use try_get_mut)");
824 return *r;
825 }
826
835 template<typename First, typename Second, if_t< is_enum<Second>::value && !std::is_same<First, Second>::value > = 0>
836 First& get_mut(Second constant) const {
837 const auto& et = enum_type<Second>(this->world_);
838 flecs::entity_t target = et.entity(constant);
839 return get_mut<First>(target);
840 }
841
848 void* get_mut(flecs::id_t comp) const {
849 void *r = ecs_get_mut_id(world_, id_, comp);
850 ecs_assert(r != nullptr, ECS_INVALID_OPERATION,
851 "invalid get_mut: entity does not have component (use try_get_mut)");
852 return r;
853 }
854
865 void* get_mut(flecs::entity_t first, flecs::entity_t second) const {
866 void *r = ecs_get_mut_id(world_, id_, ecs_pair(first, second));
867 ecs_assert(r != nullptr, ECS_INVALID_OPERATION,
868 "invalid get_mut: entity does not have pair (use try_get_mut)");
869 return r;
870 }
871
877 template<typename... Ts>
878 auto get_mut_n() const {
879 flecs_static_assert(sizeof...(Ts) > 1, "get_mut_n requires at least two components");
880 flecs_static_assert(sizeof...(Ts) < 9, "get_mut_n cannot fetch more than eight components");
881 return typename tuple_builder<sizeof...(Ts), Ts...>::type {get_mut<Ts>()...};
882 }
883
893 template<typename Second>
894 Second& get_mut_second(flecs::entity_t first) const {
895 Second *r = try_get_mut_second<Second>(first);
896 ecs_assert(r != nullptr, ECS_INVALID_OPERATION,
897 "invalid get_mut_second: entity does not have pair (use try_get_mut_second)");
898 return *r;
899 }
900
910 template<typename First, typename Second>
911 Second& get_mut_second() const {
912 Second *r = try_get_mut_second<First, Second>();
913 ecs_assert(r != nullptr, ECS_INVALID_OPERATION,
914 "invalid get_mut_second: entity does not have pair (use try_get_mut_second)");
915 return *r;
916 }
917
923 template<typename Enum>
924 Enum get_constant() const;
925
935 template<typename First>
936 flecs::entity target(int32_t index = 0) const;
937
947 flecs::entity target(flecs::entity_t first, int32_t index = 0) const;
948
968 flecs::entity target_for(flecs::entity_t relationship, flecs::id_t id) const;
969
976 template <typename T>
977 flecs::entity target_for(flecs::entity_t relationship) const;
978
986 template <typename First, typename Second>
987 flecs::entity target_for(flecs::entity_t relationship) const;
988
994 int32_t depth(flecs::entity_t rel) const {
995 return ecs_get_depth(world_, id_, rel);
996 }
997
1003 template<typename Rel>
1004 int32_t depth() const {
1005 return this->depth(_::type<Rel>::id(world_));
1006 }
1007
1013 flecs::entity parent() const;
1014
1023 flecs::entity lookup(const char *path, bool search_path = false) const;
1024
1030 bool has(flecs::id_t e) const {
1031 return ecs_has_id(world_, id_, e);
1032 }
1033
1039 template <typename T>
1040 bool has() const {
1041 flecs::id_t cid = _::type<T>::id(world_);
1042 bool result = ecs_has_id(world_, id_, cid);
1043 if (result) {
1044 return result;
1045 }
1046
1047 if (is_enum<T>::value) {
1048 return ecs_has_pair(world_, id_, cid, flecs::Wildcard);
1049 }
1050
1051 return false;
1052 }
1053
1060 template <typename E, if_t< is_enum<E>::value > = 0>
1061 bool has(E value) const {
1062 auto r = _::type<E>::id(world_);
1063 auto o = enum_type<E>(world_).entity(value);
1065 "Constant was not found in Enum reflection data."
1066 " Did you mean to use has<E>() instead of has(E)?");
1067 return ecs_has_pair(world_, id_, r, o);
1068 }
1069
1076 template <typename First, typename Second>
1077 bool has() const {
1078 return this->has<First>(_::type<Second>::id(world_));
1079 }
1080
1087 template<typename First, typename Second, if_not_t< is_enum<Second>::value > = 0>
1088 bool has(Second second) const {
1089 auto comp_id = _::type<First>::id(world_);
1090 return ecs_has_id(world_, id_, ecs_pair(comp_id, second));
1091 }
1092
1099 template <typename Second>
1100 bool has_second(flecs::entity_t first) const {
1101 return this->has(first, _::type<Second>::id(world_));
1102 }
1103
1110 template<typename First, typename E, if_t< is_enum<E>::value && !std::is_same<First, E>::value > = 0>
1111 bool has(E value) const {
1112 const auto& et = enum_type<E>(this->world_);
1113 flecs::entity_t second = et.entity(value);
1114 return has<First>(second);
1115 }
1116
1123 bool has(flecs::id_t first, flecs::id_t second) const {
1124 return ecs_has_id(world_, id_, ecs_pair(first, second));
1125 }
1126
1133 bool owns(flecs::id_t e) const {
1134 return ecs_owns_id(world_, id_, e);
1135 }
1136
1143 template <typename First>
1144 bool owns(flecs::id_t second) const {
1145 auto comp_id = _::type<First>::id(world_);
1146 return owns(ecs_pair(comp_id, second));
1147 }
1148
1155 bool owns(flecs::id_t first, flecs::id_t second) const {
1156 return owns(ecs_pair(first, second));
1157 }
1158
1165 template <typename T>
1166 bool owns() const {
1167 return owns(_::type<T>::id(world_));
1168 }
1169
1177 template <typename First, typename Second>
1178 bool owns() const {
1179 return owns(
1180 _::type<First>::id(world_),
1181 _::type<Second>::id(world_));
1182 }
1183
1190 template <typename Second>
1191 bool owns_second(flecs::entity_t first) const {
1192 return owns(first, _::type<Second>::id(world_));
1193 }
1194
1200 bool enabled(flecs::id_t id) const {
1201 return ecs_is_enabled_id(world_, id_, id);
1202 }
1203
1209 template<typename T>
1210 bool enabled() const {
1211 return this->enabled(_::type<T>::id(world_));
1212 }
1213
1220 bool enabled(flecs::id_t first, flecs::id_t second) const {
1221 return this->enabled(ecs_pair(first, second));
1222 }
1223
1230 template <typename First>
1231 bool enabled(flecs::id_t second) const {
1232 return this->enabled(_::type<First>::id(world_), second);
1233 }
1234
1241 template <typename First, typename Second>
1242 bool enabled() const {
1243 return this->enabled<First>(_::type<Second>::id(world_));
1244 }
1245
1253 flecs::entity clone(bool clone_value = true, flecs::entity_t dst_id = 0) const;
1254
1274 flecs::entity mut(const flecs::world& stage) const;
1275
1283 flecs::entity mut(const flecs::iter& it) const;
1284
1293 flecs::entity mut(const flecs::entity_view& e) const;
1294
1295# ifdef FLECS_JSON
1297# endif
1298# ifdef FLECS_DOC
1300# endif
1301# ifdef FLECS_ALERTS
1303# endif
1304
1307
1308private:
1309 flecs::entity set_stage(world_t *stage);
1310};
1311
1312}
1313
Alerts entity mixin.
component< T > & constant(const char *name, T value)
Add a constant.
Definition component.inl:38
Doc entity view mixin.
Utilities to fetch components as tuples from entities.
Enum entity view mixin.
Event entity mixin.
#define ecs_assert(condition, error_code,...)
Assert.
Definition log.h:473
#define ECS_INVALID_OPERATION
Invalid operation error code.
Definition log.h:669
#define ECS_INVALID_PARAMETER
Invalid parameter error code.
Definition log.h:671
const ecs_type_info_t * ecs_get_type_info(const ecs_world_t *world, ecs_id_t component)
Get the type info for a component.
ecs_id_t id_t
ID type.
Definition c_types.hpp:20
ecs_entity_t entity_t
Entity type.
Definition c_types.hpp:21
ecs_world_t world_t
World type.
Definition c_types.hpp:18
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 a custom relationship argument.
bool ecs_is_enabled_id(const ecs_world_t *world, ecs_entity_t entity, ecs_id_t component)
Test if a 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 the depth for an entity in the 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.
#define ecs_has_pair(world, entity, first, second)
Test if an entity has a pair.
Definition flecs_c.h:487
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 the world from a poly.
JSON entity mixin.
Component added to enum type entities.
Definition meta.h:289
Iterator.
Definition flecs.h:1190
Component class.
bool owns_second(flecs::entity_t first) const
Check if entity owns the provided pair.
flecs::type type() const
Get the entity's type.
Definition impl.hpp:94
auto try_get_n() const
Get multiple component values as a tuple of const pointers.
entity_view(entity_t id)
Implicit conversion from flecs::entity_t to flecs::entity_view.
int32_t depth(flecs::entity_t rel) const
Get the depth for a 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.
Definition impl.hpp:102
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 the depth for a 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.
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 & get_mut_second() const
Get the second part for a pair.
Second * try_get_mut_second(flecs::entity_t first) const
Get the second part for a pair.
const First & get(Second second) const
Get a pair.
void children(Func &&func) const
Iterate children for an 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.
Definition impl.hpp:98
flecs::string path_from(flecs::entity_t parent, const char *sep="::", const char *init_sep="::") const
Return the entity path relative to a parent.
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.
bool enabled() const
Check if entity is enabled (does not have the Disabled tag).
flecs::entity parent() const
Get parent of entity.
Definition impl.hpp:68
entity_view()
Default constructor.
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.
Definition impl.hpp:112
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 an entity.
const A & get() const
Get component value.
auto get_n() const
Get multiple component values as a tuple of const references.
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.
Definition impl.hpp:36
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 typed parent.
First * try_get_mut(Second constant) const
Get a mutable pair.
auto try_get_mut_n() const
Get multiple mutable component values as a tuple of pointers.
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 an entity.
auto get_mut_n() const
Get multiple mutable component values as a tuple of references.
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.
Entity.
Definition entity.hpp:30
entity()
Default constructor.
Definition entity.hpp:32
Class that wraps around a flecs::id_t.
Definition decl.hpp:27
flecs::world world() const
Get the world.
Definition impl.hpp:58
flecs::id_t id_
The raw ID value.
Definition decl.hpp:149
flecs::entity second() const
Get second element from a pair.
Definition impl.hpp:31
flecs::world_t * world_
World is optional, but guarantees that entity identifiers extracted from the ID are valid.
Definition decl.hpp:147
flecs::entity first() const
Get first element from a pair.
Definition impl.hpp:20
Class for iterating over query results.
Definition iter.hpp:68
Non-owning string view.
Definition string.hpp:169
Owned string wrapper.
Definition string.hpp:15
Table range.
Definition table.hpp:449
Table.
Definition table.hpp:23
Builds tuple types for a given number of component types.
Type class.
Definition type.hpp:21
The world.
Definition world.hpp:244