HawkTracer  0.10.0
events.h
Go to the documentation of this file.
1 #ifndef HAWKTRACER_EVENTS_H
2 #define HAWKTRACER_EVENTS_H
3 
6 
7 #include <stddef.h>
8 
10 
12 
14  (POINTER, HT_EventKlass*, klass),
15  (INTEGER, HT_TimestampNs, timestamp),
16  (INTEGER, HT_EventId, id))
17 
18 HT_API HT_EventKlass* ht_HT_Event_get_event_klass_instance(void);
20 HT_API size_t ht_HT_Event_get_size(HT_Event* event);
21 HT_API size_t ht_HT_Event_fnc_serialize(HT_Event* event, HT_Byte* buffer);
22 
23 #define HT_EVENT(event) ((HT_Event*)(event))
24 
26 {
28  size_t (*serialize)(HT_Event* event, HT_Byte* buffer);
29  size_t (*get_size)(HT_Event* event);
31 };
32 
33 #define HT_REGISTER_EVENT_KLASS(EVENT_TYPE) ht_##EVENT_TYPE##_register_event_klass()
34 
35 #define HT_EVENT_GET_KLASS(event) (((HT_Event*)event)->klass)
36 #define HT_EVENT_KLASS_GET(EVENT_TYPE) ht_##EVENT_TYPE##_get_event_klass_instance()
37 #define HT_EVENT_IS_INSTANCE_OF(event, EVENT_TYPE) \
38  (HT_EVENT_GET_KLASS(event) == HT_EVENT_KLASS_GET(EVENT_TYPE))
39 
40 #define HT_DECL_EVENT(TYPE_NAME, event) \
41  TYPE_NAME event; HT_EVENT(&event)->klass = HT_EVENT_KLASS_GET(TYPE_NAME);
42 
44 
45 #endif /* HAWKTRACER_EVENTS_H */
#define HT_API
Defines a directive for exporting/importing symbols from DLL.
Definition: macros.h:76
#define HT_DECLS_END
Defines an end of C linkage block.
Definition: macros.h:17
Definition: mkcreflect.h:42
HT_API size_t ht_HT_Event_get_size(HT_Event *event)
uint8_t HT_Byte
An unsigned integer guaranteed to be 8 bits on all platforms.
Definition: base_types.h:26
uint64_t HT_TimestampNs
An unsigned integer used for representing timestamps in nanoseconds.
Definition: base_types.h:14
uint64_t HT_EventId
An unsigned integer used for event identifiers.
Definition: base_types.h:16
HT_API size_t ht_HT_Event_fnc_serialize(HT_Event *event, HT_Byte *buffer)
size_t(* serialize)(HT_Event *event, HT_Byte *buffer)
Definition: events.h:28
HT_DECLS_BEGIN INTEGER
Definition: core_events.h:11
Definition: events.h:25
HT_API HT_EventKlassId ht_HT_Event_register_event_klass(void)
HT_EventKlassId klass_id
Definition: events.h:30
typedefHT_DECLS_BEGIN struct _HT_EventKlass HT_EventKlass
Definition: events.h:11
#define HT_DECLS_BEGIN
Defines a beginning of C linkage block.
Definition: macros.h:16
MKCREFLECT_TypeInfo * type_info
Definition: events.h:27
HT_DECLS_BEGIN typedef uint32_t HT_EventKlassId
An unsigned integer used for event klass identifiers.
Definition: base_types.h:12
HT_DECLS_BEGIN HT_Event
Definition: core_events.h:11
size_t(* get_size)(HT_Event *event)
Definition: events.h:29
MKCREFLECT_DEFINE_STRUCT(HT_Event,(POINTER, HT_EventKlass *, klass),(INTEGER, HT_TimestampNs, timestamp),(INTEGER, HT_EventId, id)) HT_API HT_EventKlass *ht_HT_Event_get_event_klass_instance(void)