Flecs: include/flecs/addons/alerts.h Source File
Description: A fast entity component system (ECS) for C & C++

| Flecs v4.1 A fast entity component system (ECS) for C & C++

Loading...
Searching...
No Matches
alerts.h
Go to the documentation of this file.
1
9
10#ifdef FLECS_ALERTS
11
19
20#ifndef FLECS_ALERTS_H
21#define FLECS_ALERTS_H
22
23#ifndef FLECS_PIPELINE
24#define FLECS_PIPELINE
25#endif
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
31#define ECS_ALERT_MAX_SEVERITY_FILTERS (4)
32
34FLECS_API extern ECS_COMPONENT_DECLARE(FlecsAlerts);
35
36/* Module components */
37
38FLECS_API extern ECS_COMPONENT_DECLARE(EcsAlert);
39FLECS_API extern ECS_COMPONENT_DECLARE(EcsAlertInstance);
40FLECS_API extern ECS_COMPONENT_DECLARE(EcsAlertsActive);
41FLECS_API extern ECS_COMPONENT_DECLARE(EcsAlertTimeout);
42
43/* Alert severity tags */
44FLECS_API extern ECS_TAG_DECLARE(EcsAlertInfo);
45FLECS_API extern ECS_TAG_DECLARE(EcsAlertWarning);
46FLECS_API extern ECS_TAG_DECLARE(EcsAlertError);
47FLECS_API extern ECS_TAG_DECLARE(EcsAlertCritical);
48
50 typedef struct EcsAlertInstance {
51 char *message;
52} EcsAlertInstance;
53
55 typedef struct EcsAlertsActive {
56 int32_t info_count;
57 int32_t warning_count;
58 int32_t error_count;
59 ecs_map_t alerts;
60} EcsAlertsActive;
61
68 typedef struct ecs_alert_severity_filter_t {
69 ecs_entity_t severity; /* Severity kind */
70 ecs_id_t with; /* Component to match */
71 const char *var; /* Variable to match component on. Do not include the
72 * '$' character. Leave to NULL for $this. */
73 int32_t _var_index; /* Index of variable in filter (do not set) */
74} ecs_alert_severity_filter_t;
75
77 typedef struct ecs_alert_desc_t {
78 int32_t _canary;
79
81 ecs_entity_t entity;
82
86 ecs_query_desc_t query;
87
97 const char *message;
98
100 const char *doc_name;
101
103 const char *brief;
104
107 ecs_entity_t severity;
108
113 ecs_alert_severity_filter_t severity_filters[ECS_ALERT_MAX_SEVERITY_FILTERS];
114
120 ecs_ftime_t retain_period;
121
124 ecs_entity_t member;
125
128 ecs_id_t id;
129
132 const char *var;
133} ecs_alert_desc_t;
134
160FLECS_API
161 ecs_entity_t ecs_alert_init(
162 ecs_world_t *world,
163 const ecs_alert_desc_t *desc);
164
168#define ecs_alert(world, ...)\
169 ecs_alert_init(world, &(ecs_alert_desc_t)__VA_ARGS__)
170
182FLECS_API
183int32_t ecs_get_alert_count(
184 const ecs_world_t *world,
185 ecs_entity_t entity,
186 ecs_entity_t alert);
187
197FLECS_API
198 ecs_entity_t ecs_get_alert(
199 const ecs_world_t *world,
200 ecs_entity_t entity,
201 ecs_entity_t alert);
202
211FLECS_API
212 void FlecsAlertsImport(
213 ecs_world_t *world);
214
215#ifdef __cplusplus
216}
217#endif
218
219#endif
220
222
223#endif
ecs_get_alert
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.
FlecsAlertsImport
FLECS_API void FlecsAlertsImport(ecs_world_t *world)
Alert module import function.
ecs_alert_init
FLECS_API ecs_entity_t ecs_alert_init(ecs_world_t *world, const ecs_alert_desc_t *desc)
Create a new alert.
ecs_get_alert_count
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_entity_t
ecs_id_t ecs_entity_t
An entity identifier.
Definition flecs.h:361
ecs_world_t
struct ecs_world_t ecs_world_t
A world is the container for all ECS data and supporting features.
Definition flecs.h:405
ecs_id_t
uint64_t ecs_id_t
Ids are the things that can be added to an entity.
Definition flecs.h:354
ECS_TAG_DECLARE
#define ECS_TAG_DECLARE
Forward declare a tag.
Definition flecs_c.h:66
ECS_COMPONENT_DECLARE
#define ECS_COMPONENT_DECLARE(id)
Forward declare a component.
Definition flecs_c.h:112
ecs_ftime_t
#define ecs_ftime_t
Customizable precision for scalar time values.
Definition flecs.h:59
EcsAlertInstance
Component added to alert instance.
Definition alerts.h:50
EcsAlertInstance::message
char * message
Generated alert message.
Definition alerts.h:51
EcsAlertsActive
Map with active alerts for entity.
Definition alerts.h:55
EcsAlertsActive::error_count
int32_t error_count
Number of alerts for source with error severity.
Definition alerts.h:58
EcsAlertsActive::info_count
int32_t info_count
Number of alerts for source with info severity.
Definition alerts.h:56
EcsAlertsActive::warning_count
int32_t warning_count
Number of alerts for source with warning severity.
Definition alerts.h:57
ecs_alert_desc_t
Alert descriptor, used with ecs_alert_init().
Definition alerts.h:77
ecs_alert_desc_t::severity_filters
ecs_alert_severity_filter_t severity_filters[(4)]
Severity filters can be used to assign different severities to the same alert.
Definition alerts.h:113
ecs_alert_desc_t::brief
const char * brief
Description of alert.
Definition alerts.h:103
ecs_alert_desc_t::retain_period
ecs_ftime_t retain_period
The retain period specifies how long an alert must be inactive before it is cleared.
Definition alerts.h:120
ecs_alert_desc_t::member
ecs_entity_t member
Alert when member value is out of range.
Definition alerts.h:124
ecs_alert_desc_t::id
ecs_id_t id
(Component) id of member to monitor.
Definition alerts.h:128
ecs_alert_desc_t::entity
ecs_entity_t entity
Entity associated with alert.
Definition alerts.h:81
ecs_alert_desc_t::severity
ecs_entity_t severity
Metric kind.
Definition alerts.h:107
ecs_alert_desc_t::query
ecs_query_desc_t query
Alert query.
Definition alerts.h:86
ecs_alert_desc_t::doc_name
const char * doc_name
User friendly name.
Definition alerts.h:100
ecs_alert_desc_t::message
const char * message
Template for alert message.
Definition alerts.h:97
ecs_alert_desc_t::var
const char * var
Variable from which to fetch the member (optional).
Definition alerts.h:132
ecs_alert_severity_filter_t
Alert severity filter.
Definition alerts.h:68
ecs_query_desc_t
Used with ecs_query_init().
Definition flecs.h:1251