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 ecs_map_t alerts;
63
65 ecs_entity_t severity; /* Severity kind */
66 ecs_id_t with; /* Component to match */
67 const char *var; /* Variable to match component on. Do not include the
68 * '$' character. Leave to NULL for $this. */
69 int32_t _var_index; /* Index of variable in filter (do not set) */
71
72typedef struct ecs_alert_desc_t {
73 int32_t _canary;
74
77
82
91 const char *message;
92
94 const char *doc_name;
95
97 const char *brief;
98
102
107 ecs_alert_severity_filter_t severity_filters[ECS_ALERT_MAX_SEVERITY_FILTERS];
108
115
119
123
126 const char *var;
128
154FLECS_API
156 ecs_world_t *world,
157 const ecs_alert_desc_t *desc);
158
159#define ecs_alert(world, ...)\
160 ecs_alert_init(world, &(ecs_alert_desc_t)__VA_ARGS__)
161
173FLECS_API
175 const ecs_world_t *world,
176 ecs_entity_t entity,
177 ecs_entity_t alert);
178
188FLECS_API
190 const ecs_world_t *world,
191 ecs_entity_t entity,
192 ecs_entity_t alert);
193
194/* Module import */
195FLECS_API
196void FlecsAlertsImport(
197 ecs_world_t *world);
198
199#ifdef __cplusplus
200}
201#endif
202
203#endif
204
207#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
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
#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:107
const char * brief
Description of alert.
Definition alerts.h:97
ecs_ftime_t retain_period
The retain period specifies how long an alert must be inactive before it is cleared.
Definition alerts.h:114
ecs_entity_t member
Alert when member value is out of range.
Definition alerts.h:118
ecs_id_t id
(Component) id of member to monitor.
Definition alerts.h:122
ecs_entity_t entity
Entity associated with alert.
Definition alerts.h:76
ecs_entity_t severity
Metric kind.
Definition alerts.h:101
ecs_filter_desc_t filter
Alert query.
Definition alerts.h:81
const char * doc_name
User friendly name.
Definition alerts.h:94
const char * message
Template for alert message.
Definition alerts.h:91
const char * var
Variable from which to fetch the member (optional).
Definition alerts.h:126
Used with ecs_filter_init.
Definition flecs.h:848