ir: add bt_ctf_stream_class_get_event_class_by_id()
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Mon, 16 Mar 2015 23:05:28 +0000 (19:05 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 17 Mar 2015 02:47:39 +0000 (22:47 -0400)
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
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 6ad2cfa1583aaae18374b3276d866de8eaae660f..409c5ab0f21430dea3402a8990fc1e6568b11cbb 100644 (file)
@@ -335,6 +335,30 @@ end:
        return event_class;
 }
 
+struct bt_ctf_event_class *bt_ctf_stream_class_get_event_class_by_id(
+               struct bt_ctf_stream_class *stream_class, uint32_t id)
+{
+       size_t i;
+       struct bt_ctf_event_class *event_class = NULL;
+
+       if (!stream_class) {
+               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 (bt_ctf_event_class_get_id(current_event_class) == id) {
+                       event_class = current_event_class;
+                       bt_ctf_event_class_get(event_class);
+                       goto end;
+               }
+       }
+end:
+       return event_class;
+}
+
 struct bt_ctf_field_type *bt_ctf_stream_class_get_packet_context_type(
                struct bt_ctf_stream_class *stream_class)
 {
index bf5f577c3c99140b21f43c694bc13aae3830b91f..a78437b2dcc86f1feebde91bf2c30c921f4cf2ed 100644 (file)
@@ -190,6 +190,18 @@ extern struct bt_ctf_event_class *bt_ctf_stream_class_get_event_class(
 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_event_class_by_name: Get stream class event class by
+ * ID.
+ *
+ * @param stream_class Stream class.
+ * @param id Event class ID.
+ *
+ * Returns event class, NULL on error.
+ */
+extern struct bt_ctf_event_class *bt_ctf_stream_class_get_event_class_by_id(
+               struct bt_ctf_stream_class *stream_class, uint32_t id);
+
 /*
  * bt_ctf_stream_class_get_packet_context_type: get the stream class' packet
  * context type.
This page took 0.043113 seconds and 4 git commands to generate.