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*>(ecs_get_id(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)) != NULL,
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
567 template <typename Func, if_t< is_callable<Func>::value > = 0>
568 bool get(const Func& func) const;
569
575 template<typename... Ts>
576 auto get_n() const {
577 flecs_static_assert(sizeof...(Ts) > 1, "get_n requires at least two components");
578 flecs_static_assert(sizeof...(Ts) < 9, "get_n cannot fetch more than eight components");
579 return typename tuple_builder<sizeof...(Ts), Ts...>::type_const {get<Ts>()...};
580 }
581
591 template<typename Second>
592 const Second& get_second(flecs::entity_t first) const {
593 const Second *r = try_get_second<Second>(first);
594 ecs_assert(r != nullptr, ECS_INVALID_OPERATION,
595 "invalid get_second: entity does not have pair (use try_get_second)");
596 return *r;
597 }
598
608 template<typename First, typename Second>
609 const Second& get_second() const {
610 const Second *r = try_get<First, Second>();
611 ecs_assert(r != nullptr, ECS_INVALID_OPERATION,
612 "invalid get_second: entity does not have pair (use try_get_second)");
613 return *r;
614 }
615
616
617 /* try_get_mut */
618
625 template <typename T, if_t< is_actual<T>::value > = 0>
626 T* try_get_mut() const {
627 auto comp_id = _::type<T>::id(world_);
629 "operation invalid for empty type");
630 return static_cast<T*>(ecs_get_mut_id(world_, id_, comp_id));
631 }
632
641 template <typename T, typename A = actual_type_t<T>,
642 if_t< flecs::is_pair<T>::value > = 0>
643 A* try_get_mut() const {
644 auto comp_id = _::type<T>::id(world_);
646 "operation invalid for empty type");
647 return static_cast<A*>(ecs_get_mut_id(world_, id_, comp_id));
648 }
649
657 template <typename First, typename Second, typename P = pair<First, Second>,
658 typename A = actual_type_t<P>, if_not_t< flecs::is_pair<First>::value > = 0>
659 A* try_get_mut() const {
660 return this->try_get_mut<P>();
661 }
662
670 template<typename First, typename Second, if_not_t< is_enum<Second>::value> = 0>
671 First* try_get_mut(Second second) const {
672 auto first = _::type<First>::id(world_);
674 "operation invalid for empty type");
675 return static_cast<First*>(
676 ecs_get_mut_id(world_, id_, ecs_pair(first, second)));
677 }
678
686 template<typename First, typename Second, if_t< is_enum<Second>::value && !std::is_same<First, Second>::value > = 0>
687 First* try_get_mut(Second constant) const {
688 const auto& et = enum_type<Second>(this->world_);
689 flecs::entity_t target = et.entity(constant);
690 return try_get_mut<First>(target);
691 }
692
699 void* try_get_mut(flecs::id_t comp) const {
700 return ecs_get_mut_id(world_, id_, comp);
701 }
702
712 void* try_get_mut(flecs::entity_t first, flecs::entity_t second) const {
713 return ecs_get_mut_id(world_, id_, ecs_pair(first, second));
714 }
715
721 template<typename... Ts>
722 auto try_get_mut_n() const {
723 flecs_static_assert(sizeof...(Ts) > 1, "try_get_mut_n requires at least two components");
724 flecs_static_assert(sizeof...(Ts) < 9, "try_get_mut_n cannot fetch more than eight components");
725 return typename tuple_builder<sizeof...(Ts), Ts...>::type_ptr {try_get_mut<Ts>()...};
726 }
727
736 template<typename Second>
737 Second* try_get_mut_second(flecs::entity_t first) const {
738 auto second = _::type<Second>::id(world_);
739 ecs_assert( ecs_get_type_info(world_, ecs_pair(first, second)) != NULL,
740 ECS_INVALID_PARAMETER, "pair is not a component");
741 ecs_assert( ecs_get_type_info(world_, ecs_pair(first, second))->component == second,
742 ECS_INVALID_PARAMETER, "type of pair is not Second");
744 "operation invalid for empty type");
745 return static_cast<Second*>(
746 ecs_get_mut_id(world_, id_, ecs_pair(first, second)));
747 }
748
757 template<typename First, typename Second>
758 Second* try_get_mut_second() const {
759 return try_get_mut<pair_object<First, Second>>();
760 }
761
762
763 /* get_mut */
764
771 template <typename T, if_t< is_actual<T>::value > = 0>
772 T& get_mut() const {
773 T* r = try_get_mut<T>();
774 ecs_assert(r != nullptr, ECS_INVALID_OPERATION,
775 "invalid get_mut: entity does not have component (use try_get_mut)");
776 return *r;
777 }
778
787 template <typename T, typename A = actual_type_t<T>,
788 if_t< flecs::is_pair<T>::value > = 0>
789 A& get_mut() const {
790 A* r = try_get_mut<T>();
791 ecs_assert(r != nullptr, ECS_INVALID_OPERATION,
792 "invalid get_mut: entity does not have component (use try_get_mut)");
793 return *r;
794 }
795
804 template <typename First, typename Second, typename P = pair<First, Second>,
805 typename A = actual_type_t<P>, if_not_t< flecs::is_pair<First>::value > = 0>
806 A& get_mut() const {
807 A* r = try_get_mut<First, Second>();
808 ecs_assert(r != nullptr, ECS_INVALID_OPERATION,
809 "invalid get_mut: entity does not have pair (use try_get_mut)");
810 return *r;
811 }
812
821 template<typename First, typename Second, if_not_t< is_enum<Second>::value> = 0>
822 First& get_mut(Second second) const {
823 First* r = try_get_mut<First>(second);
824 ecs_assert(r != nullptr, ECS_INVALID_OPERATION,
825 "invalid get_mut: entity does not have pair (use try_get_mut)");
826 return *r;
827 }
828
837 template<typename First, typename Second, if_t< is_enum<Second>::value && !std::is_same<First, Second>::value > = 0>
838 First& get_mut(Second constant) const {
839 const auto& et = enum_type<Second>(this->world_);
840 flecs::entity_t target = et.entity(constant);
841 return get_mut<First>(target);
842 }
843
850 void* get_mut(flecs::id_t comp) const {
851 void *r = ecs_get_mut_id(world_, id_, comp);
852 ecs_assert(r != nullptr, ECS_INVALID_OPERATION,
853 "invalid get_mut: entity does not have component (use try_get_mut)");
854 return r;
855 }
856
867 void* get_mut(flecs::entity_t first, flecs::entity_t second) const {
868 void *r = ecs_get_mut_id(world_, id_, ecs_pair(first, second));
869 ecs_assert(r != nullptr, ECS_INVALID_OPERATION,
870 "invalid get_mut: entity does not have pair (use try_get_mut)");
871 return r;
872 }
873
879 template<typename... Ts>
880 auto get_mut_n() const {
881 flecs_static_assert(sizeof...(Ts) > 1, "get_mut_n requires at least two components");
882 flecs_static_assert(sizeof...(Ts) < 9, "get_mut_n cannot fetch more than eight components");
883 return typename tuple_builder<sizeof...(Ts), Ts...>::type {get_mut<Ts>()...};
884 }
885
895 template<typename Second>
896 Second& get_mut_second(flecs::entity_t first) const {
897 Second *r = try_get_mut_second<Second>(first);
898 ecs_assert(r != nullptr, ECS_INVALID_OPERATION,
899 "invalid get_mut_second: entity does not have pair (use try_get_mut_second)");
900 return *r;
901 }
902
912 template<typename First, typename Second>
913 Second& get_mut_second() const {
914 Second *r = try_get_mut_second<First, Second>();
915 ecs_assert(r != nullptr, ECS_INVALID_OPERATION,
916 "invalid get_mut_second: entity does not have pair (use try_get_mut_second)");
917 return *r;
918 }
919
925 template<typename Enum>
926 Enum get_constant() const;
927
937 template<typename First>
938 flecs::entity target(int32_t index = 0) const;
939
949 flecs::entity target(flecs::entity_t first, int32_t index = 0) const;
950
970 flecs::entity target_for(flecs::entity_t relationship, flecs::id_t id) const;
971
978 template <typename T>
979 flecs::entity target_for(flecs::entity_t relationship) const;
980
988 template <typename First, typename Second>
989 flecs::entity target_for(flecs::entity_t relationship) const;
990
996 int32_t depth(flecs::entity_t rel) const {
997 return ecs_get_depth(world_, id_, rel);
998 }
999
1005 template<typename Rel>
1006 int32_t depth() const {
1007 return this->depth(_::type<Rel>::id(world_));
1008 }
1009
1015 flecs::entity parent() const;
1016
1025 flecs::entity lookup(const char *path, bool search_path = false) const;
1026
1032 bool has(flecs::id_t e) const {
1033 return ecs_has_id(world_, id_, e);
1034 }
1035
1041 template <typename T>
1042 bool has() const {
1043 flecs::id_t cid = _::type<T>::id(world_);
1044 bool result = ecs_has_id(world_, id_, cid);
1045 if (result) {
1046 return result;
1047 }
1048
1049 if (is_enum<T>::value) {
1050 return ecs_has_pair(world_, id_, cid, flecs::Wildcard);
1051 }
1052
1053 return false;
1054 }
1055
1062 template <typename E, if_t< is_enum<E>::value > = 0>
1063 bool has(E value) const {
1064 auto r = _::type<E>::id(world_);
1065 auto o = enum_type<E>(world_).entity(value);
1067 "Constant was not found in Enum reflection data."
1068 " Did you mean to use has<E>() instead of has(E)?");
1069 return ecs_has_pair(world_, id_, r, o);
1070 }
1071
1078 template <typename First, typename Second>
1079 bool has() const {
1080 return this->has<First>(_::type<Second>::id(world_));
1081 }
1082
1089 template<typename First, typename Second, if_not_t< is_enum<Second>::value > = 0>
1090 bool has(Second second) const {
1091 auto comp_id = _::type<First>::id(world_);
1092 return ecs_has_id(world_, id_, ecs_pair(comp_id, second));
1093 }
1094
1101 template <typename Second>
1102 bool has_second(flecs::entity_t first) const {
1103 return this->has(first, _::type<Second>::id(world_));
1104 }
1105
1112 template<typename First, typename E, if_t< is_enum<E>::value && !std::is_same<First, E>::value > = 0>
1113 bool has(E value) const {
1114 const auto& et = enum_type<E>(this->world_);
1115 flecs::entity_t second = et.entity(value);
1116 return has<First>(second);
1117 }
1118
1125 bool has(flecs::id_t first, flecs::id_t second) const {
1126 return ecs_has_id(world_, id_, ecs_pair(first, second));
1127 }
1128
1135 bool owns(flecs::id_t e) const {
1136 return ecs_owns_id(world_, id_, e);
1137 }
1138
1145 template <typename First>
1146 bool owns(flecs::id_t second) const {
1147 auto comp_id = _::type<First>::id(world_);
1148 return owns(ecs_pair(comp_id, second));
1149 }
1150
1157 bool owns(flecs::id_t first, flecs::id_t second) const {
1158 return owns(ecs_pair(first, second));
1159 }
1160
1167 template <typename T>
1168 bool owns() const {
1169 return owns(_::type<T>::id(world_));
1170 }
1171
1179 template <typename First, typename Second>
1180 bool owns() const {
1181 return owns(
1182 _::type<First>::id(world_),
1183 _::type<Second>::id(world_));
1184 }
1185
1192 template <typename Second>
1193 bool owns_second(flecs::entity_t first) const {
1194 return owns(first, _::type<Second>::id(world_));
1195 }
1196
1202 bool enabled(flecs::id_t id) const {
1203 return ecs_is_enabled_id(world_, id_, id);
1204 }
1205
1211 template<typename T>
1212 bool enabled() const {
1213 return this->enabled(_::type<T>::id(world_));
1214 }
1215
1222 bool enabled(flecs::id_t first, flecs::id_t second) const {
1223 return this->enabled(ecs_pair(first, second));
1224 }
1225
1232 template <typename First>
1233 bool enabled(flecs::id_t second) const {
1234 return this->enabled(_::type<First>::id(world_), second);
1235 }
1236
1243 template <typename First, typename Second>
1244 bool enabled() const {
1245 return this->enabled<First>(_::type<Second>::id(world_));
1246 }
1247
1255 flecs::entity clone(bool clone_value = true, flecs::entity_t dst_id = 0) const;
1256
1276 flecs::entity mut(const flecs::world& stage) const;
1277
1285 flecs::entity mut(const flecs::iter& it) const;
1286
1295 flecs::entity mut(const flecs::entity_view& e) const;
1296
1297# ifdef FLECS_JSON
1299# endif
1300# ifdef FLECS_DOC
1302# endif
1303# ifdef FLECS_ALERTS
1305# endif
1306
1309
1310private:
1311 flecs::entity set_stage(world_t *stage);
1312};
1313
1314}
1315
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:659
#define ECS_INVALID_PARAMETER
Invalid parameter error code.
Definition log.h:661
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:534
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:285
Iterator.
Definition flecs.h:1166
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:246