Flecs: include/flecs/addons/cpp/mixins/metrics/builder.hpp Source File
Description: A fast entity component system (ECS) for C & C++

| 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
5
6#pragma once
7
8#define ECS_EVENT_DESC_ID_COUNT_MAX (8)
9
10namespace flecs {
11
16
18 struct metric_builder {
19 metric_builder(flecs::world_t *world, flecs::entity_t entity)
20 : world_(world)
21 {
22 desc_.entity = entity;
23 }
24
25 ~metric_builder();
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>
53 metric_builder& id() {
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>
68 metric_builder& id() {
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
103
104}
ecs_metric_desc_t
Used with ecs_metric_init to create metric.
Definition metrics.h:76
flecs::_::type
Definition flecs.hpp:39
flecs::entity
Entity.
Definition entity.hpp:30
flecs::world
The world.
Definition world.hpp:172