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
95 const char *message;
96
98 const char *doc_name;
99
101 const char *brief;
102
106
111 ecs_alert_severity_filter_t severity_filters[ECS_ALERT_MAX_SEVERITY_FILTERS];
112
119
123
127
130 const char *var;
132
158FLECS_API
160 ecs_world_t *world,
161 const ecs_alert_desc_t *desc);
162
163#define ecs_alert(world, ...)\
164 ecs_alert_init(world, &(ecs_alert_desc_t)__VA_ARGS__)
165
177FLECS_API
179 const ecs_world_t *world,
180 ecs_entity_t entity,
181 ecs_entity_t alert);
182
192FLECS_API
194 const ecs_world_t *world,
195 ecs_entity_t entity,
196 ecs_entity_t alert);
197
198/* Module import */
199FLECS_API
200void FlecsAlertsImport(
201 ecs_world_t *world);
202
203#ifdef __cplusplus
204}
205#endif
206
207#endif
208
211#endif
struct EcsAlertsActive EcsAlertsActive
Map with active alerts for entity.
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.
struct EcsAlertInstance EcsAlertInstance
Alert information.
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:305
struct ecs_world_t ecs_world_t
A world is the container for all ECS data and supporting features.
Definition flecs.h:349
uint64_t ecs_id_t
Ids are the things that can be added to an entity.
Definition flecs.h:298
#define ECS_TAG_DECLARE
Forward declare a tag.
Definition flecs_c.h:66
#define ECS_COMPONENT_DECLARE(id)
Forward declare a component.
Definition flecs_c.h:112
#define ecs_ftime_t
Customizable precision for scalar time values.
Definition flecs.h:43
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:111
const char * brief
Description of alert.
Definition alerts.h:101
ecs_ftime_t retain_period
The retain period specifies how long an alert must be inactive before it is cleared.
Definition alerts.h:118
ecs_entity_t member
Alert when member value is out of range.
Definition alerts.h:122
ecs_id_t id
(Component) id of member to monitor.
Definition alerts.h:126
ecs_entity_t entity
Entity associated with alert.
Definition alerts.h:79
ecs_entity_t severity
Metric kind.
Definition alerts.h:105
ecs_filter_desc_t filter
Alert query.
Definition alerts.h:84
const char * doc_name
User friendly name.
Definition alerts.h:98
const char * message
Template for alert message.
Definition alerts.h:95
const char * var
Variable from which to fetch the member (optional).
Definition alerts.h:130
Used with ecs_filter_init().
Definition flecs.h:983