17 , m_filter_ptr(
nullptr) { }
26 , m_filter_ptr(&m_filter) {
43 m_filter_ptr = &m_filter;
47 this->m_world = obj.m_world;
48 if (obj.m_filter_ptr) {
49 this->m_filter_ptr = &this->m_filter;
51 this->m_filter_ptr =
nullptr;
57 this->m_world = obj.m_world;
58 if (obj.m_filter_ptr) {
59 this->m_filter_ptr = &this->m_filter;
61 this->m_filter_ptr =
nullptr;
68 this->m_world = obj.m_world;
69 if (obj.m_filter_ptr) {
70 this->m_filter_ptr = &this->m_filter;
72 this->m_filter_ptr =
nullptr;
78 this->m_world = obj.m_world;
79 if (obj.m_filter_ptr) {
80 this->m_filter_ptr = &this->m_filter;
82 this->m_filter_ptr =
nullptr;
99 if ((&m_filter == m_filter_ptr) && m_filter_ptr) {
104 template <
typename Func>
105 void each_term(
const Func& func) {
106 for (
int i = 0; i < m_filter_ptr->
term_count; i ++) {
117 int32_t field_count() {
126 operator filter<>()
const;
129 world_t *m_world =
nullptr;
131 const filter_t *m_filter_ptr;
134template<
typename ... Components>
137 using Terms =
typename _::term_ptrs<Components...>::array;
140 using filter_base::filter_base;
147 filter_base::operator=(obj);
154 filter_base::operator=(FLECS_FWD(obj));
159 ecs_iter_t get_iter(flecs::world_t *
world)
const override {
176template <
typename... Comps,
typename... Args>
182template <
typename... Comps,
typename... Args>
191template<
typename Func,
typename ... Args>
194template<
typename Func,
typename E,
typename ... Args>
199 f.each(FLECS_MOV(func));
204template<
typename Func,
typename ... Args>
207template<
typename Func,
typename ... Args>
212 f.each(FLECS_MOV(func));
217template<
typename Func,
typename T =
int>
220template <
typename Func>
227template <
typename Func>
236template <
typename Func>
237inline void world::each(Func&& func)
const {
241template <
typename T,
typename Func>
242inline void world::each(Func&& func)
const {
244 t.
id = _::cpp_type<T>::id();
248 _::each_delegate<Func, T>(func).invoke(&it);
252template <
typename Func>
253inline void world::each(flecs::id_t term_id, Func&& func)
const {
259 _::each_delegate<Func>(func).invoke(&it);
267 f.m_filter_ptr = &f.m_filter;
268 f.m_world = this->m_world;
#define ecs_abort(error_code,...)
Abort.
flecs::filter< Comps... > filter(Args &&... args) const
Create a filter.
ecs_filter_t * ecs_filter_init(ecs_world_t *world, const ecs_filter_desc_t *desc)
Initialize filter A filter is a lightweight object that can be used to query for entities in a world.
bool ecs_filter_next(ecs_iter_t *it)
Iterate tables matched by filter.
ecs_iter_t ecs_filter_iter(const ecs_world_t *world, const ecs_filter_t *filter)
Return a filter iterator.
char * ecs_filter_str(const ecs_world_t *world, const ecs_filter_t *filter)
Convert filter to string expression.
void ecs_filter_fini(ecs_filter_t *filter)
Deinitialize filter.
bool ecs_filter_next_instanced(ecs_iter_t *it)
Same as ecs_filter_next, but always instanced.
bool ecs_term_next(ecs_iter_t *it)
Progress a term iterator.
void ecs_filter_move(ecs_filter_t *dst, ecs_filter_t *src)
Move resources of one filter to another.
void ecs_filter_copy(ecs_filter_t *dst, const ecs_filter_t *src)
Copy resources of one filter to another.
ecs_iter_t ecs_term_iter(const ecs_world_t *world, ecs_term_t *term)
Iterator for a single (component) id.
bool(* ecs_iter_next_action_t)(ecs_iter_t *it)
Function prototype for iterating an iterator.
ecs_filter_t ECS_FILTER_INIT
Use $this variable to initialize user-allocated filter object.
ecs_entity_t ecs_get_entity(const ecs_poly_t *poly)
Get entity from poly.
Used with ecs_filter_init.
ecs_term_t * terms_buffer
For filters with lots of terms an outside array can be provided.
ecs_filter_t * storage
External storage to prevent allocation of the filter object.
Filters alllow for ad-hoc quick filtering of entity tables.
ecs_term_t * terms
Array containing terms for filter.
int32_t term_count
Number of elements in terms array.
Type that describes a term (single element in a query)
ecs_id_t id
Component id to be matched by term.
~filter_base()
Free the filter.
Class that describes a term.