Implement CTF-IR stream class getters
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 12 Jun 2014 19:00:39 +0000 (15:00 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Sat, 28 Jun 2014 21:13:00 +0000 (17:13 -0400)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
formats/ctf/ir/stream-class.c
include/babeltrace/ctf-ir/stream-class.h

index 7957a4961733c1f8a56f2863b77cffb4646dc2c8..67015978399eb35e2e13b354412d4bb9279ef57d 100644 (file)
@@ -77,6 +77,20 @@ error:
        return stream_class;
 }
 
+const char *bt_ctf_stream_class_get_name(
+               struct bt_ctf_stream_class *stream_class)
+{
+       const char *name = NULL;
+
+       if (!stream_class) {
+               goto end;
+       }
+
+       name = stream_class->name->str;
+end:
+       return name;
+}
+
 struct bt_ctf_clock *bt_ctf_stream_class_get_clock(
                struct bt_ctf_stream_class *stream_class)
 {
@@ -183,6 +197,66 @@ end:
        return ret;
 }
 
+int64_t bt_ctf_stream_class_get_event_class_count(
+               struct bt_ctf_stream_class *stream_class)
+{
+       int64_t ret;
+
+       if (!stream_class) {
+               ret = -1;
+               goto end;
+       }
+
+       ret = (int64_t) stream_class->event_classes->len;
+end:
+       return ret;
+}
+
+struct bt_ctf_event_class *bt_ctf_stream_class_get_event_class(
+               struct bt_ctf_stream_class *stream_class, size_t index)
+{
+       struct bt_ctf_event_class *event_class = NULL;
+
+       if (!stream_class || index >= stream_class->event_classes->len) {
+               goto end;
+       }
+
+       event_class = g_ptr_array_index(stream_class->event_classes, index);
+       bt_ctf_event_class_get(event_class);
+end:
+       return event_class;
+}
+
+struct bt_ctf_event_class *bt_ctf_stream_class_get_event_class_by_name(
+               struct bt_ctf_stream_class *stream_class, const char *name)
+{
+       size_t i;
+       GQuark name_quark;
+       struct bt_ctf_event_class *event_class = NULL;
+
+       if (!stream_class || !name) {
+               goto end;
+       }
+
+       name_quark = g_quark_try_string(name);
+       if (!name_quark) {
+               goto end;
+       }
+
+       for (i = 0; i < stream_class->event_classes->len; i++) {
+               struct bt_ctf_event_class *current_event_class =
+                       g_ptr_array_index(stream_class->event_classes, i);
+
+               if (name_quark == current_event_class->name) {
+                       event_class = current_event_class;
+                       bt_ctf_event_class_get(event_class);
+                       goto end;
+               }
+       }
+end:
+       return event_class;
+}
+
 void bt_ctf_stream_class_get(struct bt_ctf_stream_class *stream_class)
 {
        if (!stream_class) {
index d26bc2ca861441745750309e2a2fd6ae052d9a30..ef6bc778d535c94724fe8a6e7949068fe970208a 100644 (file)
@@ -50,6 +50,16 @@ struct bt_ctf_clock;
  */
 extern struct bt_ctf_stream_class *bt_ctf_stream_class_create(const char *name);
 
+/*
+ * bt_ctf_stream_class_get_name: Get a stream class' name.
+ *
+ * @param stream_class Stream class.
+ *
+ * Returns the stream class' name, NULL on error.
+ */
+extern const char *bt_ctf_stream_class_get_name(
+               struct bt_ctf_stream_class *stream_class);
+
 /*
  * bt_ctf_stream_class_get_clock: get the clock associated with a stream class.
  *
@@ -118,6 +128,40 @@ extern int bt_ctf_stream_class_add_event_class(
                struct bt_ctf_stream_class *stream_class,
                struct bt_ctf_event_class *event_class);
 
+/*
+ * bt_ctf_stream_class_get_event_class_count: Get a stream class' event class
+ * count.
+ *
+ * @param stream_class Stream class.
+ *
+ * Returns the stream class' event count, a negative value on error.
+ */
+extern int64_t bt_ctf_stream_class_get_event_class_count(
+               struct bt_ctf_stream_class *stream_class);
+
+/*
+ * bt_ctf_stream_class_get_event_class: Get stream class event class by index.
+ *
+ * @param stream_class Stream class.
+ * @param index Index of field.
+ *
+ * Returns event class, NULL on error.
+ */
+extern struct bt_ctf_event_class *bt_ctf_stream_class_get_event_class(
+               struct bt_ctf_stream_class *stream_class, size_t index);
+
+/*
+ * bt_ctf_stream_class_get_event_class_by_name: Get stream class event class by
+ * name.
+ *
+ * @param stream_class Stream class.
+ * @param name Event name.
+ *
+ * Returns event class, NULL on error.
+ */
+extern struct bt_ctf_event_class *bt_ctf_stream_class_get_event_class_by_name(
+               struct bt_ctf_stream_class *stream_class, const char *name);
+
 /*
  * bt_ctf_stream_class_get and bt_ctf_stream_class_put: increment and
  * decrement the stream class' reference count.
This page took 0.02673 seconds and 5 git commands to generate.