Flecs: include/flecs/addons/cpp/entity_view.hpp Source File
Description: A fast entity component system (ECS) for C & C++

| Flecs v4.0 A fast entity component system (ECS) for C & C++

Loading...
Searching...
No Matches
entity_view.hpp
Go to the documentation of this file.
1
12
13#pragma once
14
16 * @ingroup cpp_entities
17 * @{
18 */
19
20namespace flecs
21{
22
28 struct entity_view : public id {
29
30 entity_view() : flecs::id() { }
31
32
35 * @param id The entity id.
36 */
37 explicit entity_view(flecs::world_t *world, flecs::id_t id)
38 : flecs::id(world
39 ? const_cast<flecs::world_t*>(ecs_get_world(world))
40 : nullptr
41 , id ) { }
42
44 entity_view(entity_t id)
45 : flecs::id( nullptr, id ) { }
46
50 entity_t id() const {
51 return id_;
52 }
53
55 * An entity is valid if:
56 * - its id is not 0
57 * - the id contains a valid bit pattern for an entity
58 * - the entity is alive (see is_alive())
59 *
60 * @return True if the entity is valid, false otherwise.
61 * @see ecs_is_valid()
62 */
63 bool is_valid() const {
64 return world_ && ecs_is_valid(world_, id_);
65 }
66
67 explicit operator bool() const {
68 return is_valid();
69 }
70
71
76 bool is_alive() const {
77 return world_ && ecs_is_alive(world_, id_);
78 }
79
81 *
82 * @return The entity name.
83 */
84 flecs::string_view name() const {
85 return flecs::string_view(ecs_get_name(world_, id_));
86 }
87
92 flecs::string_view symbol() const {
93 return flecs::string_view(ecs_get_symbol(world_, id_));
94 }
95
100 flecs::string path(const char *sep = "::", const char *init_sep = "::") const {
101 return path_from(0, sep, init_sep);
102 }
103
108 flecs::string path_from(flecs::entity_t parent, const char *sep = "::", const char *init_sep = "::") const {
109 char *path = ecs_get_path_w_sep(world_, parent, id_, sep, init_sep);
110 return flecs::string(path);
111 }
112
117 template <typename Parent>
118 flecs::string path_from(const char *sep = "::", const char *init_sep = "::") const {
119 return path_from(_::type<Parent>::id(world_), sep, init_sep);
120 }
121
122 bool enabled() const {
123 return !ecs_has_id(world_, id_, flecs::Disabled);
124 }
125
130 flecs::type type() const;
131
136 flecs::table table() const;
137
145 flecs::table_range range() const;
146
156 template <typename Func>
157 void each(const Func& func) const;
158
168 template <typename Func>
169 void each(flecs::id_t first, flecs::id_t second, const Func& func) const;
170
181 template <typename Func>
182 void each(const flecs::entity_view& rel, const Func& func) const;
183
194 template <typename First, typename Func>
195 void each(const Func& func) const {
196 return each(_::type<First>::id(world_), func);
197 }
198
209 template <typename Func>
210 void children(flecs::entity_t rel, Func&& func) const {
211 /* When the entity is a wildcard, this would attempt to query for all
212 * entities with (ChildOf, *) or (ChildOf, _) instead of querying for
213 * the children of the wildcard entity. */
214 if (id_ == flecs::Wildcard || id_ == flecs::Any) {
215 /* This is correct, wildcard entities don't have children */
216 return;
217 }
218
219 flecs::world world(world_);
220
221 if (rel == flecs::ChildOf) {
222 ecs_iter_t it = ecs_children(world_, id_);
223 while (ecs_children_next(&it)) {
224 _::each_delegate<Func>(FLECS_MOV(func)).invoke(&it);
225 }
226 } else {
227 ecs_iter_t it = ecs_each_id(world_, ecs_pair(rel, id_));
228 while (ecs_each_next(&it)) {
229 _::each_delegate<Func>(FLECS_MOV(func)).invoke(&it);
230 }
231 }
232 }
233
244 template <typename Rel, typename Func>
245 void children(Func&& func) const {
246 children(_::type<Rel>::id(world_), FLECS_MOV(func));
247 }
248
260 template <typename Func>
261 void children(Func&& func) const {
262 children(flecs::ChildOf, FLECS_MOV(func));
263 }
264
265
266 /* try_get */
267
274 template <typename T, if_t< is_actual<T>::value > = 0>
275 const T* try_get() const {
276 auto comp_id = _::type<T>::id(world_);
277 ecs_assert(_::type<T>::size() != 0, ECS_INVALID_PARAMETER,
278 "operation invalid for empty type");
279 return static_cast<const T*>(ecs_get_id(world_, id_, comp_id));
280 }
281
290 template <typename T, typename A = actual_type_t<T>,
291 if_t< flecs::is_pair<T>::value > = 0>
292 const A* try_get() const {
293 auto comp_id = _::type<T>::id(world_);
294 ecs_assert(_::type<A>::size() != 0, ECS_INVALID_PARAMETER,
295 "operation invalid for empty type");
296 return static_cast<const A*>(ecs_get_id(world_, id_, comp_id));
297 }
298
305 template <typename First, typename Second, typename P = pair<First, Second>,
306 typename A = actual_type_t<P>, if_not_t< flecs::is_pair<First>::value > = 0>
307 const A* try_get() const {
308 return this->try_get<P>();
309 }
310
317 template<typename First, typename Second, if_not_t< is_enum<Second>::value> = 0>
318 const First* try_get(Second second) const {
319 auto first = _::type<First>::id(world_);
320 ecs_assert(_::type<First>::size() != 0, ECS_INVALID_PARAMETER,
321 "operation invalid for empty type");
322 return static_cast<const First*>(
323 ecs_get_id(world_, id_, ecs_pair(first, second)));
324 }
325
332 template<typename First, typename Second, if_t< is_enum<Second>::value && !std::is_same<First, Second>::value > = 0>
333 const First* try_get(Second constant) const {
334 const auto& et = enum_type<Second>(this->world_);
335 flecs::entity_t target = et.entity(constant);
336 return try_get<First>(target);
337 }
338
345 const void* try_get(flecs::id_t comp) const {
346 return ecs_get_id(world_, id_, comp);
347 }
348
357 const void* try_get(flecs::entity_t first, flecs::entity_t second) const {
358 return ecs_get_id(world_, id_, ecs_pair(first, second));
359 }
360
368 template<typename Second>
369 const Second* try_get_second(flecs::entity_t first) const {
370 auto second = _::type<Second>::id(world_);
371 ecs_assert( ecs_get_type_info(world_, ecs_pair(first, second)) != NULL,
372 ECS_INVALID_PARAMETER, "pair is not a component");
373 ecs_assert( ecs_get_type_info(world_, ecs_pair(first, second))->component == second,
374 ECS_INVALID_PARAMETER, "type of pair is not Second");
375 ecs_assert(_::type<Second>::size() != 0, ECS_INVALID_PARAMETER,
376 "operation invalid for empty type");
377 return static_cast<const Second*>(
378 ecs_get_id(world_, id_, ecs_pair(first, second)));
379 }
380
388 template<typename First, typename Second>
389 const Second* try_get_second() const {
390 return try_get<pair_object<First, Second>>();
391 }
392
393
394 /* get */
395
402 template <typename T, if_t< is_actual<T>::value > = 0>
403 const T& get() const {
404 const T *r = try_get<T>();
405 ecs_assert(r != nullptr, ECS_INVALID_OPERATION,
406 "invalid get: entity does not have component (use try_get)");
407 return *r;
408 }
409
418 template <typename T, typename A = actual_type_t<T>,
419 if_t< flecs::is_pair<T>::value > = 0>
420 const A& get() const {
421 const A *r = try_get<T>();
422 ecs_assert(r != nullptr, ECS_INVALID_OPERATION,
423 "invalid get: entity does not have component (use try_get)");
424 return *r;
425 }
426
435 template <typename First, typename Second, typename P = pair<First, Second>,
436 typename A = actual_type_t<P>, if_not_t< flecs::is_pair<First>::value > = 0>
437 const A& get() const {
438 return this->get<P>();
439 }
440
449 template<typename First, typename Second, if_not_t< is_enum<Second>::value> = 0>
450 const First& get(Second second) const {
451 const First *r = try_get<First>(second);
452 ecs_assert(r != nullptr, ECS_INVALID_OPERATION,
453 "invalid get: entity does not have component (use try_get)");
454 return *r;
455 }
456
465 template<typename First, typename Second, if_t< is_enum<Second>::value && !std::is_same<First, Second>::value > = 0>
466 const First& get(Second constant) const {
467 const auto& et = enum_type<Second>(this->world_);
468 flecs::entity_t target = et.entity(constant);
469 return get<First>(target);
470 }
471
478 const void* get(flecs::id_t comp) const {
479 const void *r = ecs_get_id(world_, id_, comp);
480 ecs_assert(r != nullptr, ECS_INVALID_OPERATION,
481 "invalid get: entity does not have component (use try_get)");
482 return r;
483 }
484
495 const void* get(flecs::entity_t first, flecs::entity_t second) const {
496 const void *r = ecs_get_id(world_, id_, ecs_pair(first, second));
497 ecs_assert(r != nullptr, ECS_INVALID_OPERATION,
498 "invalid get: entity does not have component (use try_get)");
499 return r;
500 }
501
536 template <typename Func, if_t< is_callable<Func>::value > = 0>
537 bool get(const Func& func) const;
538
546 template<typename Second>
547 const Second& get_second(flecs::entity_t first) const {
548 const Second *r = try_get_second<Second>(first);
549 ecs_assert(r != nullptr, ECS_INVALID_OPERATION,
550 "invalid get: entity does not have component (use try_get)");
551 return *r;
552 }
553
561 template<typename First, typename Second>
562 const Second& get_second() const {
563 const Second *r = try_get<First, Second>();
564 ecs_assert(r != nullptr, ECS_INVALID_OPERATION,
565 "invalid get: entity does not have component (use try_get)");
566 return *r;
567 }
568
569
570 /* try_get_mut */
571
578 template <typename T, if_t< is_actual<T>::value > = 0>
579 T* try_get_mut() const {
580 auto comp_id = _::type<T>::id(world_);
581 ecs_assert(_::type<T>::size() != 0, ECS_INVALID_PARAMETER,
582 "operation invalid for empty type");
583 return static_cast<T*>(ecs_get_mut_id(world_, id_, comp_id));
584 }
585
594 template <typename T, typename A = actual_type_t<T>,
595 if_t< flecs::is_pair<T>::value > = 0>
596 A* try_get_mut() const {
597 auto comp_id = _::type<T>::id(world_);
598 ecs_assert(_::type<A>::size() != 0, ECS_INVALID_PARAMETER,
599 "operation invalid for empty type");
600 return static_cast<A*>(ecs_get_mut_id(world_, id_, comp_id));
601 }
602
609 template <typename First, typename Second, typename P = pair<First, Second>,
610 typename A = actual_type_t<P>, if_not_t< flecs::is_pair<First>::value > = 0>
611 A* try_get_mut() const {
612 return this->try_get_mut<P>();
613 }
614
621 template<typename First, typename Second, if_not_t< is_enum<Second>::value> = 0>
622 First* try_get_mut(Second second) const {
623 auto first = _::type<First>::id(world_);
624 ecs_assert(_::type<First>::size() != 0, ECS_INVALID_PARAMETER,
625 "operation invalid for empty type");
626 return static_cast<First*>(
627 ecs_get_mut_id(world_, id_, ecs_pair(first, second)));
628 }
629
636 template<typename First, typename Second, if_t< is_enum<Second>::value && !std::is_same<First, Second>::value > = 0>
637 First* try_get_mut(Second constant) const {
638 const auto& et = enum_type<Second>(this->world_);
639 flecs::entity_t target = et.entity(constant);
640 return get_mut<First>(target);
641 }
642
649 void* try_get_mut(flecs::id_t comp) const {
650 return ecs_get_mut_id(world_, id_, comp);
651 }
652
661 void* try_get_mut(flecs::entity_t first, flecs::entity_t second) const {
662 return ecs_get_mut_id(world_, id_, ecs_pair(first, second));
663 }
664
672 template<typename Second>
673 Second* try_get_mut_second(flecs::entity_t first) const {
674 auto second = _::type<Second>::id(world_);
675 ecs_assert( ecs_get_type_info(world_, ecs_pair(first, second)) != NULL,
676 ECS_INVALID_PARAMETER, "pair is not a component");
677 ecs_assert( ecs_get_type_info(world_, ecs_pair(first, second))->component == second,
678 ECS_INVALID_PARAMETER, "type of pair is not Second");
679 ecs_assert(_::type<Second>::size() != 0, ECS_INVALID_PARAMETER,
680 "operation invalid for empty type");
681 return static_cast<Second*>(
682 ecs_get_mut_id(world_, id_, ecs_pair(first, second)));
683 }
684
692 template<typename First, typename Second>
693 Second* try_get_mut_second() const {
694 return get_mut<pair_object<First, Second>>();
695 }
696
697
698 /* get_mut */
699
706 template <typename T, if_t< is_actual<T>::value > = 0>
707 T& get_mut() const {
708 T* r = try_get_mut<T>();
709 ecs_assert(r != nullptr, ECS_INVALID_OPERATION,
710 "invalid get_mut: entity does not have component (use try_get_mut)");
711 return *r;
712 }
713
722 template <typename T, typename A = actual_type_t<T>,
723 if_t< flecs::is_pair<T>::value > = 0>
724 A& get_mut() const {
725 A* r = try_get_mut<T>();
726 ecs_assert(r != nullptr, ECS_INVALID_OPERATION,
727 "invalid get_mut: entity does not have component (use try_get_mut)");
728 return *r;
729 }
730
737 template <typename First, typename Second, typename P = pair<First, Second>,
738 typename A = actual_type_t<P>, if_not_t< flecs::is_pair<First>::value > = 0>
739 A& get_mut() const {
740 A* r = try_get_mut<First, Second>();
741 ecs_assert(r != nullptr, ECS_INVALID_OPERATION,
742 "invalid get_mut: entity does not have component (use try_get_mut)");
743 return *r;
744 }
745
752 template<typename First, typename Second, if_not_t< is_enum<Second>::value> = 0>
753 First& get_mut(Second second) const {
754 First* r = try_get_mut<First>(second);
755 ecs_assert(r != nullptr, ECS_INVALID_OPERATION,
756 "invalid get_mut: entity does not have component (use try_get_mut)");
757 return *r;
758 }
759
766 template<typename First, typename Second, if_t< is_enum<Second>::value && !std::is_same<First, Second>::value > = 0>
767 First& get_mut(Second constant) const {
768 const auto& et = enum_type<Second>(this->world_);
769 flecs::entity_t target = et.entity(constant);
770 return get_mut<First>(target);
771 }
772
779 void* get_mut(flecs::id_t comp) const {
780 void *r = ecs_get_mut_id(world_, id_, comp);
781 ecs_assert(r != nullptr, ECS_INVALID_OPERATION,
782 "invalid get_mut: entity does not have component (use try_get_mut)");
783 return r;
784 }
785
794 void* get_mut(flecs::entity_t first, flecs::entity_t second) const {
795 void *r = ecs_get_mut_id(world_, id_, ecs_pair(first, second));
796 ecs_assert(r != nullptr, ECS_INVALID_OPERATION,
797 "invalid get_mut: entity does not have component (use try_get_mut)");
798 return r;
799 }
800
808 template<typename Second>
809 Second& get_mut_second(flecs::entity_t first) const {
810 Second *r = try_get_mut_second<Second>(first);
811 ecs_assert(r != nullptr, ECS_INVALID_OPERATION,
812 "invalid get_mut: entity does not have component (use try_get_mut)");
813 return *r;
814 }
815
823 template<typename First, typename Second>
824 Second* get_mut_second() const {
825 Second *r = try_get_mut_second<First, Second>();
826 ecs_assert(r != nullptr, ECS_INVALID_OPERATION,
827 "invalid get_mut: entity does not have component (use try_get_mut)");
828 return *r;
829 }
830
832 template<typename Enum>
833 Enum get_constant() const;
834
843 template<typename First>
844 flecs::entity target(int32_t index = 0) const;
845
854 flecs::entity target(flecs::entity_t first, int32_t index = 0) const;
855
874 flecs::entity target_for(flecs::entity_t relationship, flecs::id_t id) const;
875
876 template <typename T>
877 flecs::entity target_for(flecs::entity_t relationship) const;
878
879 template <typename First, typename Second>
880 flecs::entity target_for(flecs::entity_t relationship) const;
881
887 int32_t depth(flecs::entity_t rel) const {
888 return ecs_get_depth(world_, id_, rel);
889 }
890
896 template<typename Rel>
897 int32_t depth() const {
898 return this->depth(_::type<Rel>::id(world_));
899 }
900
906 flecs::entity parent() const;
907
916 flecs::entity lookup(const char *path, bool search_path = false) const;
917
923 bool has(flecs::id_t e) const {
924 return ecs_has_id(world_, id_, e);
925 }
926
932 template <typename T>
933 bool has() const {
934 flecs::id_t cid = _::type<T>::id(world_);
935 bool result = ecs_has_id(world_, id_, cid);
936 if (result) {
937 return result;
938 }
939
940 if (is_enum<T>::value) {
941 return ecs_has_pair(world_, id_, cid, flecs::Wildcard);
942 }
943
944 return false;
945 }
946
953 template <typename E, if_t< is_enum<E>::value > = 0>
954 bool has(E value) const {
955 auto r = _::type<E>::id(world_);
956 auto o = enum_type<E>(world_).entity(value);
957 ecs_assert(o, ECS_INVALID_PARAMETER,
958 "Constant was not found in Enum reflection data."
959 " Did you mean to use has<E>() instead of has(E)?");
960 return ecs_has_pair(world_, id_, r, o);
961 }
962
969 template <typename First, typename Second>
970 bool has() const {
971 return this->has<First>(_::type<Second>::id(world_));
972 }
973
980 template<typename First, typename Second, if_not_t< is_enum<Second>::value > = 0>
981 bool has(Second second) const {
982 auto comp_id = _::type<First>::id(world_);
983 return ecs_has_id(world_, id_, ecs_pair(comp_id, second));
984 }
985
992 template <typename Second>
993 bool has_second(flecs::entity_t first) const {
994 return this->has(first, _::type<Second>::id(world_));
995 }
996
1003 template<typename First, typename E, if_t< is_enum<E>::value && !std::is_same<First, E>::value > = 0>
1004 bool has(E value) const {
1005 const auto& et = enum_type<E>(this->world_);
1006 flecs::entity_t second = et.entity(value);
1007 return has<First>(second);
1008 }
1009
1016 bool has(flecs::id_t first, flecs::id_t second) const {
1017 return ecs_has_id(world_, id_, ecs_pair(first, second));
1018 }
1019
1026 bool owns(flecs::id_t e) const {
1027 return ecs_owns_id(world_, id_, e);
1028 }
1029
1036 template <typename First>
1037 bool owns(flecs::id_t second) const {
1038 auto comp_id = _::type<First>::id(world_);
1039 return owns(ecs_pair(comp_id, second));
1040 }
1041
1048 bool owns(flecs::id_t first, flecs::id_t second) const {
1049 return owns(ecs_pair(first, second));
1050 }
1051
1058 template <typename T>
1059 bool owns() const {
1060 return owns(_::type<T>::id(world_));
1061 }
1062
1070 template <typename First, typename Second>
1071 bool owns() const {
1072 return owns(
1073 _::type<First>::id(world_),
1074 _::type<Second>::id(world_));
1075 }
1076
1082 bool enabled(flecs::id_t id) const {
1083 return ecs_is_enabled_id(world_, id_, id);
1084 }
1085
1091 template<typename T>
1092 bool enabled() const {
1093 return this->enabled(_::type<T>::id(world_));
1094 }
1095
1102 bool enabled(flecs::id_t first, flecs::id_t second) const {
1103 return this->enabled(ecs_pair(first, second));
1104 }
1105
1112 template <typename First>
1113 bool enabled(flecs::id_t second) const {
1114 return this->enabled(_::type<First>::id(world_), second);
1115 }
1116
1123 template <typename First, typename Second>
1124 bool enabled() const {
1125 return this->enabled<First>(_::type<Second>::id(world_));
1126 }
1127
1128 flecs::entity clone(bool clone_value = true, flecs::entity_t dst_id = 0) const;
1129
1149 flecs::entity mut(const flecs::world& stage) const;
1150
1158 flecs::entity mut(const flecs::iter& it) const;
1159
1168 flecs::entity mut(const flecs::entity_view& e) const;
1169
1170# ifdef FLECS_JSON
1171# include "mixins/json/entity_view.inl"
1172# endif
1173# ifdef FLECS_DOC
1174# include "mixins/doc/entity_view.inl"
1175# endif
1176# ifdef FLECS_ALERTS
1177# include "mixins/alerts/entity_view.inl"
1178# endif
1179
1180# include "mixins/enum/entity_view.inl"
1181# include "mixins/event/entity_view.inl"
1182
1183private:
1184 flecs::entity set_stage(world_t *stage);
1185};
1186
1187}
1188
entity_view.inl
Alerts entity mixin.
entity_view.inl
Doc entity view mixin.
entity_view.inl
Enum entity view mixin.
entity_view.inl
Event entity mixin.
ecs_assert
#define ecs_assert(condition, error_code,...)
Assert.
Definition log.h:368
ecs_get_type_info
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.
flecs::component::constant
untyped_component & constant(const char *name, T value)
Add constant.
Definition untyped_component.inl:192
ecs_children_next
bool ecs_children_next(ecs_iter_t *it)
Progress an iterator created with ecs_children().
ecs_each_id
ecs_iter_t ecs_each_id(const ecs_world_t *world, ecs_id_t component)
Iterate all entities with specified (component id).
ecs_each_next
bool ecs_each_next(ecs_iter_t *it)
Progress an iterator created with ecs_each_id().
ecs_children
ecs_iter_t ecs_children(const ecs_world_t *world, ecs_entity_t parent)
Iterate children of parent.
ecs_is_enabled_id
bool ecs_is_enabled_id(const ecs_world_t *world, ecs_entity_t entity, ecs_id_t component)
Test if component is enabled.
ecs_owns_id
bool ecs_owns_id(const ecs_world_t *world, ecs_entity_t entity, ecs_id_t component)
Test if an entity owns a component.
ecs_get_depth
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.
ecs_has_id
bool ecs_has_id(const ecs_world_t *world, ecs_entity_t entity, ecs_id_t component)
Test if an entity has a component.
ecs_get_id
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.
ecs_get_mut_id
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.
ecs_is_valid
bool ecs_is_valid(const ecs_world_t *world, ecs_entity_t e)
Test whether an entity is valid.
ecs_is_alive
bool ecs_is_alive(const ecs_world_t *world, ecs_entity_t e)
Test whether an entity is alive.
ecs_get_path_w_sep
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.
ecs_get_symbol
const char * ecs_get_symbol(const ecs_world_t *world, ecs_entity_t entity)
Get the symbol of an entity.
ecs_get_name
const char * ecs_get_name(const ecs_world_t *world, ecs_entity_t entity)
Get the name of an entity.
ecs_get_world
const ecs_world_t * ecs_get_world(const ecs_poly_t *poly)
Get world from poly.
entity_view.inl
JSON entity mixin.
ecs_iter_t
Iterator.
Definition flecs.h:1147
flecs::_::each_delegate
Definition delegate.hpp:230
flecs::_::type
Definition flecs.hpp:39
flecs::component
Component class.
Definition component.hpp:382
flecs::entity_view
Entity view.
Definition entity_view.hpp:28
flecs::entity_view::type
flecs::type type() const
Get the entity's type.
Definition impl.hpp:94
flecs::entity_view::entity_view
entity_view(entity_t id)
Implicit conversion from flecs::entity_t to flecs::entity_view.
Definition entity_view.hpp:44
flecs::entity_view::depth
int32_t depth(flecs::entity_t rel) const
Get depth for given relationship.
Definition entity_view.hpp:887
flecs::entity_view::enabled
bool enabled() const
Test if pair is enabled.
Definition entity_view.hpp:1124
flecs::entity_view::try_get_second
const Second * try_get_second(flecs::entity_t first) const
Get the second part for a pair.
Definition entity_view.hpp:369
flecs::entity_view::has
bool has(flecs::id_t first, flecs::id_t second) const
Check if entity has the provided pair.
Definition entity_view.hpp:1016
flecs::entity_view::get_mut
First & get_mut(Second constant) const
Get a mutable pair.
Definition entity_view.hpp:767
flecs::entity_view::get_mut
T & get_mut() const
Get mutable component value.
Definition entity_view.hpp:707
flecs::entity_view::get_mut
A & get_mut() const
Get mutable component value.
Definition entity_view.hpp:724
flecs::entity_view::name
flecs::string_view name() const
Return the entity name.
Definition entity_view.hpp:84
flecs::entity_view::owns
bool owns(flecs::id_t second) const
Check if entity owns the provided pair.
Definition entity_view.hpp:1037
flecs::entity_view::try_get
const A * try_get() const
Get a pair.
Definition entity_view.hpp:307
flecs::entity_view::is_valid
bool is_valid() const
Check if entity is valid.
Definition entity_view.hpp:63
flecs::entity_view::path
flecs::string path(const char *sep="::", const char *init_sep="::") const
Return the entity path.
Definition entity_view.hpp:100
flecs::entity_view::try_get
const void * try_get(flecs::entity_t first, flecs::entity_t second) const
Get a pair (untyped).
Definition entity_view.hpp:357
flecs::entity_view::symbol
flecs::string_view symbol() const
Return the entity symbol.
Definition entity_view.hpp:92
flecs::entity_view::each
void each(const Func &func) const
Iterate targets for a given relationship.
Definition entity_view.hpp:195
flecs::entity_view::get_mut
A & get_mut() const
Get a mutable pair.
Definition entity_view.hpp:739
flecs::entity_view::range
flecs::table_range range() const
Get table range for the entity.
Definition impl.hpp:102
flecs::entity_view::get_mut
void * get_mut(flecs::entity_t first, flecs::entity_t second) const
Get a mutable pair (untyped).
Definition entity_view.hpp:794
flecs::entity_view::get_second
const Second & get_second(flecs::entity_t first) const
Get the second part for a pair.
Definition entity_view.hpp:547
flecs::entity_view::get_second
const Second & get_second() const
Get the second part for a pair.
Definition entity_view.hpp:562
flecs::entity_view::owns
bool owns() const
Check if entity owns the provided pair.
Definition entity_view.hpp:1071
flecs::entity_view::get
const T & get() const
Get component value.
Definition entity_view.hpp:403
flecs::entity_view::has
bool has(E value) const
Check if entity has the provided pair.
Definition entity_view.hpp:1004
flecs::entity_view::depth
int32_t depth() const
Get depth for given relationship.
Definition entity_view.hpp:897
flecs::entity_view::entity_view
entity_view(flecs::world_t *world, flecs::id_t id)
Wrap an existing entity id.
Definition entity_view.hpp:37
flecs::entity_view::enabled
bool enabled(flecs::id_t id) const
Test if id is enabled.
Definition entity_view.hpp:1082
flecs::entity_view::target_for
flecs::entity target_for(flecs::entity_t relationship, flecs::id_t id) const
Get the target of a pair for a given relationship id.
Definition impl.hpp:50
flecs::entity_view::has_second
bool has_second(flecs::entity_t first) const
Check if entity has the provided pair.
Definition entity_view.hpp:993
flecs::entity_view::try_get
const First * try_get(Second constant) const
Get a pair.
Definition entity_view.hpp:333
flecs::entity_view::try_get_mut_second
Second * try_get_mut_second(flecs::entity_t first) const
Get the second part for a pair.
Definition entity_view.hpp:673
flecs::entity_view::lookup
flecs::entity lookup(const char *path, bool search_path=false) const
Lookup an entity by name.
Definition impl.hpp:172
flecs::entity_view::get
const First & get(Second second) const
Get a pair.
Definition entity_view.hpp:450
flecs::entity_view::children
void children(Func &&func) const
Iterate children for entity.
Definition entity_view.hpp:245
flecs::entity_view::try_get
const void * try_get(flecs::id_t comp) const
Get component value (untyped).
Definition entity_view.hpp:345
flecs::entity_view::owns
bool owns(flecs::id_t e) const
Check if entity owns the provided entity.
Definition entity_view.hpp:1026
flecs::entity_view::get_mut_second
Second & get_mut_second(flecs::entity_t first) const
Get the second part for a pair.
Definition entity_view.hpp:809
flecs::entity_view::get
const First & get(Second constant) const
Get a pair.
Definition entity_view.hpp:466
flecs::entity_view::table
flecs::table table() const
Get the entity's table.
Definition impl.hpp:98
flecs::entity_view::path_from
flecs::string path_from(flecs::entity_t parent, const char *sep="::", const char *init_sep="::") const
Return the entity path relative to a parent.
Definition entity_view.hpp:108
flecs::entity_view::get_mut_second
Second * get_mut_second() const
Get the second part for a pair.
Definition entity_view.hpp:824
flecs::entity_view::enabled
bool enabled(flecs::id_t second) const
Test if pair is enabled.
Definition entity_view.hpp:1113
flecs::entity_view::has
bool has(Second second) const
Check if entity has the provided pair.
Definition entity_view.hpp:981
flecs::entity_view::try_get_mut
A * try_get_mut() const
Get mutable component value.
Definition entity_view.hpp:596
flecs::entity_view::has
bool has(flecs::id_t e) const
Check if entity has the provided entity.
Definition entity_view.hpp:923
flecs::entity_view::owns
bool owns() const
Check if entity owns the provided component.
Definition entity_view.hpp:1059
flecs::entity_view::parent
flecs::entity parent() const
Get parent of entity.
Definition impl.hpp:68
flecs::entity_view::try_get
const First * try_get(Second second) const
Get a pair.
Definition entity_view.hpp:318
flecs::entity_view::get_mut
void * get_mut(flecs::id_t comp) const
Get mutable component value (untyped).
Definition entity_view.hpp:779
flecs::entity_view::try_get_mut
A * try_get_mut() const
Get a mutable pair.
Definition entity_view.hpp:611
flecs::entity_view::each
void each(const Func &func) const
Iterate (component) ids of an entity.
Definition impl.hpp:112
flecs::entity_view::get
const void * get(flecs::entity_t first, flecs::entity_t second) const
Get a pair (untyped).
Definition entity_view.hpp:495
flecs::entity_view::is_alive
bool is_alive() const
Check if entity is alive.
Definition entity_view.hpp:76
flecs::entity_view::get
const A & get() const
Get a pair.
Definition entity_view.hpp:437
flecs::entity_view::has
bool has() const
Check if entity has the provided component.
Definition entity_view.hpp:933
flecs::entity_view::try_get_mut
T * try_get_mut() const
Get mutable component value.
Definition entity_view.hpp:579
flecs::entity_view::owns
bool owns(flecs::id_t first, flecs::id_t second) const
Check if entity owns the provided pair.
Definition entity_view.hpp:1048
flecs::entity_view::try_get_mut
void * try_get_mut(flecs::id_t comp) const
Get mutable component value (untyped).
Definition entity_view.hpp:649
flecs::entity_view::children
void children(Func &&func) const
Iterate children for entity.
Definition entity_view.hpp:261
flecs::entity_view::get
const A & get() const
Get component value.
Definition entity_view.hpp:420
flecs::entity_view::get_constant
Enum get_constant() const
Get enum constant for enum relationship.
Definition impl.hpp:30
flecs::entity_view::get_mut
First & get_mut(Second second) const
Get a mutable pair.
Definition entity_view.hpp:753
flecs::entity_view::try_get_mut_second
Second * try_get_mut_second() const
Get the second part for a pair.
Definition entity_view.hpp:693
flecs::entity_view::try_get_mut
void * try_get_mut(flecs::entity_t first, flecs::entity_t second) const
Get a mutable pair (untyped).
Definition entity_view.hpp:661
flecs::entity_view::try_get_mut
First * try_get_mut(Second second) const
Get a mutable pair.
Definition entity_view.hpp:622
flecs::entity_view::id
entity_t id() const
Get entity id.
Definition entity_view.hpp:50
flecs::entity_view::target
flecs::entity target(int32_t index=0) const
Get target for a given pair.
Definition impl.hpp:36
flecs::entity_view::try_get
const T * try_get() const
Get component value.
Definition entity_view.hpp:275
flecs::entity_view::get
const void * get(flecs::id_t comp) const
Get component value (untyped).
Definition entity_view.hpp:478
flecs::entity_view::has
bool has() const
Check if entity has the provided pair.
Definition entity_view.hpp:970
flecs::entity_view::path_from
flecs::string path_from(const char *sep="::", const char *init_sep="::") const
Return the entity path relative to a parent.
Definition entity_view.hpp:118
flecs::entity_view::try_get_mut
First * try_get_mut(Second constant) const
Get a mutable pair.
Definition entity_view.hpp:637
flecs::entity_view::enabled
bool enabled() const
Test if component is enabled.
Definition entity_view.hpp:1092
flecs::entity_view::try_get_second
const Second * try_get_second() const
Get the second part for a pair.
Definition entity_view.hpp:389
flecs::entity_view::children
void children(flecs::entity_t rel, Func &&func) const
Iterate children for entity.
Definition entity_view.hpp:210
flecs::entity_view::mut
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...
Definition impl.hpp:72
flecs::entity_view::has
bool has(E value) const
Check if entity has the provided enum constant.
Definition entity_view.hpp:954
flecs::entity_view::enabled
bool enabled(flecs::id_t first, flecs::id_t second) const
Test if pair is enabled.
Definition entity_view.hpp:1102
flecs::entity_view::try_get
const A * try_get() const
Get component value.
Definition entity_view.hpp:292
flecs::entity
Entity.
Definition entity.hpp:30
flecs::id::second
flecs::entity second() const
Get second element from a pair.
Definition impl.hpp:31
flecs::id::first
flecs::entity first() const
Get first element from a pair.
Definition impl.hpp:20
flecs::iter
Class for iterating over query results.
Definition iter.hpp:68
flecs::string_view
Definition string.hpp:146
flecs::string
Definition string.hpp:13
flecs::table_range
Definition table.hpp:412
flecs::table
Definition table.hpp:18
flecs::type
Type class.
Definition type.hpp:21
flecs::world
The world.
Definition world.hpp:150