48 : flecs::
id( nullptr,
id ) { }
71 explicit operator bool()
const {
129 template <
typename Parent>
172 template <
typename Func>
173 void each(
const Func& func)
const;
186 template <
typename Func>
199 template <
typename Func>
212 template <
typename First,
typename Func>
213 void each(
const Func& func)
const {
227 template <
typename Func>
232 if (
id_ == flecs::Wildcard ||
id_ == flecs::Any) {
255 template <
typename Rel,
typename Func>
271 template <
typename Func>
273 children(flecs::ChildOf, FLECS_MOV(func));
277 template <
typename... T,
typename... Args>
278 decltype(
auto) try_get(Args... args)
const {
279 return _::get_component<false, false>(
world_,
id_,
280 _::make_id<T...>(
world_, args...));
283 template <
typename... T,
typename... Args>
284 decltype(
auto) try_get_second(Args... args)
const {
285 return _::get_component<false, false>(
world_,
id_,
286 _::second_id<T...>(
world_, args...));
289 template <
typename... T>
290 auto try_get_n()
const {
291 static_assert(
sizeof...(T) > 1 &&
sizeof...(T) < 9,
292 "component tuple requires between two and eight components");
293 return typename tuple_builder<
sizeof...(T), T...>::type_const_ptr {try_get<T>()...};
296 template <typename Func, if_t<is_callable<Func>::value> = 0>
297 bool get(
const Func& func)
const;
299 template <
typename... T,
typename... Args>
300 decltype(
auto) get(Args... args)
const {
301 return _::get_component<false, true>(world_, id_,
302 _::make_id<T...>(world_, args...));
305 template <
typename... T,
typename... Args>
306 decltype(
auto) get_second(Args... args)
const {
307 return _::get_component<false, true>(world_, id_,
308 _::second_id<T...>(world_, args...));
311 template <
typename... T>
313 static_assert(
sizeof...(T) > 1 &&
sizeof...(T) < 9,
314 "component tuple requires between two and eight components");
315 return typename tuple_builder<
sizeof...(T), T...>::type_const {get<T>()...};
318 template <
typename... T,
typename... Args>
319 decltype(
auto) try_get_mut(Args... args)
const {
320 return _::get_component<true, false>(world_, id_,
321 _::make_id<T...>(world_, args...));
324 template <
typename... T,
typename... Args>
325 decltype(
auto) try_get_mut_second(Args... args)
const {
326 return _::get_component<true, false>(world_, id_,
327 _::second_id<T...>(world_, args...));
330 template <
typename... T>
331 auto try_get_mut_n()
const {
332 static_assert(
sizeof...(T) > 1 &&
sizeof...(T) < 9,
333 "component tuple requires between two and eight components");
334 return typename tuple_builder<
sizeof...(T), T...>::type_ptr {try_get_mut<T>()...};
337 template <
typename... T,
typename... Args>
338 decltype(
auto) get_mut(Args... args)
const {
339 return _::get_component<true, true>(world_, id_,
340 _::make_id<T...>(world_, args...));
343 template <
typename... T,
typename... Args>
344 decltype(
auto) get_mut_second(Args... args)
const {
345 return _::get_component<true, true>(world_, id_,
346 _::second_id<T...>(world_, args...));
349 template <
typename... T>
350 auto get_mut_n()
const {
351 static_assert(
sizeof...(T) > 1 &&
sizeof...(T) < 9,
352 "component tuple requires between two and eight components");
353 return typename tuple_builder<
sizeof...(T), T...>::type {get_mut<T>()...};
361 template<
typename Enum>
362 Enum get_constant()
const;
373 template<
typename First>
414 template <
typename T>
424 template <
typename First,
typename Second>
441 template<
typename Rel>
461 flecs::entity lookup(
const char *path,
bool search_path =
false)
const;
463 template <
typename... T,
typename... Args>
464 bool has(Args... args)
const {
465 return _::has_component(world_, id_, _::make_id<T...>(world_, args...));
468 template <
typename Second>
470 return has(first, _::type<Second>::id(world_));
473 template <
typename... T,
typename... Args>
474 bool owns(Args... args)
const {
475 return ecs_owns_id(world_, id_, _::make_id<T...>(world_, args...).
id);
478 template <
typename Second>
480 return owns(first, _::type<Second>::id(world_));
483 template <
typename... T,
typename... Args>
484 bool enabled(Args... args)
const {
Utilities to fetch components as tuples from entities.
ecs_entity_t entity_t
Entity type.
ecs_world_t world_t
World type.
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.
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.
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.
flecs::string_view name() const
Return the entity name.
bool is_valid() const
Check if entity is valid.
flecs::string path(const char *sep="::", const char *init_sep="::") const
Return the entity path.
flecs::string_view symbol() const
Return the entity symbol.
void each(const Func &func) const
Iterate targets for a given relationship.
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.
void children(Func &&func) const
Iterate children for an entity.
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() const
Check if entity is enabled (does not have the Disabled tag).
flecs::entity parent() const
Get parent of entity.
entity_view()
Default constructor.
void each(const Func &func) const
Iterate (component) IDs of an entity.
bool is_alive() const
Check if entity is alive.
void children(Func &&func) const
Iterate children for an entity.
entity_t id() const
Get entity ID.
flecs::string path_from(const char *sep="::", const char *init_sep="::") const
Return the entity path relative to a typed parent.
void children(flecs::entity_t rel, Func &&func) const
Iterate children for an entity.
flecs::world world() const
Get the world.
flecs::id_t id_
The raw ID value.
flecs::entity second() const
Get second element from a pair.
flecs::world_t * world_
World is optional, but guarantees that entity identifiers extracted from the ID are valid.
flecs::entity first() const
Get first element from a pair.
Class for iterating over query results.
table()
Default constructor.
Builds tuple types for a given number of component types.
type()
Default constructor.
void each(Func &&func) const
Iterate over all entities with components in the argument list of the function.