Flecs v3.2
A fast entity component system (ECS) for C & C++
Loading...
Searching...
No Matches
flecs::iterable< Components > Struct Template Referenceabstract

Public Member Functions

template<typename Func >
void each (Func &&func) const
 Each iterator.
 
template<typename Func >
void each (flecs::world_t *world, Func &&func) const
 
template<typename Func >
void each (flecs::iter &it, Func &&func) const
 
template<typename Func >
void each (flecs::entity e, Func &&func) const
 
template<typename Func >
flecs::entity find (Func &&func) const
 
template<typename Func >
void iter (Func &&func) const
 Iter iterator.
 
template<typename Func >
void iter (flecs::world_t *world, Func &&func) const
 
template<typename Func >
void iter (flecs::iter &it, Func &&func) const
 
template<typename Func >
void iter (flecs::entity e, Func &&func) const
 
iter_iterable< Components... > iter (flecs::world_t *world=nullptr) const
 Create iterator.
 
page_iterable< Components... > page (int32_t offset, int32_t limit)
 Page iterator.
 
worker_iterable< Components... > worker (int32_t index, int32_t count)
 Worker iterator.
 
int32_t count () const
 Return number of entities matched by iterable.
 
bool is_true () const
 Return whether iterable has any matches.
 
flecs::entity first () const
 Return first entity matched by iterable.
 

Protected Member Functions

virtual ecs_iter_t get_iter (flecs::world_t *stage) const =0
 
virtual ecs_iter_next_action_t next_action () const =0
 
virtual ecs_iter_next_action_t next_each_action () const =0
 
template<template< typename Func, typename ... Comps > class Delegate, typename Func , typename NextFunc , typename ... Args>
void iterate (flecs::world_t *stage, Func &&func, NextFunc next, Args &&... args) const
 
template<template< typename Func, typename ... Comps > class Delegate, typename Func , typename NextFunc , typename ... Args>
flecs::entity iterate_find (flecs::world_t *stage, Func &&func, NextFunc next, Args &&... args) const
 

Protected Attributes

friend iter_iterable< Components... >
 
friend page_iterable< Components... >
 
friend worker_iterable< Components... >
 

Detailed Description

template<typename ... Components>
struct flecs::iterable< Components >

Definition at line 18 of file iterable.hpp.

Constructor & Destructor Documentation

◆ ~iterable()

template<typename ... Components>
virtual flecs::iterable< Components >::~iterable ( )
inlinevirtual

Definition at line 132 of file iterable.hpp.

Member Function Documentation

◆ count()

template<typename ... Components>
int32_t flecs::iterable< Components >::count ( ) const
inline

Return number of entities matched by iterable.

Definition at line 118 of file iterable.hpp.

◆ each() [1/4]

template<typename ... Components>
template<typename Func >
void flecs::iterable< Components >::each ( flecs::entity e,
Func && func ) const
inline

Definition at line 47 of file iterable.hpp.

◆ each() [2/4]

template<typename ... Components>
template<typename Func >
void flecs::iterable< Components >::each ( flecs::iter & it,
Func && func ) const
inline

Definition at line 41 of file iterable.hpp.

◆ each() [3/4]

template<typename ... Components>
template<typename Func >
void flecs::iterable< Components >::each ( flecs::world_t * world,
Func && func ) const
inline

Definition at line 35 of file iterable.hpp.

◆ each() [4/4]

template<typename ... Components>
template<typename Func >
void flecs::iterable< Components >::each ( Func && func) const
inline

Each iterator.

The "each" iterator accepts a function that is invoked for each matching entity. The following function signatures are valid:

  • func(flecs::entity e, Components& ...)
  • func(flecs::iter& it, size_t index, Components& ....)
  • func(Components& ...)

Each iterators are automatically instanced.

Definition at line 30 of file iterable.hpp.

◆ find()

template<typename ... Components>
template<typename Func >
flecs::entity flecs::iterable< Components >::find ( Func && func) const
inline

Definition at line 53 of file iterable.hpp.

◆ first()

