Flecs v4.1
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
8namespace flecs {
9
23
26
29 desc_.member = e;
30 return *this;
31 }
32
34 metric_builder& member(const char *name);
35
37 template <typename T>
38 metric_builder& member(const char *name);
39
41 metric_builder& dotmember(const char *name);
42
44 template <typename T>
45 metric_builder& dotmember(const char *name);
46
49 desc_.id = the_id;
50 return *this;
51 }
52
55 desc_.id = ecs_pair(first, second);
56 return *this;
57 }
58
60 template <typename T>
62 return id(_::type<T>::id(world_));
63 }
64
66 template <typename First>
68 return id(_::type<First>::id(world_), second);
69 }
70
72 template <typename Second>
74 return id(first, _::type<Second>::id(world_));
75 }
76
78 template <typename First, typename Second>
80 return id<First>(_::type<Second>::id(world_));
81 }
82
84 metric_builder& targets(bool value = true) {
85 desc_.targets = value;
86 return *this;
87 }
88
91 desc_.kind = the_kind;
92 return *this;
93 }
94
96 template <typename Kind>
98 return kind(_::type<Kind>::id(world_));
99 }
100
102 metric_builder& brief(const char *b) {
103 desc_.brief = b;
104 return *this;
105 }
106
108 operator flecs::entity();
109
110protected:
111 flecs::world_t *world_;
112 ecs_metric_desc_t desc_ = {};
113 bool created_ = false;
114};
115
120}
ecs_id_t id_t
ID type.
Definition c_types.hpp:20
ecs_entity_t entity_t
Entity type.
Definition c_types.hpp:21
ecs_world_t world_t
World type.
Definition c_types.hpp:18
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
Metric builder interface.
Definition builder.hpp:16
operator flecs::entity()
Finalize the metric and return the entity.
Definition impl.hpp:71
metric_builder & id(flecs::entity_t first, flecs::entity_t second)
Set the ID for the metric as a pair.
Definition builder.hpp:54
metric_builder & kind()
Set the metric kind by type.
Definition builder.hpp:97
metric_builder & id(flecs::entity_t second)
Set the ID for the metric as a pair with type First.
Definition builder.hpp:67
~metric_builder()
Destructor.
Definition impl.hpp:27
metric_builder & brief(const char *b)
Set a brief description for the metric.
Definition builder.hpp:102
metric_builder & id(flecs::id_t the_id)
Set the ID for the metric.
Definition builder.hpp:48
metric_builder(flecs::world_t *world, flecs::entity_t entity)
Construct a metric builder.
Definition builder.hpp:18
metric_builder & id_second(flecs::entity_t first)
Set the ID for the metric as a pair with type Second.
Definition builder.hpp:73
metric_builder & id()
Set the ID for the metric by type.
Definition builder.hpp:61
metric_builder & targets(bool value=true)
Set whether to create metrics for targets.
Definition builder.hpp:84
metric_builder & dotmember(const char *name)
Set the member to use for the metric using dot notation.
Definition impl.hpp:59
metric_builder & id()
Set the ID for the metric as a pair with types First and Second.
Definition builder.hpp:79
metric_builder & member(flecs::entity_t e)
Set the member to use for the metric by entity ID.
Definition builder.hpp:28
metric_builder & kind(flecs::entity_t the_kind)
Set the metric kind (e.g., Counter, Gauge).
Definition builder.hpp:90
The world.
Definition world.hpp:246