Add logging to validation and serialization failure paths
[babeltrace.git] / include / babeltrace / ctf-ir / trace.h
index cc628a5b5240f804ab26666cabe0d7f2b938e72b..fae7832bd2a3dbda127d57892fdfcedcb4ffb104 100644 (file)
  * http://www.efficios.com/ctf
  */
 
-#include <babeltrace/ctf-ir/event-types.h>
-#include <babeltrace/objects.h>
+#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,17 @@ struct bt_ctf_stream;
 struct bt_ctf_stream_class;
 struct bt_ctf_clock;
 
+/**
+ * Trace modification handling function type.
+ *
+ * Callback invoked whenever an element is added to a trace's hierachy.
+ *
+ * @param element      New element
+ * @param data         Handler private data
+ */
+typedef void (*bt_ctf_listener_cb)(
+               struct bt_ctf_ir_element *element, void *data);
+
 /*
  * bt_ctf_trace_create: create a trace instance.
  *
@@ -58,21 +71,6 @@ struct bt_ctf_clock;
  */
 extern struct bt_ctf_trace *bt_ctf_trace_create(void);
 
-/*
- * bt_ctf_trace_create_stream: create a stream instance.
- *
- * Allocate a new stream instance and register it to the trace. The creation of
- * a stream sets its reference count to 1.
- *
- * @param trace Trace instance.
- * @param stream_class Stream class to instantiate.
- *
- * Returns a new stream on success, NULL on error.
- */
-extern struct bt_ctf_stream *bt_ctf_trace_create_stream(
-               struct bt_ctf_trace *trace,
-               struct bt_ctf_stream_class *stream_class);
-
 /*
  * bt_ctf_trace_set_environment_field: sets an environment field to the
  *     trace.
@@ -84,8 +82,8 @@ extern struct bt_ctf_stream *bt_ctf_trace_create_stream(
  * If a value exists in the environment for the specified name, it is
  * replaced by the new value.
  *
- * The value parameter _must_ be either an integer object or a
- * string object. Other object types are not supported.
+ * The value parameter _must_ be either an integer value object or a
+ * string value object. Other object types are not supported.
  *
  * @param trace Trace instance.
  * @param name Name of the environment field (will be copied).
@@ -95,7 +93,7 @@ extern struct bt_ctf_stream *bt_ctf_trace_create_stream(
  */
 extern int bt_ctf_trace_set_environment_field(
                struct bt_ctf_trace *trace, const char *name,
-               struct bt_object *value);
+               struct bt_value *value);
 
 /*
  * bt_ctf_trace_set_environment_field_string: sets a string environment
@@ -167,14 +165,14 @@ bt_ctf_trace_get_environment_field_name(struct bt_ctf_trace *trace,
  *
  * Get an environment field's value (an object). The returned object's
  * reference count is incremented. When done with the object, the caller
- * must call bt_object_put() on it.
+ * must call bt_value_put() on it.
  *
  * @param trace Trace instance.
  * @param index Index of the environment field.
  *
  * Returns the environment field's object value, NULL on error.
  */
-extern struct bt_object *
+extern struct bt_value *
 bt_ctf_trace_get_environment_field_value(struct bt_ctf_trace *trace,
                int index);
 
@@ -184,14 +182,14 @@ bt_ctf_trace_get_environment_field_value(struct bt_ctf_trace *trace,
  *
  * Get an environment field's value (an object) by its field name. The
  * returned object's reference count is incremented. When done with the
- * object, the caller must call bt_object_put() on it.
+ * object, the caller must call bt_value_put() on it.
  *
  * @param trace Trace instance.
  * @param name Environment field's name
  *
  * Returns the environment field's object value, NULL on error.
  */
-extern struct bt_object *
+extern struct bt_value *
 bt_ctf_trace_get_environment_field_value_by_name(struct bt_ctf_trace *trace,
                const char *name);
 
@@ -264,6 +262,17 @@ extern int bt_ctf_trace_get_stream_class_count(struct bt_ctf_trace *trace);
 extern struct bt_ctf_stream_class *bt_ctf_trace_get_stream_class(
                struct bt_ctf_trace *trace, int index);
 
+/*
+ * bt_ctf_trace_get_stream_class_by_id: get a trace's stream class by ID.
+ *
+ * @param trace Trace instance.
+ * @param index ID of the stream class in the given trace.
+ *
+ * Return a stream class on success, NULL on error.
+ */
+extern struct bt_ctf_stream_class *bt_ctf_trace_get_stream_class_by_id(
+               struct bt_ctf_trace *trace, uint32_t id);
+
 /*
  * bt_ctf_trace_get_clock_by_name: get a trace's clock by name
  *
@@ -343,23 +352,38 @@ 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_get and bt_ctf_trace_put: increment and decrement the
- * trace's reference count.
+ * bt_ctf_trace_visit: visit a trace's hierarchy.
+ *
+ * Recursively walk a trace's hierarchy and call visitor on each of its
+ * elements.
  *
- * You may also use bt_ctf_get() and bt_ctf_put() with trace objects.
+ * @param trace Trace instance.
+ * @param visitor visitor function to invoke for each element.
+ * @param data user data passed to the visitor.
  *
- * These functions ensure that the trace won't be destroyed while it
- * is in use. The same number of get and put (plus one extra put to
- * release the initial reference done at creation) have to be done to
- * destroy a trace.
+ * 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_listener: add a trace modification listener
+ * which will be invoked whenever a trace's schema is modified.
  *
- * When the trace's reference count is decremented to 0 by a
- * bt_ctf_trace_put, the trace is freed.
+ * Register a modification listener to a trace.
  *
  * @param trace Trace instance.
+ * @param listener Callback to invoke on trace modification.
+ * @param listener_data Private data passed to the listener.
+ *
+ * Returns 0 on success, a negative value on error.
+ *
+ * Note: the listener 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 void bt_ctf_trace_get(struct bt_ctf_trace *trace);
-extern void bt_ctf_trace_put(struct bt_ctf_trace *trace);
+extern int bt_ctf_trace_add_listener(struct bt_ctf_trace *trace,
+               bt_ctf_listener_cb listener, void *listener_data);
 
 #ifdef __cplusplus
 }
This page took 0.026782 seconds and 4 git commands to generate.