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
19#ifndef FLECS_METRICS_H
20#define FLECS_METRICS_H
21
22#ifndef FLECS_META
23#define FLECS_META
24#endif
25
26#ifndef FLECS_UNITS
27#define FLECS_UNITS
28#endif
29
30#ifndef FLECS_PIPELINE
31#define FLECS_PIPELINE
32#endif
33
34#ifdef __cplusplus
35extern "C" {
36#endif
37
38FLECS_API extern ECS_COMPONENT_DECLARE(FlecsMetrics);
39
41FLECS_API extern ECS_TAG_DECLARE(EcsMetric);
42
44FLECS_API extern ECS_TAG_DECLARE(EcsCounter);
45
47FLECS_API extern ECS_TAG_DECLARE(EcsCounterIncrement);
48
50FLECS_API extern ECS_TAG_DECLARE(EcsCounterId);
51
53FLECS_API extern ECS_TAG_DECLARE(EcsGauge);
54
56FLECS_API extern ECS_COMPONENT_DECLARE(EcsMetricInstance);
57
60
63
64typedef struct EcsMetricValue {
65 double value;
67
68typedef struct EcsMetricSource {
69 ecs_entity_t entity;
71
72typedef struct ecs_metric_desc_t {
73 int32_t _canary;
74
75 /* Entity associated with metric */
76 ecs_entity_t entity;
77
78 /* Entity associated with member that stores metric value. Must not be set
79 * at the same time as id. Cannot be combined with EcsCounterId. */
80 ecs_entity_t member;
81
82 /* Tracks whether entities have the specified component id. Must not be set
83 * at the same time as member. */
84 ecs_id_t id;
85
86 /* If id is a (R, *) wildcard and relationship R has the OneOf property,
87 * setting this value to true will track individual targets.
88 * If the kind is EcsCountId and the id is a (R, *) wildcard, this value
89 * will create a metric per target. */
90 bool targets;
91
92 /* Must be EcsGauge, EcsCounter, EcsCounterIncrement or EcsCounterId */
93 ecs_entity_t kind;
94
95 /* Description of metric. Will only be set if FLECS_DOC addon is enabled */
96 const char *brief;
98
138FLECS_API
140 ecs_world_t *world,
141 const ecs_metric_desc_t *desc);
142
151#define ecs_metric(world, ...)\
152 ecs_metric_init(world, &(ecs_metric_desc_t) __VA_ARGS__ )
153
154/* Module import */
155FLECS_API
156void FlecsMetricsImport(
157 ecs_world_t *world);
158
159#ifdef __cplusplus
160}
161#endif
162
163#endif
164
167#endif
FLECS_API ecs_entity_t ecs_metric_init(ecs_world_t *world, const ecs_metric_desc_t *desc)
Create a new metric.
ecs_id_t ecs_entity_t
An entity identifier.
Definition flecs.h:282
struct ecs_world_t ecs_world_t
A world is the container for all ECS data and supporting features.
Definition flecs.h:291
uint64_t ecs_id_t
An id.
Definition flecs.h:279
#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