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#define ECS_ALERT_MAX_SEVERITY_FILTERS (4)
36
37/* Module id */
38FLECS_API extern ECS_COMPONENT_DECLARE(FlecsAlerts);
39
40/* Module components */
41
43FLECS_API extern ECS_COMPONENT_DECLARE(EcsAlert);
46FLECS_API extern ECS_COMPONENT_DECLARE(EcsAlertTimeout);
47
48/* Alert severity tags */
49FLECS_API extern ECS_TAG_DECLARE(EcsAlertInfo);
50FLECS_API extern ECS_TAG_DECLARE(EcsAlertWarning);
51FLECS_API extern ECS_TAG_DECLARE(EcsAlertError);
52FLECS_API extern ECS_TAG_DECLARE(EcsAlertCritical);
53
55typedef struct EcsAlertInstance {
56 char *message;
58
60typedef struct EcsAlertsActive {
61 int32_t info_count;
62 int32_t warning_count;
63 int32_t error_count;
64 ecs_map_t alerts;
66
68 ecs_entity_t severity; /* Severity kind */
69 ecs_id_t with; /* Component to match */
70 const char *var; /* Variable to match component on. Do not include the
71 * '$' character. Leave to NULL for $this. */
72 int32_t _var_index; /* Index of variable in filter (do not set) */
74
75typedef struct ecs_alert_desc_t {
76 int32_t _canary;
77
80
85
94 const char *message;
95
97 const char *doc_name;
98
100 const char *brief;
101
105
110 ecs_alert_severity_filter_t severity_filters[ECS_ALERT_MAX_SEVERITY_FILTERS];
111
118
122
126
129 const char *var;
131
157FLECS_API
159 ecs_world_t *world,
160 const ecs_alert_desc_t *desc);
161
162#define ecs_alert(world, ...)\
163 ecs_alert_init(world, &(ecs_alert_desc_t)__VA_ARGS__)
164
176FLECS_API
178 const ecs_world_t *world,
179 ecs_entity_t entity,
180 ecs_entity_t alert);
181
191FLECS_API
193 const ecs_world_t *world,
194 ecs_entity_t entity,
195 ecs_entity_t alert);
196
197/* Module import */
198FLECS_API
199void FlecsAlertsImport(
200 ecs_world_t *world);
201
202#ifdef __cplusplus
203}
204#endif
205
206#endif
207
210#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:288
struct ecs_world_t ecs_world_t
A world is the container for all ECS data and supporting features.
Definition flecs.h:332
uint64_t ecs_id_t
Ids are the things that can be added to an entity.
Definition flecs.h:281
#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
#define ecs_ftime_t
Customizable precision for scalar time values.
Definition flecs.h:42
Alert information.
Definition alerts.h:55
Map with active alerts for entity.
Definition alerts.h:60
ecs_alert_severity_filter_t severity_filters[(4)]
Severity filters can be used to assign different severities to the same alert.
Definition alerts.h:110
const char * brief
Description of alert.
Definition alerts.h:100
ecs_ftime_t retain_period
The retain period specifies how long an alert must be inactive before it is cleared.
Definition alerts.h:117
ecs_entity_t member
Alert when member value is out of range.
Definition alerts.h:121
ecs_id_t id
(Component) id of member to monitor.
Definition alerts.h:125
ecs_entity_t entity
Entity associated with alert.
Definition alerts.h:79
ecs_entity_t severity
Metric kind.
Definition alerts.h:104
ecs_filter_desc_t filter
Alert query.
Definition alerts.h:84
const char * doc_name
User friendly name.
Definition alerts.h:97
const char * message
Template for alert message.
Definition alerts.h:94
const char * var
Variable from which to fetch the member (optional).
Definition alerts.h:129
Used with ecs_filter_init.
Definition flecs.h:963