Add CTF-IR visitor interface
[babeltrace.git] / include / babeltrace / ctf-ir / trace.h
index ee740039829052cf6367cca4d9feaba46c84e1f5..39574f3a210dd50e999d9871bfd617820a4c2457 100644 (file)
@@ -31,7 +31,9 @@
  */
 
 #include <babeltrace/ctf-ir/field-types.h>
+#include <babeltrace/ctf-ir/visitor.h>
 #include <babeltrace/values.h>
+#include <babeltrace/plugin/notification/notification.h>
 #include <stdint.h>
 
 #ifdef __cplusplus
@@ -43,6 +45,18 @@ struct bt_ctf_stream;
 struct bt_ctf_stream_class;
 struct bt_ctf_clock;
 
+/**
+ * Notification handling function type.
+ *
+ * A reference must be taken on the notification if the handler has to
+ * keep ownership of the notification beyond the invocation of the callback.
+ *
+ * @param notification Notification to handle
+ * @param data         Handler private data
+ */
+typedef void (*bt_ctf_notification_cb)(
+               struct bt_notification *notification, void *data);
+
 /*
  * bt_ctf_trace_create: create a trace instance.
  *
@@ -338,6 +352,40 @@ extern struct bt_ctf_field_type *bt_ctf_trace_get_packet_header_type(
 extern int bt_ctf_trace_set_packet_header_type(struct bt_ctf_trace *trace,
                struct bt_ctf_field_type *packet_header_type);
 
+/*
+ * bt_ctf_trace_visit: visit a trace's hierarchy.
+ *
+ * Recursively walk a trace's hierarchy and call visitor on each of its
+ * elements.
+ *
+ * @param trace Trace instance.
+ * @param visitor visitor function to invoke for each element.
+ * @param data user data passed to the visitor.
+ *
+ * Returns 0 on success, a negative value on error.
+ */
+extern int bt_ctf_trace_visit(struct bt_ctf_trace *trace,
+               bt_ctf_ir_visitor visitor, void *data);
+
+/*
+ * bt_ctf_trace_add_notification_handler_cb: set a notification callback
+ * which will be invoked whenever a trace's schema is modified.
+ *
+ * Register a notification handler to a trace.
+ *
+ * @param trace Trace instance.
+ * @param handler Notification handler to invoke on trace xmodification.
+ * @param handler_data Private data passed to the notification handler.
+ *
+ * Returns 0 on success, a negative value on error.
+ *
+ * Note: the notification handler will be used to serialize the trace's current
+ * state on registration. It will then be invoked on any change occuring within
+ * the trace's hierarchy.
+ */
+extern int bt_ctf_trace_add_notification_handler_cb(struct bt_ctf_trace *trace,
+               bt_ctf_notification_cb handler, void *handler_data);
+
 #ifdef __cplusplus
 }
 #endif
This page took 0.035818 seconds and 4 git commands to generate.