Add clock accessor to CTF IR Trace
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Mon, 20 Oct 2014 17:39:46 +0000 (13:39 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Mon, 20 Oct 2014 17:57:29 +0000 (13:57 -0400)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
formats/ctf/ir/trace.c
include/babeltrace/ctf-ir/trace.h

index 073e4abffb83c8ba11f802e5ce29d0949e312fa1..1ad37bec5ee85b5d7e7c65d885580d29b9726806 100644 (file)
@@ -282,6 +282,34 @@ end:
        return ret;
 }
 
+int bt_ctf_trace_get_clock_count(struct bt_ctf_trace *trace)
+{
+       int ret = -1;
+
+       if (!trace) {
+               goto end;
+       }
+
+       ret = trace->clocks->len;
+end:
+       return ret;
+}
+
+struct bt_ctf_clock *bt_ctf_trace_get_clock(struct bt_ctf_trace *trace,
+               int index)
+{
+       struct bt_ctf_clock *clock = NULL;
+
+       if (!trace || index < 0 || index >= trace->clocks->len) {
+               goto end;
+       }
+
+       clock = g_ptr_array_index(trace->clocks, index);
+       bt_ctf_clock_get(clock);
+end:
+       return clock;
+}
+
 BT_HIDDEN
 const char *get_byte_order_string(int byte_order)
 {
index 1be85cfdeb4d197246ce6fe7324c56b20fa0f2ab..d36da0eb43d86fa93d9827ea6f3a19e446b025ee 100644 (file)
@@ -95,6 +95,27 @@ extern int bt_ctf_trace_add_environment_field(struct bt_ctf_trace *trace,
 extern int bt_ctf_trace_add_clock(struct bt_ctf_trace *trace,
                struct bt_ctf_clock *clock);
 
+/*
+ * bt_ctf_trace_get_clock_count: get the number of clocks
+ *     associated to the trace.
+ *
+ * @param trace Trace instance.
+ *
+ * Returns the clock count on success, a negative value on error.
+ */
+extern int bt_ctf_trace_get_clock_count(struct bt_ctf_trace *trace);
+
+/*
+ * bt_ctf_trace_get_clock: get a trace's clock at index.
+ *
+ * @param trace Trace instance.
+ * @param index Index 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(
+               struct bt_ctf_trace *trace, int index);
+
 /*
  * bt_ctf_trace_get_metadata_string: get metadata string.
  *
This page took 0.026146 seconds and 4 git commands to generate.