Set notification iterator methods to the component class
[babeltrace.git] / plugins / ctf / fs / fs.c
index 6b80d04a3258755c80fd50dfcd2368d4934a0342..61cac172fd2c4efce1c67f5008ea9bd87f84721b 100644 (file)
  * SOFTWARE.
  */
 
-#include <babeltrace/plugin/plugin-system.h>
 #include <babeltrace/ctf-ir/packet.h>
-#include <babeltrace/ctf-ir/clock.h>
-#include <babeltrace/plugin/notification/iterator.h>
-#include <babeltrace/plugin/notification/stream.h>
-#include <babeltrace/plugin/notification/event.h>
-#include <babeltrace/plugin/notification/packet.h>
-#include <babeltrace/plugin/notification/heap.h>
+#include <babeltrace/ctf-ir/clock-class.h>
+#include <babeltrace/component/notification/iterator.h>
+#include <babeltrace/component/notification/stream.h>
+#include <babeltrace/component/notification/event.h>
+#include <babeltrace/component/notification/packet.h>
+#include <babeltrace/component/notification/heap.h>
+#include <plugins-common.h>
 #include <glib.h>
 #include <assert.h>
 #include <unistd.h>
 BT_HIDDEN
 bool ctf_fs_debug;
 
-static
 enum bt_notification_iterator_status ctf_fs_iterator_next(
                struct bt_notification_iterator *iterator);
 
-static
 struct bt_notification *ctf_fs_iterator_get(
                struct bt_notification_iterator *iterator)
 {
@@ -246,7 +244,6 @@ end:
        return ret;
 }
 
-static
 enum bt_notification_iterator_status ctf_fs_iterator_next(
                struct bt_notification_iterator *iterator)
 {
@@ -364,7 +361,6 @@ void ctf_fs_iterator_destroy_data(struct ctf_fs_iterator *ctf_it)
        g_free(ctf_it);
 }
 
-static
 void ctf_fs_iterator_destroy(struct bt_notification_iterator *it)
 {
        void *data = bt_notification_iterator_get_private_data(it);
@@ -377,7 +373,7 @@ bool compare_event_notifications(struct bt_notification *a,
                struct bt_notification *b)
 {
        int ret;
-       struct bt_ctf_clock *clock;
+       struct bt_ctf_clock_class *clock_class;
        struct bt_ctf_clock_value *a_clock_value, *b_clock_value;
        struct bt_ctf_stream_class *a_stream_class;
        struct bt_ctf_stream *a_stream;
@@ -398,9 +394,9 @@ bool compare_event_notifications(struct bt_notification *a,
        trace = bt_ctf_stream_class_get_trace(a_stream_class);
        assert(trace);
 
-       clock = bt_ctf_trace_get_clock(trace, 0);
-       a_clock_value = bt_ctf_event_get_clock_value(a_event, clock);
-       b_clock_value = bt_ctf_event_get_clock_value(b_event, clock);
+       clock_class = bt_ctf_trace_get_clock_class(trace, 0);
+       a_clock_value = bt_ctf_event_get_clock_value(a_event, clock_class);
+       b_clock_value = bt_ctf_event_get_clock_value(b_event, clock_class);
        assert(a_clock_value);
        assert(b_clock_value);
 
@@ -415,7 +411,7 @@ bool compare_event_notifications(struct bt_notification *a,
        bt_put(b_clock_value);
        bt_put(a_stream);
        bt_put(a_stream_class);
-       bt_put(clock);
+       bt_put(clock_class);
        bt_put(trace);
        return a_ts < b_ts;
 }
@@ -584,25 +580,24 @@ end:
        return ret;
 }
 
-static
-enum bt_component_status ctf_fs_iterator_init(struct bt_component *source,
+enum bt_notification_iterator_status ctf_fs_iterator_init(struct bt_component *source,
                struct bt_notification_iterator *it)
 {
        struct ctf_fs_iterator *ctf_it;
        struct ctf_fs_component *ctf_fs;
-       enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
+       enum bt_notification_iterator_status ret = BT_NOTIFICATION_ITERATOR_STATUS_OK;
 
        assert(source && it);
 
        ctf_fs = bt_component_get_private_data(source);
        if (!ctf_fs) {
-               ret = BT_COMPONENT_STATUS_INVALID;
+               ret = BT_NOTIFICATION_ITERATOR_STATUS_INVAL;
                goto end;
        }
 
        ctf_it = g_new0(struct ctf_fs_iterator, 1);
        if (!ctf_it) {
-               ret = BT_COMPONENT_STATUS_NOMEM;
+               ret = BT_NOTIFICATION_ITERATOR_STATUS_NOMEM;
                goto end;
        }
 
@@ -627,22 +622,6 @@ enum bt_component_status ctf_fs_iterator_init(struct bt_component *source,
                goto error;
        }
 
-       ret = bt_notification_iterator_set_get_cb(it, ctf_fs_iterator_get);
-       if (ret) {
-               goto error;
-       }
-
-       ret = bt_notification_iterator_set_next_cb(it, ctf_fs_iterator_next);
-       if (ret) {
-               goto error;
-       }
-
-       ret = bt_notification_iterator_set_destroy_cb(it,
-                       ctf_fs_iterator_destroy);
-       if (ret) {
-               goto error;
-       }
-
        ret = bt_notification_iterator_set_private_data(it, ctf_it);
        if (ret) {
                goto error;
@@ -669,7 +648,6 @@ void ctf_fs_destroy_data(struct ctf_fs_component *ctf_fs)
        g_free(ctf_fs);
 }
 
-static
 void ctf_fs_destroy(struct bt_component *component)
 {
        void *data = bt_component_get_private_data(component);
@@ -726,7 +704,7 @@ end:
 
 BT_HIDDEN
 enum bt_component_status ctf_fs_init(struct bt_component *source,
-               struct bt_value *params)
+               struct bt_value *params, UNUSED_VAR void *init_method_data)
 {
        struct ctf_fs_component *ctf_fs;
        enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
@@ -739,21 +717,10 @@ enum bt_component_status ctf_fs_init(struct bt_component *source,
                goto end;
        }
 
-       ret = bt_component_set_destroy_cb(source, ctf_fs_destroy);
-       if (ret != BT_COMPONENT_STATUS_OK) {
-               goto error;
-       }
-
        ret = bt_component_set_private_data(source, ctf_fs);
        if (ret != BT_COMPONENT_STATUS_OK) {
                goto error;
        }
-
-       ret = bt_component_source_set_iterator_init_cb(source,
-                       ctf_fs_iterator_init);
-       if (ret != BT_COMPONENT_STATUS_OK) {
-               goto error;
-       }
 end:
        return ret;
 error:
This page took 0.024953 seconds and 4 git commands to generate.