Flecs v4.0
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_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);
41FLECS_API extern ECS_COMPONENT_DECLARE(EcsAlertTimeout);
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);
53
55typedef struct EcsAlertsActive {
56 int32_t info_count;
57 int32_t warning_count;
58 int32_t error_count;
59 ecs_map_t alerts;
61
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) */
75
77typedef struct ecs_alert_desc_t {
78 int32_t _canary;
79
82
87
97 const char *message;
98
100 const char *doc_name;
101
103 const char *brief;
104
108
113 ecs_alert_severity_filter_t severity_filters[ECS_ALERT_MAX_SEVERITY_FILTERS];
114
121
125
129
132 const char *var;
134
160FLECS_API
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
184 const ecs_world_t *world,
185 ecs_entity_t entity,
186 ecs_entity_t alert);
187
197FLECS_API
199 const ecs_world_t *world,
200 ecs_entity_t entity,
201 ecs_entity_t alert);
202
211FLECS_API
213 ecs_world_t *world);
214
215#ifdef __cplusplus
216}
217#endif
218
219#endif
220
223#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 ecs_alert_severity_filter_t ecs_alert_severity_filter_t
Alert severity filter.
struct EcsAlertInstance EcsAlertInstance
Component added to alert instance.
FLECS_API void FlecsAlertsImport(ecs_world_t *world)
Alert module import function.
FLECS_API ecs_entity_t ecs_alert_init(ecs_world_t *world, const ecs_alert_desc_t *desc)
Create a new alert.
struct ecs_alert_desc_t ecs_alert_desc_t
Alert descriptor, used with ecs_alert_init().
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:347
struct ecs_world_t ecs_world_t
A world is the container for all ECS data and supporting features.
Definition flecs.h:391
uint64_t ecs_id_t
Ids are the things that can be added to an entity.
Definition flecs.h:340
#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:59
Component added to alert instance.
Definition alerts.h:50
char * message
Generated alert message.
Definition alerts.h:51
Map with active alerts for entity.
Definition alerts.h:55
int32_t error_count
Number of alerts for source with error severity.
Definition alerts.h:58
int32_t info_count
Number of alerts for source with info severity.
Definition alerts.h:56
int32_t warning_count
Number of alerts for source with warning severity.
Definition alerts.h:57
Alert descriptor, used with ecs_alert_init().
Definition alerts.h:77
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
const char * brief
Description of alert.
Definition alerts.h:103
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_entity_t member
Alert when member value is out of range.
Definition alerts.h:124
ecs_id_t id
(Component) id of member to monitor.
Definition alerts.h:128
ecs_entity_t entity
Entity associated with alert.
Definition alerts.h:81
ecs_entity_t severity
Metric kind.
Definition alerts.h:107
ecs_query_desc_t query
Alert query.
Definition alerts.h:86
const char * doc_name
User friendly name.
Definition alerts.h:100
const char * message
Template for alert message.
Definition alerts.h:97
const char * var
Variable from which to fetch the member (optional).
Definition alerts.h:132
Alert severity filter.
Definition alerts.h:68
Used with ecs_query_init().
Definition flecs.h:1162