ir: add bt_ctf_trace_get_clock_by_name()
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Mon, 16 Mar 2015 23:24:57 +0000 (19:24 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 17 Mar 2015 02:45:43 +0000 (22:45 -0400)
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
formats/ctf/ir/trace.c
include/babeltrace/ctf-ir/trace.h

index 78c2f28e87b86c83056bd5cbf91efbed5835b621..3f9bdb86f8962c3d5f970776e1e84a6f4bc2ae48 100644 (file)
@@ -497,6 +497,36 @@ end:
        return stream_class;
 }
 
+struct bt_ctf_clock *bt_ctf_trace_get_clock_by_name(
+               struct bt_ctf_trace *trace, const char *name)
+{
+       size_t i;
+       struct bt_ctf_clock *clock = NULL;
+
+       if (!trace || !name) {
+               goto end;
+       }
+
+       for (i = 0; i < trace->clocks->len; ++i) {
+               struct bt_ctf_clock *cur_clk =
+                       g_ptr_array_index(trace->clocks, i);
+               const char *cur_clk_name = bt_ctf_clock_get_name(cur_clk);
+
+               if (!cur_clk_name) {
+                       goto end;
+               }
+
+               if (!strcmp(cur_clk_name, name)) {
+                       clock = cur_clk;
+                       bt_ctf_clock_get(clock);
+                       goto end;
+               }
+       }
+
+end:
+       return clock;
+}
+
 BT_HIDDEN
 const char *get_byte_order_string(int byte_order)
 {
index 03c281bcb21729b6074f3ce73ba7efd03c5e67bc..bcef8973bc659c8c75c9ba50492a0501bdd873ea 100644 (file)
@@ -253,6 +253,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_clock_by_name: get a trace's clock by name
+ *
+ * @param trace Trace instance.
+ * @param name Name of the clock in the given trace.
+ *
+ * Return a clock instance on success, NULL on error.
+ */
+extern struct bt_ctf_clock *bt_ctf_trace_get_clock_by_name(
+               struct bt_ctf_trace *trace, const char *name);
+
 /*
  * bt_ctf_trace_get_metadata_string: get metadata string.
  *
This page took 0.026475 seconds and 4 git commands to generate.