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
32 entity_view() : flecs::id() { }
33
39 explicit entity_view(flecs::world_t *world, flecs::id_t id)
40 : flecs::id(world
41 ? const_cast<flecs::world_t*>(ecs_get_world(world))
42 : nullptr
43 , id ) { }
44
46 entity_view(entity_t id)
47 : flecs::id( nullptr, id ) { }
48
52 entity_t id() const {
53 return id_;
54 }
55
65 bool is_valid() const {
66 return world_ && ecs_is_valid(world_, id_);
67 }
68
69 explicit operator bool() const {
70 return is_valid();
71 }
72
78 bool is_alive() const {
79 return world_ && ecs_is_alive(world_, id_);
80 }
81
87 return flecs::string_view(ecs_get_name(world_, id_));
88 }
89
95 return flecs::string_view(ecs_get_symbol(world_, id_));
96 }
97
102 flecs::string path(const char *sep = "::", const char *init_sep = "::") const {
103 return path_from(0, sep, init_sep);
104 }
105
110 flecs::string path_from(flecs::entity_t parent, const char *sep = "::", const char *init_sep = "::") const {
111 char *path = ecs_get_path_w_sep(world_, parent, id_, sep, init_sep);
112 return flecs::string(path);
113 }
114
119 template <typename Parent>
120 flecs::string path_from(const char *sep = "::", const char *init_sep = "::") const {
121 return path_from(_::type<Parent>::id(world_), sep, init_sep);
122 }
123
124 bool enabled() const {
125 return !ecs_has_id(world_, id_, flecs::Disabled);
126 }
127
132 flecs::type type() const;
133
138 flecs::table table() const;
139
148
158 template <typename Func>
159 void each(const Func& func) const;
160
170 template <typename Func>
171 void each(flecs::id_t first, flecs::id_t second, const Func& func) const;
172
183 template <typename Func>
184 void each(const flecs::entity_view& rel, const Func& func) const;
185
196 template <typename First, typename Func>
197 void each(const Func& func) const {
198 return each(_::type<First>::id(world_), func);
199 }
200
211 template <typename Func>
212 void children(flecs::entity_t rel, Func&& func) const {
213 /* When the entity is a wildcard, this would attempt to query for all
214 * entities with (ChildOf, *) or (ChildOf, _) instead of querying for
215 * the children of the wildcard entity. */
216 if (id_ == flecs::Wildcard || id_ == flecs::Any) {
217 /* This is correct, wildcard entities don't have children */
218 return;
219 }
220
221 flecs::world world(world_);
222
223 ecs_iter_t it = ecs_children_w_rel(world_, rel, id_);
224 while (ecs_children_next(&it)) {
225 _::each_delegate<Func>(FLECS_MOV(func)).invoke(&it);
226 }
227 }
228
239 template <typename Rel, typename Func>
240 void children(Func&& func) const {
241 children(_::type<Rel>::id(world_), FLECS_MOV(func));
242 }
243
255 template <typename Func>
256 void children(Func&& func) const {
257 children(flecs::ChildOf, FLECS_MOV(func));
258 }
259
260
261 /* try_get */
262
269 template <typename T, if_t< is_actual<T>::value > = 0>
270 const T* try_get() const {
271 auto comp_id = _::type<T>::id(world_);
272 ecs_assert(_::type<T>::size() != 0, ECS_INVALID_PARAMETER,
273 "operation invalid for empty type");
274 return static_cast<const T*>(ecs_get_id(world_, id_, comp_id));
275 }
276
285 template <typename T, typename A = actual_type_t<T>,
286 if_t< flecs::is_pair<T>::value > = 0>
287 const A* try_get() const {
288 auto comp_id = _::type<T>::id(world_);
289 ecs_assert(_::type<A>::size() != 0, ECS_INVALID_PARAMETER,
290 "operation invalid for empty type");
291 return static_cast<const A*>(ecs_get_id(world_, id_, comp_id));
292 }
293
300 template <typename First, typename Second, typename P = pair<First, Second>,
301 typename A = actual_type_t<P>, if_not_t< flecs::is_pair<First>::value > = 0>
302 const A* try_get() const {
303 return this->try_get<P>();
304 }
305
312 template<typename First, typename Second, if_not_t< is_enum<Second>::value> = 0>
313 const First* try_get(Second second) const {
314 auto first = _::type<First>::id(world_);
315 ecs_assert(_::type<First>::size() != 0, ECS_INVALID_PARAMETER,
316 "operation invalid for empty type");
317 return static_cast<const First*>(
318 ecs_get_id(world_, id_, ecs_pair(first, second)));
319 }
320
327 template<typename First, typename Second, if_t< is_enum<Second>::value && !std::is_same<First, Second>::value > = 0>
328 const First* try_get(Second constant) const {
329 const auto& et = enum_type<Second>(this->world_);
330 flecs::entity_t target = et.entity(constant);
331 return try_get<First>(target);
332 }
333
340 const void* try_get(flecs::id_t comp) const {
341 return ecs_get_id(world_, id_, comp);
342 }
343
352 const void* try_get(flecs::entity_t first, flecs::entity_t second) const {
353 return ecs_get_id(world_, id_, ecs_pair(first, second));
354 }
355
356 template<typename... Ts>
357 auto try_get_n() const {
358 flecs_static_assert(sizeof...(Ts) > 1, "try_get_n requires at least two components");
359 flecs_static_assert(sizeof...(Ts) < 9, "try_get_n cannot fetch more than eight components");
360 return typename tuple_builder<sizeof...(Ts), Ts...>::type_const_ptr {try_get<Ts>()...};
361 }
362
370 template<typename Second>
371 const Second* try_get_second(flecs::entity_t first) const {
372 auto second = _::type<Second>::id(world_);
373 ecs_assert( ecs_get_type_info(world_, ecs_pair(first, second)) != NULL,
374 ECS_INVALID_PARAMETER, "pair is not a component");
375 ecs_assert( ecs_get_type_info(world_, ecs_pair(first, second))->component == second,
376 ECS_INVALID_PARAMETER, "type of pair is not Second");
377 ecs_assert(_::type<Second>::size() != 0, ECS_INVALID_PARAMETER,
378 "operation invalid for empty type");
379 return static_cast<const Second*>(
380 ecs_get_id(world_, id_, ecs_pair(first, second)));
381 }
382
390 template<typename First, typename Second>
391 const Second* try_get_second() const {
392 return try_get<pair_object<First, Second>>();
393 }
394
395
396 /* get */
397
404 template <typename T, if_t< is_actual<T>::value > = 0>
405 const T& get() const {
406 const T *r = try_get<T>();
407 ecs_assert(r != nullptr, ECS_INVALID_OPERATION,
408 "invalid get: entity does not have component '%s' (use try_get)",
409 flecs::_::type_name<T>());
410 return *r;
411 }
412
421 template <typename T, typename A = actual_type_t<T>,
422 if_t< flecs::is_pair<T>::value > = 0>
423 const A& get() const {
424 const A *r = try_get<T>();
425 ecs_assert(r != nullptr, ECS_INVALID_OPERATION,
426 "invalid get: entity does not have component '%s' (use try_get)",
427 flecs::_::type_name<T>());
428 return *r;
429 }
430
439 template <typename First, typename Second, typename P = pair<First, Second>,
440 typename A = actual_type_t<P>, if_not_t< flecs::is_pair<First>::value > = 0>
441 const A& get() const {
442 return this->get<P>();
443 }
444
453 template<typename First, typename Second, if_not_t< is_enum<Second>::value> = 0>
454 const First& get(Second second) const {
455 const First *r = try_get<First>(second);
456 ecs_assert(r != nullptr, ECS_INVALID_OPERATION,
457 "invalid get: entity does not have component (use try_get)");
458 return *r;
459 }
460
469 template<typename First, typename Second, if_t< is_enum<Second>::value && !std::is_same<First, Second>::value > = 0>
470 const First& get(Second constant) const {
471 const auto& et = enum_type<Second>(this->world_);
472 flecs::entity_t target = et.entity(constant);
473 return get<First>(target);
474 }
475
482 const void* get(flecs::id_t comp) const {
483 const void *r = ecs_get_id(world_, id_, comp);
484 ecs_assert(r != nullptr, ECS_INVALID_OPERATION,
485 "invalid get: entity does not have component (use try_get)");
486 return r;
487 }
488
499 const void* get(flecs::entity_t first, flecs::entity_t second) const {
500 const void *r = ecs_get_id(world_, id_, ecs_pair(first, second));
501 ecs_assert(r != nullptr, ECS_INVALID_OPERATION,
502 "invalid get: entity does not have component (use try_get)");
503 return r;
504 }
505
540 template <typename Func, if_t< is_callable<Func>::value > = 0>
541 bool get(const Func& func) const;
542
543 template<typename... Ts>
544 auto get_n() const {
545 flecs_static_assert(sizeof...(Ts) > 1, "get_n requires at least two components");
546 flecs_static_assert(sizeof...(Ts) < 9, "get_n cannot fetch more than eight components");
547 return typename tuple_builder<sizeof...(Ts), Ts...>::type_const {get<Ts>()...};
548 }
549
557 template<typename Second>
558 const Second& get_second(flecs::entity_t first) const {
559 const Second *r = try_get_second<Second>(first);
560 ecs_assert(r != nullptr, ECS_INVALID_OPERATION,
561 "invalid get: entity does not have component (use try_get)");
562 return *r;
563 }
564
572 template<typename First, typename Second>
573 const Second& get_second() const {
574 const Second *r = try_get<First, Second>();
575 ecs_assert(r != nullptr, ECS_INVALID_OPERATION,
576 "invalid get: entity does not have component (use try_get)");
577 return *r;
578 }
579
580
581 /* try_get_mut */
582
589 template <typename T, if_t< is_actual<T>::value > = 0>
590 T* try_get_mut() const {
591 auto comp_id = _::type<T>::id(world_);
592 ecs_assert(_::type<T>::size() != 0, ECS_INVALID_PARAMETER,
593 "operation invalid for empty type");
594 return static_cast<T*>(ecs_get_mut_id(world_, id_, comp_id));
595 }
596
605 template <typename T, typename A = actual_type_t<T>,
606 if_t< flecs::is_pair<T>::value > = 0>
607 A* try_get_mut() const {
608 auto comp_id = _::type<T>::id(world_);
609 ecs_assert(_::type<A>::size() != 0, ECS_INVALID_PARAMETER,
610 "operation invalid for empty type");
611 return static_cast<A*>(ecs_get_mut_id(world_, id_, comp_id));
612 }
613
620 template <typename First, typename Second, typename P = pair<First, Second>,
621 typename A = actual_type_t<P>, if_not_t< flecs::is_pair<First>::value > = 0>
622 A* try_get_mut() const {
623 return this->try_get_mut<P>();
624 }
625
632 template<typename First, typename Second, if_not_t< is_enum<Second>::value> = 0>
633 First* try_get_mut(Second second) const {
634 auto first = _::type<First>::id(world_);
635 ecs_assert(_::type<First>::size() != 0, ECS_INVALID_PARAMETER,
636 "operation invalid for empty type");
637 return static_cast<First*>(
638 ecs_get_mut_id(world_, id_, ecs_pair(first, second)));
639 }
640
647 template<typename First, typename Second, if_t< is_enum<Second>::value && !std::is_same<First, Second>::value > = 0>
648 First* try_get_mut(Second constant) const {
649 const auto& et = enum_type<Second>(this->world_);
650 flecs::entity_t target = et.entity(constant);
651 return get_mut<First>(target);
652 }
653
660 void* try_get_mut(flecs::id_t comp) const {
661 return ecs_get_mut_id(world_, id_, comp);
662 }
663
672 void* try_get_mut(flecs::entity_t first, flecs::entity_t second) const {
673 return ecs_get_mut_id(world_, id_, ecs_pair(first, second));
674 }
675
676 template<typename... Ts>
677 auto try_get_mut_n() const {
678 flecs_static_assert(sizeof...(Ts) > 1, "try_get_mut_n requires at least two components");
679 flecs_static_assert(sizeof...(Ts) < 9, "try_get_mut_n cannot fetch more than eight components");
680 return typename tuple_builder<sizeof...(Ts), Ts...>::type_ptr {try_get_mut<Ts>()...};
681 }
682
690 template<typename Second>
691 Second* try_get_mut_second(flecs::entity_t first) const {
692 auto second = _::type<Second>::id(world_);
693 ecs_assert( ecs_get_type_info(world_, ecs_pair(first, second)) != NULL,
694 ECS_INVALID_PARAMETER, "pair is not a component");
695 ecs_assert( ecs_get_type_info(world_, ecs_pair(first, second))->component == second,
696 ECS_INVALID_PARAMETER, "type of pair is not Second");
697 ecs_assert(_::type<Second>::size() != 0, ECS_INVALID_PARAMETER,
698 "operation invalid for empty type");
699 return static_cast<Second*>(
700 ecs_get_mut_id(world_, id_, ecs_pair(first, second)));
701 }
702
710 template<typename First, typename Second>
711 Second* try_get_mut_second() const {
712 return get_mut<pair_object<First, Second>>();
713 }
714
715
716 /* get_mut */
717
724 template <typename T, if_t< is_actual<T>::value > = 0>
725 T& get_mut() const {
726 T* r = try_get_mut<T>();
727 ecs_assert(r != nullptr, ECS_INVALID_OPERATION,
728 "invalid get_mut: entity does not have component (use try_get_mut)");
729 return *r;
730 }
731
740 template <typename T, typename A = actual_type_t<T>,
741 if_t< flecs::is_pair<T>::value > = 0>
742 A& get_mut() const {
743 A* r = try_get_mut<T>();
744 ecs_assert(r != nullptr, ECS_INVALID_OPERATION,
745 "invalid get_mut: entity does not have component (use try_get_mut)");
746 return *r;
747 }
748
755 template <typename First, typename Second, typename P = pair<First, Second>,
756 typename A = actual_type_t<P>, if_not_t< flecs::is_pair<First>::value > = 0>
757 A& get_mut() const {
758 A* r = try_get_mut<First, Second>();
759 ecs_assert(r != nullptr, ECS_INVALID_OPERATION,
760 "invalid get_mut: entity does not have component (use try_get_mut)");
761 return *r;
762 }
763
770 template<typename First, typename Second, if_not_t< is_enum<Second>::value> = 0>
771 First& get_mut(Second second) const {
772 First* r = try_get_mut<First>(second);
773 ecs_assert(r != nullptr, ECS_INVALID_OPERATION,
774 "invalid get_mut: entity does not have component (use try_get_mut)");
775 return *r;
776 }
777
784 template<typename First, typename Second, if_t< is_enum<Second>::value && !std::is_same<First, Second>::value > = 0>
785 First& get_mut(Second constant) const {
786 const auto& et = enum_type<Second>(this->world_);
787 flecs::entity_t target = et.entity(constant);
788 return get_mut<First>(target);
789 }
790
797 void* get_mut(flecs::id_t comp) const {
798 void *r = ecs_get_mut_id(world_, id_, comp);
799 ecs_assert(r != nullptr, ECS_INVALID_OPERATION,
800 "invalid get_mut: entity does not have component (use try_get_mut)");
801 return r;
802 }
803
812 void* get_mut(flecs::entity_t first, flecs::entity_t second) const {
813 void *r = ecs_get_mut_id(world_, id_, ecs_pair(first, second));
814 ecs_assert(r != nullptr, ECS_INVALID_OPERATION,
815 "invalid get_mut: entity does not have component (use try_get_mut)");
816 return r;
817 }
818
819 template<typename... Ts>
820 auto get_mut_n() const {
821 flecs_static_assert(sizeof...(Ts) > 1, "get_mut_n requires at least two components");
822 flecs_static_assert(sizeof...(Ts) < 9, "get_mut_n cannot fetch more than eight components");
823 return typename tuple_builder<sizeof...(Ts), Ts...>::type {get_mut<Ts>()...};
824 }
825
833 template<typename Second>
834 Second& get_mut_second(flecs::entity_t first) const {
835 Second *r = try_get_mut_second<Second>(first);
836 ecs_assert(r != nullptr, ECS_INVALID_OPERATION,
837 "invalid get_mut: entity does not have component (use try_get_mut)");
838 return *r;
839 }
840
848 template<typename First, typename Second>
849 Second* get_mut_second() const {
850 Second *r = try_get_mut_second<First, Second>();
851 ecs_assert(r != nullptr, ECS_INVALID_OPERATION,
852 "invalid get_mut: entity does not have component (use try_get_mut)");
853 return *r;
854 }
855
857 template<typename Enum>
858 Enum get_constant() const;
859
868 template<typename First>
869 flecs::entity target(int32_t index = 0) const;
870
879 flecs::entity target(flecs::entity_t first, int32_t index = 0) const;
880
899 flecs::entity target_for(flecs::entity_t relationship, flecs::id_t id) const;
900
901 template <typename T>
902 flecs::entity target_for(flecs::entity_t relationship) const;
903
904 template <typename First, typename Second>
905 flecs::entity target_for(flecs::entity_t relationship) const;
906
912 int32_t depth(flecs::entity_t rel) const {
913 return ecs_get_depth(world_, id_, rel);
914 }
915
921 template<typename Rel>
922 int32_t depth() const {
923 return this->depth(_::type<Rel>::id(world_));
924 }
925
931 flecs::entity parent() const;
932
941 flecs::entity lookup(const char *path, bool search_path = false) const;
942
948 bool has(flecs::id_t e) const {
949 return ecs_has_id(world_, id_, e);
950 }
951
957 template <typename T>
958 bool has() const {
959 flecs::id_t cid = _::type<T>::id(world_);
960 bool result = ecs_has_id(world_, id_, cid);
961 if (result) {
962 return result;
963 }
964
965 if (is_enum<T>::value) {
966 return ecs_has_pair(world_, id_, cid, flecs::Wildcard);
967 }
968
969 return false;
970 }
971
978 template <typename E, if_t< is_enum<E>::value > = 0>
979 bool has(E value) const {
980 auto r = _::type<E>::id(world_);
981 auto o = enum_type<E>(world_).entity(value);
982 ecs_assert(o, ECS_INVALID_PARAMETER,
983 "Constant was not found in Enum reflection data."
984 " Did you mean to use has<E>() instead of has(E)?");
985 return ecs_has_pair(world_, id_, r, o);
986 }
987
994 template <typename First, typename Second>
995 bool has() const {
996 return this->has<First>(_::type<Second>::id(world_));
997 }
998
1005 template<typename First, typename Second, if_not_t< is_enum<Second>::value > = 0>
1006 bool has(Second second) const {
1007 auto comp_id = _::type<First>::id(world_);
1008 return ecs_has_id(world_, id_, ecs_pair(comp_id, second));
1009 }
1010
1017 template <typename Second>
1018 bool has_second(flecs::entity_t first) const {
1019 return this->has(first, _::type<Second>::id(world_));
1020 }
1021
1028 template<typename First, typename E, if_t< is_enum<E>::value && !std::is_same<First, E>::value > = 0>
1029 bool has(E value) const {
1030 const auto& et = enum_type<E>(this->world_);
1031 flecs::entity_t second = et.entity(value);
1032 return has<First>(second);
1033 }
1034
1041 bool has(flecs::id_t first, flecs::id_t second) const {
1042 return ecs_has_id(world_, id_, ecs_pair(first, second));
1043 }
1044
1051 bool owns(flecs::id_t e) const {
1052 return ecs_owns_id(world_, id_, e);
1053 }
1054
1061 template <typename First>
1062 bool owns(flecs::id_t second) const {
1063 auto comp_id = _::type<First>::id(world_);
1064 return owns(ecs_pair(comp_id, second));
1065 }
1066
1073 bool owns(flecs::id_t first, flecs::id_t second) const {
1074 return owns(ecs_pair(first, second));
1075 }
1076
1083 template <typename T>
1084 bool owns() const {
1085 return owns(_::type<T>::id(world_));
1086 }
1087
1095 template <typename First, typename Second>
1096 bool owns() const {
1097 return owns(
1098 _::type<First>::id(world_),
1099 _::type<Second>::id(world_));
1100 }
1101
1108 template <typename Second>
1109 bool owns_second(flecs::entity_t first) const {
1110 return owns(first, _::type<Second>::id(world_));
1111 }
1112
1118 bool enabled(flecs::id_t id) const {
1119 return ecs_is_enabled_id(world_, id_, id);
1120 }
1121
1127 template<typename T>
1128 bool enabled() const {
1129 return this->enabled(_::type<T>::id(world_));
1130 }
1131
1138 bool enabled(flecs::id_t first, flecs::id_t second) const {
1139 return this->enabled(ecs_pair(first, second));
1140 }
1141
1148 template <typename First>
1149 bool enabled(flecs::id_t second) const {
1150 return this->enabled(_::type<First>::id(world_), second);
1151 }
1152
1159 template <typename First, typename Second>
1160 bool enabled() const {
1161 return this->enabled<First>(_::type<Second>::id(world_));
1162 }
1163
1164 flecs::entity clone(bool clone_value = true, flecs::entity_t dst_id = 0) const;
1165
1185 flecs::entity mut(const flecs::world& stage) const;
1186
1194 flecs::entity mut(const flecs::iter& it) const;
1195
1204 flecs::entity mut(const flecs::entity_view& e) const;
1205
1206# ifdef FLECS_JSON
1208# endif
1209# ifdef FLECS_DOC
1211# endif
1212# ifdef FLECS_ALERTS
1214# endif
1215
1218
1219private:
1220 flecs::entity set_stage(world_t *stage);
1221};
1222
1223}
1224
Alerts entity mixin.
component< T > & constant(const char *name, T value)
Add constant.
Definition component.inl:31
Doc entity view mixin.
Utilities to fetch component as tuples from entities.
Enum entity view mixin.
Event entity mixin.
#define ecs_assert(condition, error_code,...)
Assert.
Definition log.h:368
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.
JSON entity mixin.
Component added to enum type entities.
Definition meta.h:285
Iterator.
Definition flecs.h:1162
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
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.
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 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.
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.
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.
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.
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.
Definition impl.hpp:68
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 entity.
const A & get() const
Get component value.
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 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.
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
Class that wraps around a flecs::id_t.
Definition decl.hpp:27
flecs::entity second() const
Get second element from a pair.
Definition impl.hpp:31
flecs::entity first() const
Get first element from a pair.
Definition impl.hpp:20
Class for iterating over query results.
Definition iter.hpp:68
Type class.
Definition type.hpp:21
The world.
Definition world.hpp:174