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(EcsGauge);
52
54FLECS_API extern ECS_COMPONENT_DECLARE(EcsMetricInstance);
55
57FLECS_API extern ECS_COMPONENT_DECLARE(EcsMetricValue);
58
60FLECS_API extern ECS_COMPONENT_DECLARE(EcsMetricSource);
61
62typedef struct EcsMetricValue {
63 double value;
64} EcsMetricValue;
65
66typedef struct EcsMetricSource {
67 ecs_entity_t entity;
68} EcsMetricSource;
69
70typedef struct ecs_metric_desc_t {
71 /* Entity associated with metric */
72 ecs_entity_t entity;
73
74 /* Entity associated with member that stores metric value. Must not be set
75 * at the same time as id. */
76 ecs_entity_t member;
77
78 /* Tracks whether entities have the specified component id. Must not be set
79 * at the same time as member. */
80 ecs_id_t id;
81
82 /* If id is a (R, *) wildcard and relationship R has the OneOf property, the
83 * setting this value to true will track individual targets. */
84 bool targets;
85
86 /* Must be either EcsGauge, EcsCounter or EcsCounterIncrement. */
87 ecs_entity_t kind;
88
89 /* Description of metric. Will only be set if FLECS_DOC addon is enabled */
90 const char *brief;
91} ecs_metric_desc_t;
92
93FLECS_API
94ecs_entity_t ecs_metric_init(
95 ecs_world_t *world,
96 const ecs_metric_desc_t *desc);
97
106#define ecs_metric(world, ...)\
107 ecs_metric_init(world, &(ecs_metric_desc_t) __VA_ARGS__ )
108
109/* Module import */
110FLECS_API
111void FlecsMetricsImport(
112 ecs_world_t *world);
113
114#ifdef __cplusplus
115}
116#endif
117
118#endif
119
122#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