Flecs v3.2
A fast entity component system (ECS) for C & C++
Loading...
Searching...
No Matches
builder.hpp
Go to the documentation of this file.
1
6#pragma once
7
8#include "../../utils/builder.hpp"
9#include "builder_i.hpp"
10
11namespace flecs {
12namespace _ {
13 template <typename ... Components>
14 using filter_builder_base = builder<
15 filter, ecs_filter_desc_t, filter_builder<Components...>,
16 filter_builder_i, Components ...>;
17}
18
23template <typename ... Components>
24struct filter_builder final : _::filter_builder_base<Components...> {
25 filter_builder(flecs::world_t* world, const char *name = nullptr)
26 : _::filter_builder_base<Components...>(world)
27 {
28 _::sig<Components...>(world).populate(this);
29 if (name != nullptr) {
30 ecs_entity_desc_t entity_desc = {};
31 entity_desc.name = name;
32 entity_desc.sep = "::";
33 entity_desc.root_sep = "::";
34 this->m_desc.entity = ecs_entity_init(world, &entity_desc);
35 }
36 }
37
38 template <typename Func>
39 void each(Func&& func) {
40 this->build().each(FLECS_FWD(func));
41 }
42};
43
44}
flecs::filter_builder< Comps... > filter_builder(Args &&... args) const
Create a filter builder.
ecs_entity_t ecs_entity_init(ecs_world_t *world, const ecs_entity_desc_t *desc)
Find or create an entity.
Used with ecs_entity_init.
Definition: flecs.h:876
const char * sep
Optional custom separator for hierarchical names.
Definition: flecs.h:886
const char * root_sep
Optional, used for identifiers relative to root.
Definition: flecs.h:890
const char * name
Name of the entity.
Definition: flecs.h:881
Used with ecs_filter_init.
Definition: flecs.h:961
Filter builder.
Definition: builder.hpp:24
The world.
Definition: world.hpp:132
Term builder interface.