Add trace moficiation notification handler interface
[babeltrace.git] / formats / ctf / ir / trace.c
index 4d9e97f9e1f8f53770c464ec2c9dca53681c5330..c4889b79b44fb2f4ef318f387434bfad800ca79f 100644 (file)
 #define DEFAULT_IDENTIFIER_SIZE 128
 #define DEFAULT_METADATA_STRING_SIZE 4096
 
+struct notification_handler {
+       bt_ctf_notification_cb func;
+       void *data;
+};
+
 static
 void bt_ctf_trace_destroy(struct bt_object *obj);
 static
@@ -1027,6 +1032,27 @@ end:
        return ret;
 }
 
+int bt_ctf_trace_add_notification_handler_cb(struct bt_ctf_trace *trace,
+               bt_ctf_notification_cb handler, void *handler_data)
+{
+       int ret = 0;
+       struct notification_handler *handler_wrapper =
+                       g_new0(struct notification_handler, 1);
+
+       if (!trace || !handler || !handler_wrapper) {
+               ret = -1;
+               goto error;
+       }
+
+       handler_wrapper->func = handler;
+       handler_wrapper->data = handler_data;
+       g_ptr_array_add(trace->notification_handlers, handler_wrapper);
+       return ret;
+error:
+       g_free(handler_wrapper);
+       return ret;
+}
+
 BT_HIDDEN
 struct bt_ctf_field_type *get_field_type(enum field_type_alias alias)
 {
This page took 0.025037 seconds and 4 git commands to generate.