Flecs v4.0
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 : world_(world)
21 {
22 desc_.entity = entity;
23 }
24
26
27 metric_builder& member(flecs::entity_t e) {
28 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 desc_.id = the_id;
44 return *this;
45 }
46
47 metric_builder& id(flecs::entity_t first, flecs::entity_t second) {
48 desc_.id = ecs_pair(first, second);
49 return *this;
50 }
51
52 template <typename T>
54 return id(_::type<T>::id(world_));
55 }
56
57 template <typename First>
58 metric_builder& id(flecs::entity_t second) {
59 return id(_::type<First>::id(world_), second);
60 }
61
62 template <typename Second>
63 metric_builder& id_second(flecs::entity_t first) {
64 return id(first, _::type<Second>::id(world_));
65 }
66
67 template <typename First, typename Second>
69 return id<First>(_::type<Second>::id(world_));
70 }
71
72 metric_builder& targets(bool value = true) {
73 desc_.targets = value;
74 return *this;
75 }
76
77 metric_builder& kind(flecs::entity_t the_kind) {
78 desc_.kind = the_kind;
79 return *this;
80 }
81
82 template <typename Kind>
83 metric_builder& kind() {
84 return kind(_::type<Kind>::id(world_));
85 }
86
87 metric_builder& brief(const char *b) {
88 desc_.brief = b;
89 return *this;
90 }
91
92 operator flecs::entity();
93
94protected:
95 flecs::world_t *world_;
96 ecs_metric_desc_t desc_ = {};
97 bool created_ = false;
98};
99
104}
Used with ecs_metric_init to create metric.
Definition metrics.h:76
const char * brief
Description of metric.
Definition metrics.h:105
ecs_entity_t member
Entity associated with member that stores metric value.
Definition metrics.h:84
ecs_entity_t kind
Must be EcsGauge, EcsCounter, EcsCounterIncrement or EcsCounterId.
Definition metrics.h:102
ecs_entity_t entity
Entity associated with metric.
Definition metrics.h:80
bool targets
If id is a (R, *) wildcard and relationship R has the OneOf property, setting this value to true will...
Definition metrics.h:99
ecs_id_t id
Tracks whether entities have the specified component id.
Definition metrics.h:93
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:137