Flecs v3.2
A fast entity component system (ECS) for C & C++
Loading...
Searching...
No Matches
alerts.h
Go to the documentation of this file.
1
10#ifdef FLECS_ALERTS
11
20#ifndef FLECS_ALERTS_H
21#define FLECS_ALERTS_H
22
23#ifndef FLECS_RULES
24#define FLECS_RULES
25#endif
26
27#ifndef FLECS_PIPELINE
28#define FLECS_PIPELINE
29#endif
30
31#ifdef __cplusplus
32extern "C" {
33#endif
34
35/* Module id */
36FLECS_API extern ECS_COMPONENT_DECLARE(FlecsAlerts);
37
38/* Module components */
39
41FLECS_API extern ECS_COMPONENT_DECLARE(EcsAlert);
44
45/* Alert severity tags */
46FLECS_API extern ECS_TAG_DECLARE(EcsAlertInfo);
47FLECS_API extern ECS_TAG_DECLARE(EcsAlertWarning);
48FLECS_API extern ECS_TAG_DECLARE(EcsAlertError);
49FLECS_API extern ECS_TAG_DECLARE(EcsAlertCritical);
50
52typedef struct EcsAlertInstance {
53 char *message;
55
57typedef struct EcsAlertsActive {
58 ecs_map_t alerts;
60
61typedef struct ecs_alert_desc_t {
62 int32_t _canary;
63
64 /* Entity associated with alert */
65 ecs_entity_t entity;
66
67 /* Alert query. An alert will be created for each entity that matches the
68 * specified query. The query must have at least one term that uses the
69 * $this variable (default). */
70 ecs_filter_desc_t filter;
71
72 /* Template for alert message. This string is used to generate the alert
73 * message and may refer to variables in the query result. The format for
74 * the template expressions is as specified by ecs_interpolate_string.
75 *
76 * Examples:
77 * "$this has Position but not Velocity"
78 * "$this has a parent entity $parent without Position"
79 */
80 const char *message;
81
82 /* Description of metric. Will only be set if FLECS_DOC addon is enabled */
83 const char *brief;
84
85 /* Metric kind. Must be EcsAlertInfo, EcsAlertWarning, EcsAlertError or
86 * EcsAlertCritical. Defaults to EcsAlertError. */
87 ecs_entity_t severity;
89
115FLECS_API
117 ecs_world_t *world,
118 const ecs_alert_desc_t *desc);
119
120#define ecs_alert(world, ...)\
121 ecs_alert_init(world, &(ecs_alert_desc_t)__VA_ARGS__)
122
134FLECS_API
136 const ecs_world_t *world,
137 ecs_entity_t entity,
138 ecs_entity_t alert);
139
149FLECS_API
151 const ecs_world_t *world,
152 ecs_entity_t entity,
153 ecs_entity_t alert);
154
155/* Module import */
156FLECS_API
157void FlecsAlertsImport(
158 ecs_world_t *world);
159
160#ifdef __cplusplus
161}
162#endif
163
164#endif
165
168#endif
FLECS_API ecs_entity_t ecs_get_alert(const ecs_world_t *world, ecs_entity_t entity, ecs_entity_t alert)
Return alert instance for specified alert.
FLECS_API ecs_entity_t ecs_alert_init(ecs_world_t *world, const ecs_alert_desc_t *desc)
Create a new alert.
FLECS_API int32_t ecs_get_alert_count(const ecs_world_t *world, ecs_entity_t entity, ecs_entity_t alert)
Return number of active alerts for entity.
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
#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
Alert information.
Definition alerts.h:52
Map with active alerts for entity.
Definition alerts.h:57
Used with ecs_filter_init.
Definition flecs.h:845