template<typename ... Components>
flecs::entity flecs::iterable< Components >::first ( ) const
inline

Return first entity matched by iterable.

Definition at line 128 of file iterable.hpp.

◆ is_true()

template<typename ... Components>
bool flecs::iterable< Components >::is_true ( ) const
inline

Return whether iterable has any matches.

Definition at line 123 of file iterable.hpp.

◆ iter() [1/5]

template<typename ... Components>
template<typename Func >
void flecs::iterable< Components >::iter ( flecs::entity e,
Func && func ) const
inline

Definition at line 88 of file iterable.hpp.

◆ iter() [2/5]

template<typename ... Components>
template<typename Func >
void flecs::iterable< Components >::iter ( flecs::iter & it,
Func && func ) const
inline

Definition at line 82 of file iterable.hpp.

◆ iter() [3/5]

template<typename ... Components>
template<typename Func >
void flecs::iterable< Components >::iter ( flecs::world_t * world,
Func && func ) const
inline

Definition at line 76 of file iterable.hpp.

◆ iter() [4/5]

template<typename ... Components>
iter_iterable< Components... > flecs::iterable< Components >::iter ( flecs::world_t * world = nullptr) const

Create iterator.

Create an iterator object that can be modified before iterating.

Definition at line 261 of file iterable.hpp.

◆ iter() [5/5]

template<typename ... Components>
template<typename Func >
void flecs::iterable< Components >::iter ( Func && func) const
inline

Iter iterator.

The "iter" iterator accepts a function that is invoked for each matching table. The following function signatures are valid:

  • func(flecs::iter& it, Components* ...)
  • func(Components& ...)

Iter iterators are not automatically instanced. When a result contains shared components, entities of the result will be iterated one by one. This ensures that applications can't accidentally read out of bounds by accessing a shared component as an array.

Definition at line 70 of file iterable.hpp.

◆ iterate()

template<typename ... Components>
template<template< typename Func, typename ... Comps > class Delegate, typename Func , typename NextFunc , typename ... Args>
void flecs::iterable< Components >::iterate ( flecs::world_t * stage,
Func && func,
NextFunc next,
Args &&... args ) const
inlineprotected

Definition at line 143 of file iterable.hpp.

◆ iterate_find()

template<typename ... Components>
template<template< typename Func, typename ... Comps > class Delegate, typename Func , typename NextFunc , typename ... Args>
flecs::entity flecs::iterable< Components >::iterate_find ( flecs::world_t * stage,
Func && func,
NextFunc next,
Args &&... args ) const
inlineprotected

Definition at line 155 of file iterable.hpp.

◆ page()

template<typename ... Components>
page_iterable< Components... > flecs::iterable< Components >::page ( int32_t offset,
int32_t limit )

Page iterator.

Create an iterator that limits the returned entities with offset/limit.

Parameters
offsetHow many entities to skip.
limitThe maximum number of entities to return.
Returns
Iterable that can be iterated with each/iter.

Definition at line 296 of file iterable.hpp.

◆ worker()

template<typename ... Components>
worker_iterable< Components... > flecs::iterable< Components >::worker ( int32_t index,
int32_t count )

Worker iterator.

Create an iterator that divides the number of matched entities across a number of resources.

Parameters
indexThe index of the current resource.
countThe total number of resources to divide entities between.
Returns
Iterable that can be iterated with each/iter.

Definition at line 332 of file iterable.hpp.

Member Data Documentation

◆ iter_iterable< Components... >

template<typename ... Components>
friend flecs::iterable< Components >::iter_iterable< Components... >
protected

Definition at line 134 of file iterable.hpp.

◆ page_iterable< Components... >

template<typename ... Components>
friend flecs::iterable< Components >::page_iterable< Components... >
protected

Definition at line 135 of file iterable.hpp.

◆ worker_iterable< Components... >

template<typename ... Components>
friend flecs::iterable< Components >::worker_iterable< Components... >
protected

Definition at line 136 of file iterable.hpp.


The documentation for this struct was generated from the following file: