HawkTracer  0.10.0
timeline.h
Go to the documentation of this file.
1 #ifndef HAWKTRACER_TIMELINE_H
2 #define HAWKTRACER_TIMELINE_H
3 
4 #include <hawktracer/events.h>
8 #include <hawktracer/feature.h>
9 
10 #include <stddef.h>
11 
15 #define HT_TIMELINE_FEATURE(timeline, feature_id, feature_type) \
16  ((feature_type*)ht_timeline_get_feature(timeline, feature_id))
17 
19 #define HT_TIMELINE_MAX_FEATURES 32
20 
22 
23 typedef struct _HT_Timeline HT_Timeline;
24 
25 HT_API HT_Timeline* ht_timeline_create(size_t buffer_capacity,
26  HT_Boolean thread_safe,
27  HT_Boolean serialize_events,
28  const char* listeners,
29  HT_ErrorCode* out_err);
30 
36 HT_API void ht_timeline_destroy(HT_Timeline* timeline);
37 
50  HT_Timeline* timeline,
52  void* user_data);
53 
69  HT_Timeline* timeline,
71  void* user_data,
72  HT_DestroyCallback destroy_callback);
73 
84 
93 HT_API void ht_timeline_init_event(HT_Timeline* timeline, HT_Event* event);
94 
101 HT_API void ht_timeline_push_event(HT_Timeline* timeline, HT_Event* event);
102 
108 HT_API void ht_timeline_flush(HT_Timeline* timeline);
109 
126 
134 
136 
147 #define HT_TIMELINE_PUSH_EVENT(TIMELINE, EVENT_TYPE, ...) \
148  HT_TIMELINE_PUSH_EVENT_PEDANTIC(TIMELINE, EVENT_TYPE, ht_base_event, __VA_ARGS__)
149 
174 #define HT_TIMELINE_PUSH_EVENT_PEDANTIC(TIMELINE, EVENT_TYPE, ...) \
175  do { \
176  HT_Event ht_base_event = { \
177  ht_##EVENT_TYPE##_get_event_klass_instance(), \
178  ht_monotonic_clock_get_timestamp(), \
179  ht_event_id_provider_next(ht_timeline_get_id_provider(TIMELINE)) \
180  }; \
181  EVENT_TYPE ev = {__VA_ARGS__}; \
182  ht_timeline_push_event(TIMELINE, HT_EVENT(&ev)); \
183  } while (0)
184 
186 
187 #endif /* HAWKTRACER_TIMELINE_H */
typedefHT_DECLS_BEGIN struct _HT_Feature HT_Feature
Definition: feature.h:13
HT_API HT_Timeline * ht_timeline_create(size_t buffer_capacity, HT_Boolean thread_safe, HT_Boolean serialize_events, const char *listeners, HT_ErrorCode *out_err)
HT_API void ht_timeline_flush(HT_Timeline *timeline)
Transfers all the events from internal buffer to listeners.
#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
HT_API HT_ErrorCode ht_timeline_register_listener(HT_Timeline *timeline, HT_TimelineListenerCallback callback, void *user_data)
Registers new listener to a timeline.
typedefHT_DECLS_BEGIN struct _HT_Timeline HT_Timeline
Definition: timeline.h:23
HT_ErrorCode
Defines list of possible errors returned by library functions.
Definition: base_types.h:48
int HT_Boolean
A standard boolean type, possible values: HT_TRUE, HT_FALSE.
Definition: base_types.h:20
HT_DECLS_BEGIN typedef void(* HT_TimelineListenerCallback)(TEventPtr events, size_t buffer_size, HT_Boolean serialized, void *user_data)
A callback for the timeline listener.
Definition: timeline_listener.h:20
HT_API void ht_timeline_push_event(HT_Timeline *timeline, HT_Event *event)
Pushes an event to a timeline.
HT_API HT_EventIdProvider * ht_timeline_get_id_provider(HT_Timeline *timeline)
void(* HT_DestroyCallback)(void *data)
A type of function called to destroy data element.
Definition: base_types.h:34
HT_API void ht_timeline_destroy(HT_Timeline *timeline)
Destroys a timeline.
typedefHT_DECLS_BEGIN struct _HT_EventIdProvider HT_EventIdProvider
HT_EventIdProvider is a sequence number generator.
Definition: event_id_provider.h:13
HT_API HT_Feature * ht_timeline_get_feature(HT_Timeline *timeline, HT_FeatureKlass *feature_klass)
Gets the feature object of a specific class from the pipeline.
#define HT_DECLS_BEGIN
Defines a beginning of C linkage block.
Definition: macros.h:16
HT_API HT_ErrorCode ht_timeline_set_feature(HT_Timeline *timeline, HT_Feature *feature)
Enables a specific feature in the timeline.
HT_API HT_ErrorCode ht_timeline_register_listener_full(HT_Timeline *timeline, HT_TimelineListenerCallback callback, void *user_data, HT_DestroyCallback destroy_callback)
Registers new listener to a timeline.
HT_DECLS_BEGIN HT_Event
Definition: core_events.h:11
The struct represents a feature class.
Definition: feature.h:28
HT_API void ht_timeline_init_event(HT_Timeline *timeline, HT_Event *event)
Initializes event according to timeline&#39;s parameters.
HT_API void ht_timeline_unregister_all_listeners(HT_Timeline *timeline)
Removes all the listeners from a timeline.