Flecs v3.2
A fast entity component system (ECS) for C & C++
Loading...
Searching...
No Matches
metrics.h
Go to the documentation of this file.
1
9#ifdef FLECS_METRICS
10
20#ifndef FLECS_METRICS_H
21#define FLECS_METRICS_H
22
23#ifndef FLECS_META
24#define FLECS_META
25#endif
26
27#ifndef FLECS_UNITS
28#define FLECS_UNITS
29#endif
30
31#ifndef FLECS_PIPELINE
32#define FLECS_PIPELINE
33#endif
34
35#ifdef __cplusplus
36extern "C" {
37#endif
38
39FLECS_API extern ECS_COMPONENT_DECLARE(FlecsMetrics);
40
42FLECS_API extern ECS_TAG_DECLARE(EcsMetric);
43
45FLECS_API extern ECS_TAG_DECLARE(EcsCounter);
46
48FLECS_API extern ECS_TAG_DECLARE(EcsCounterIncrement);
49
51FLECS_API extern ECS_TAG_DECLARE(EcsCounterId);
52
54FLECS_API extern ECS_TAG_DECLARE(EcsGauge);
55
57FLECS_API extern ECS_COMPONENT_DECLARE(EcsMetricInstance);
58
60FLECS_API extern ECS_COMPONENT_DECLARE(EcsMetricValue);
61
63FLECS_API extern ECS_COMPONENT_DECLARE(EcsMetricSource);
64
65typedef struct EcsMetricValue {
66 double value;
67} EcsMetricValue;
68
69typedef struct EcsMetricSource {
70 ecs_entity_t entity;
71} EcsMetricSource;
72
73typedef struct ecs_metric_desc_t {
74 /* Entity associated with metric */
75 ecs_entity_t entity;
76
77 /* Entity associated with member that stores metric value. Must not be set
78 * at the same time as id. Cannot be combined with EcsCounterId. */
79 ecs_entity_t member;
80
81 /* Tracks whether entities have the specified component id. Must not be set
82 * at the same time as member. */
83 ecs_id_t id;
84
85 /* If id is a (R, *) wildcard and relationship R has the OneOf property, the
86 * setting this value to true will track individual targets.
87 * If the kind is EcsCountId and the id is a (R, *) wildcard, this value
88 * will create a metric per target. */
89 bool targets;
90
91 /* Must be EcsGauge, EcsCounter, EcsCounterIncrement or EcsCounterId */
92 ecs_entity_t kind;
93
94 /* Description of metric. Will only be set if FLECS_DOC addon is enabled */
95 const char *brief;
96} ecs_metric_desc_t;
97
98FLECS_API
99ecs_entity_t ecs_metric_init(
100 ecs_world_t *world,
101 const ecs_metric_desc_t *desc);
102
111#define ecs_metric(world, ...)\
112 ecs_metric_init(world, &(ecs_metric_desc_t) __VA_ARGS__ )
113
114/* Module import */
115FLECS_API
116void FlecsMetricsImport(
117 ecs_world_t *world);
118
119#ifdef __cplusplus
120}
121#endif
122
123#endif
124
127#endif
ecs_id_t ecs_entity_t
An entity identifier.
Definition flecs.h:277
struct ecs_world_t ecs_world_t
A world is the container for all ECS data and supporting features.
Definition flecs.h:286
uint64_t ecs_id_t
An id.
Definition flecs.h:274
#define ECS_TAG_DECLARE
Forward declare a tag.
Definition flecs_c.h:59
#define ECS_COMPONENT_DECLARE(id)
Forward declare a component.
Definition flecs_c.h:93