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
32#define ECS_ALERT_MAX_SEVERITY_FILTERS (4)
33
35FLECS_API extern ECS_COMPONENT_DECLARE(FlecsAlerts);
36
38
39FLECS_API extern ECS_COMPONENT_DECLARE(EcsAlert);
40FLECS_API extern ECS_COMPONENT_DECLARE(EcsAlertInstance);
41FLECS_API extern ECS_COMPONENT_DECLARE(EcsAlertsActive);
42FLECS_API extern ECS_COMPONENT_DECLARE(EcsAlertTimeout);
43
45FLECS_API extern ECS_TAG_DECLARE(EcsAlertInfo);
46FLECS_API extern ECS_TAG_DECLARE(EcsAlertWarning);
47FLECS_API extern ECS_TAG_DECLARE(EcsAlertError);
48FLECS_API extern ECS_TAG_DECLARE(EcsAlertCritical);
49
51 typedef struct EcsAlertInstance {
52 char *message;
53} EcsAlertInstance;
54
56 typedef struct EcsAlertsActive {
57 int32_t info_count;
58 int32_t warning_count;
59 int32_t error_count;
60 ecs_map_t alerts;
61} EcsAlertsActive;
62
69 typedef struct ecs_alert_severity_filter_t {
70 ecs_entity_t severity;
71 ecs_id_t with;
72 const char *var;
74 int32_t _var_index;
75} ecs_alert_severity_filter_t;
76
78 typedef struct ecs_alert_desc_t {
79 int32_t _canary;
80
82 ecs_entity_t entity;
83
87 ecs_query_desc_t query;
88
98 const char *message;
99
101 const char *doc_name;
102
104 const char *brief;
105
108 ecs_entity_t severity;
109
114 ecs_alert_severity_filter_t severity_filters[ECS_ALERT_MAX_SEVERITY_FILTERS];
115
121 ecs_ftime_t retain_period;
122
125 ecs_entity_t member;
126
129 ecs_id_t id;
130
133 const char *var;
134} ecs_alert_desc_t;
135
161FLECS_API
162 ecs_entity_t ecs_alert_init(
163 ecs_world_t *world,
164 const ecs_alert_desc_t *desc);
165
169#define ecs_alert(world, ...)\
170 ecs_alert_init(world, &(ecs_alert_desc_t)__VA_ARGS__)
171
183FLECS_API
184int32_t ecs_get_alert_count(
185 const ecs_world_t *world,
186 ecs_entity_t entity,
187 ecs_entity_t alert);
188
198FLECS_API
199 ecs_entity_t ecs_get_alert(
200 const ecs_world_t *world,
201 ecs_entity_t entity,
202 ecs_entity_t alert);
203
212FLECS_API
213 void FlecsAlertsImport(
214 ecs_world_t *world);
215
216#ifdef __cplusplus
217}
218#endif
219
220#endif
221
223
224#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.
ECS_ALERT_MAX_SEVERITY_FILTERS
#define ECS_ALERT_MAX_SEVERITY_FILTERS
Maximum number of severity filters per alert.
Definition alerts.h:32
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:381
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:425
ecs_id_t
uint64_t ecs_id_t
IDs are the things that can be added to an entity.
Definition flecs.h:374
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:51
EcsAlertInstance::message
char * message
Generated alert message.
Definition alerts.h:52
EcsAlertsActive
Map with active alerts for entity.
Definition alerts.h:56
EcsAlertsActive::error_count
int32_t error_count
Number of alerts for source with error severity.
Definition alerts.h:59
EcsAlertsActive::info_count
int32_t info_count
Number of alerts for source with info severity.
Definition alerts.h:57
EcsAlertsActive::alerts
ecs_map_t alerts
Map of active alerts for entity.
Definition alerts.h:60
EcsAlertsActive::warning_count
int32_t warning_count
Number of alerts for source with warning severity.
Definition alerts.h:58
ecs_alert_desc_t
Alert descriptor, used with ecs_alert_init().
Definition alerts.h:78
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:114
ecs_alert_desc_t::brief
const char * brief
Description of alert.
Definition alerts.h:104
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:121
ecs_alert_desc_t::member
ecs_entity_t member
Alert when member value is out of range.
Definition alerts.h:125
ecs_alert_desc_t::id
ecs_id_t id
(Component) ID of member to monitor.
Definition alerts.h:129
ecs_alert_desc_t::entity
ecs_entity_t entity
Entity associated with alert.
Definition alerts.h:82
ecs_alert_desc_t::severity
ecs_entity_t severity
Alert severity.
Definition alerts.h:108
ecs_alert_desc_t::query
ecs_query_desc_t query
Alert query.
Definition alerts.h:87
ecs_alert_desc_t::doc_name
const char * doc_name
User-friendly name.
Definition alerts.h:101
ecs_alert_desc_t::_canary
int32_t _canary
Used for validity testing.
Definition alerts.h:79
ecs_alert_desc_t::message
const char * message
Template for alert message.
Definition alerts.h:98
ecs_alert_desc_t::var
const char * var
Variable from which to fetch the member (optional).
Definition alerts.h:133
ecs_alert_severity_filter_t
Alert severity filter.
Definition alerts.h:69
ecs_alert_severity_filter_t::_var_index
int32_t _var_index
Index of variable in query (do not set).
Definition alerts.h:74
ecs_alert_severity_filter_t::var
const char * var
Variable to match component on.
Definition alerts.h:72
ecs_alert_severity_filter_t::severity
ecs_entity_t severity
Severity kind.
Definition alerts.h:70
ecs_alert_severity_filter_t::with
ecs_id_t with
Component to match.
Definition alerts.h:71
ecs_query_desc_t
Used with ecs_query_init().
Definition flecs.h:1275