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#define ECS_EVENT_DESC_ID_COUNT_MAX (8)
9
10namespace flecs {
11
19 metric_builder(flecs::world_t *world, flecs::entity_t entity)
20 : m_world(world)
21 {
22 m_desc.entity = entity;
23 }
24
26
27 metric_builder& member(flecs::entity_t e) {
28 m_desc.member = e;
29 return *this;
30 }
31
32 metric_builder& member(const char *name);
33
34 template <typename T>
35 metric_builder& member(const char *name);
36
37 metric_builder& dotmember(const char *name);
38
39 template <typename T>
40 metric_builder& dotmember(const char *name);
41
42 metric_builder& id(flecs::id_t the_id) {
43 m_desc.id = the_id;
44 return *this;
45 }
46
47 metric_builder& id(flecs::entity_t first, flecs::entity_t second) {
48 m_desc.id = ecs_pair(first, second);
49 return *this;
50 }
51
52 template <typename T>
54 return id(_::cpp_type<T>::id(m_world));
55 }
56
57 template <typename First>
58 metric_builder& id(flecs::entity_t second) {
59 return id(_::cpp_type<First>::id(m_world), second);
60 }
61
62 template <typename Second>
63 metric_builder& id_second(flecs::entity_t first) {
64 return id(first, _::cpp_type<Second>::id(m_world));
65 }
66
67 template <typename First, typename Second>
69 return id<First>(_::cpp_type<Second>::id(m_world));
70 }
71
72 metric_builder& targets(bool value = true) {
73 m_desc.targets = value;
74 return *this;
75 }
76
77 metric_builder& kind(flecs::entity_t the_kind) {
78 m_desc.kind = the_kind;
79 return *this;
80 }
81
82 template <typename Kind>
83 metric_builder& kind() {
84 return kind(_::cpp_type<Kind>::id(m_world));
85 }
86
87 metric_builder& brief(const char *b) {
88 m_desc.brief = b;
89 return *this;
90 }
91
92 operator flecs::entity();
93
94protected:
95 flecs::world_t *m_world;
96 ecs_metric_desc_t m_desc = {};
97 bool m_created = false;
98};
99
104}
const char * brief
Description of metric.
Definition metrics.h:101
ecs_entity_t member
Entity associated with member that stores metric value.
Definition metrics.h:80
ecs_entity_t kind
Must be EcsGauge, EcsCounter, EcsCounterIncrement or EcsCounterId.
Definition metrics.h:98
ecs_entity_t entity
Entity associated with metric.
Definition metrics.h:76
bool targets
If id is a (R, *) wildcard and relationship R has the OneOf property, setting this value to true will...
Definition metrics.h:95
ecs_id_t id
Tracks whether entities have the specified component id.
Definition metrics.h:89
Entity.
Definition entity.hpp:30
Class that wraps around a flecs::id_t.
Definition decl.hpp:27
Event builder interface.
Definition builder.hpp:18
The world.
Definition world.hpp:132