lib: make can_seek_ns_from_origin logic use `can_seek_forward` property of iterator
[babeltrace.git] / src / plugins / lttng-utils / debug-info / debug-info.c
index 545a4eee8c1c929ad6aef23a1d5605998c3fb6a2..c948df24b73b3719667f634a5e0255731a37e19a 100644 (file)
@@ -1746,14 +1746,15 @@ int init_from_params(struct debug_info_component *debug_info_component,
 }
 
 BT_HIDDEN
-bt_component_class_init_method_status debug_info_comp_init(
+bt_component_class_initialize_method_status debug_info_comp_init(
                bt_self_component_filter *self_comp_flt,
+               bt_self_component_filter_configuration *config,
                const bt_value *params, __attribute__((unused)) void *init_method_data)
 {
        int ret;
        struct debug_info_component *debug_info_comp;
-       bt_component_class_init_method_status status =
-               BT_COMPONENT_CLASS_INIT_METHOD_STATUS_OK;
+       bt_component_class_initialize_method_status status =
+               BT_COMPONENT_CLASS_INITIALIZE_METHOD_STATUS_OK;
        bt_self_component_add_port_status add_port_status;
        bt_self_component *self_comp =
                bt_self_component_filter_as_self_component(self_comp_flt);
@@ -1778,10 +1779,10 @@ bt_component_class_init_method_status debug_info_comp_init(
                self_comp_flt, "in", NULL, NULL);
        switch (add_port_status) {
        case BT_SELF_COMPONENT_ADD_PORT_STATUS_ERROR:
-               status = BT_COMPONENT_CLASS_INIT_METHOD_STATUS_ERROR;
+               status = BT_COMPONENT_CLASS_INITIALIZE_METHOD_STATUS_ERROR;
                goto error;
        case BT_SELF_COMPONENT_ADD_PORT_STATUS_MEMORY_ERROR:
-               status = BT_COMPONENT_CLASS_INIT_METHOD_STATUS_MEMORY_ERROR;
+               status = BT_COMPONENT_CLASS_INITIALIZE_METHOD_STATUS_MEMORY_ERROR;
                goto error;
        default:
                break;
@@ -1791,10 +1792,10 @@ bt_component_class_init_method_status debug_info_comp_init(
                        self_comp_flt, "out", NULL, NULL);
        switch (add_port_status) {
        case BT_SELF_COMPONENT_ADD_PORT_STATUS_ERROR:
-               status = BT_COMPONENT_CLASS_INIT_METHOD_STATUS_ERROR;
+               status = BT_COMPONENT_CLASS_INITIALIZE_METHOD_STATUS_ERROR;
                goto error;
        case BT_SELF_COMPONENT_ADD_PORT_STATUS_MEMORY_ERROR:
-               status = BT_COMPONENT_CLASS_INIT_METHOD_STATUS_MEMORY_ERROR;
+               status = BT_COMPONENT_CLASS_INITIALIZE_METHOD_STATUS_MEMORY_ERROR;
                goto error;
        default:
                break;
@@ -1814,8 +1815,8 @@ error:
        destroy_debug_info_comp(debug_info_comp);
        bt_self_component_set_data(self_comp, NULL);
 
-       if (status == BT_COMPONENT_CLASS_INIT_METHOD_STATUS_OK) {
-               status = BT_COMPONENT_CLASS_INIT_METHOD_STATUS_ERROR;
+       if (status == BT_COMPONENT_CLASS_INITIALIZE_METHOD_STATUS_OK) {
+               status = BT_COMPONENT_CLASS_INITIALIZE_METHOD_STATUS_ERROR;
        }
 end:
        return status;
@@ -1955,13 +1956,15 @@ end:
 }
 
 BT_HIDDEN
-bt_component_class_message_iterator_init_method_status debug_info_msg_iter_init(
+bt_component_class_message_iterator_initialize_method_status debug_info_msg_iter_init(
                bt_self_message_iterator *self_msg_iter,
+               bt_self_message_iterator_configuration *config,
                bt_self_component_filter *self_comp_flt,
                bt_self_component_port_output *self_port)
 {
-       bt_component_class_message_iterator_init_method_status status =
-               BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INIT_METHOD_STATUS_OK;
+       bt_component_class_message_iterator_initialize_method_status status;
+       bt_self_component_port_input_message_iterator_create_from_message_iterator_status
+               msg_iter_status;
        struct bt_self_component_port_input *input_port = NULL;
        bt_self_component_port_input_message_iterator *upstream_iterator = NULL;
        struct debug_info_msg_iter *debug_info_msg_iter = NULL;
@@ -1976,13 +1979,13 @@ bt_component_class_message_iterator_init_method_status debug_info_msg_iter_init(
        input_port = bt_self_component_filter_borrow_input_port_by_name(
                self_comp_flt, "in");
        if (!input_port) {
-               status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INIT_METHOD_STATUS_ERROR;
+               status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INITIALIZE_METHOD_STATUS_ERROR;
                goto error;
        }
 
        debug_info_msg_iter = g_new0(struct debug_info_msg_iter, 1);
        if (!debug_info_msg_iter) {
-               status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INIT_METHOD_STATUS_MEMORY_ERROR;
+               status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INITIALIZE_METHOD_STATUS_MEMORY_ERROR;
                goto error;
        }
 
@@ -1990,10 +1993,10 @@ bt_component_class_message_iterator_init_method_status debug_info_msg_iter_init(
        debug_info_msg_iter->self_comp = self_comp;
 
        /* Create an iterator on the upstream component. */
-       upstream_iterator = bt_self_component_port_input_message_iterator_create_from_message_iterator(
-               self_msg_iter, input_port);
-       if (!upstream_iterator) {
-               status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INIT_METHOD_STATUS_MEMORY_ERROR;
+       msg_iter_status = bt_self_component_port_input_message_iterator_create_from_message_iterator(
+               self_msg_iter, input_port, &upstream_iterator);
+       if (msg_iter_status != BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_CREATE_FROM_MESSAGE_ITERATOR_STATUS_OK) {
+               status = (int) msg_iter_status;
                goto error;
        }
 
@@ -2005,7 +2008,7 @@ bt_component_class_message_iterator_init_method_status debug_info_msg_iter_init(
                g_direct_hash, g_direct_equal, (GDestroyNotify) NULL,
                (GDestroyNotify) debug_info_destroy);
        if (!debug_info_msg_iter->debug_info_map) {
-               status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INIT_METHOD_STATUS_MEMORY_ERROR;
+               status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INITIALIZE_METHOD_STATUS_MEMORY_ERROR;
                goto error;
        }
 
@@ -2018,19 +2021,24 @@ bt_component_class_message_iterator_init_method_status debug_info_msg_iter_init(
        debug_info_msg_iter->ir_maps = trace_ir_maps_create(self_comp,
                debug_info_field_name, log_level);
        if (!debug_info_msg_iter->ir_maps) {
-               status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INIT_METHOD_STATUS_MEMORY_ERROR;
+               status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INITIALIZE_METHOD_STATUS_MEMORY_ERROR;
                goto error;
        }
 
        ret = bt_fd_cache_init(&debug_info_msg_iter->fd_cache, log_level);
        if (ret) {
-               status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INIT_METHOD_STATUS_MEMORY_ERROR;
+               status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INITIALIZE_METHOD_STATUS_MEMORY_ERROR;
                goto error;
        }
 
+       bt_self_message_iterator_configuration_set_can_seek_forward(config,
+               bt_self_component_port_input_message_iterator_can_seek_forward(
+                       debug_info_msg_iter->msg_iter));
+
        bt_self_message_iterator_set_data(self_msg_iter, debug_info_msg_iter);
        debug_info_msg_iter->input_iterator = self_msg_iter;
 
+       status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INITIALIZE_METHOD_STATUS_OK;
        goto end;
 
 error:
@@ -2041,15 +2049,16 @@ end:
 }
 
 BT_HIDDEN
-bt_bool debug_info_msg_iter_can_seek_beginning(
-               bt_self_message_iterator *self_msg_iter)
+bt_component_class_message_iterator_can_seek_beginning_method_status
+debug_info_msg_iter_can_seek_beginning(
+       bt_self_message_iterator *self_msg_iter, bt_bool *can_seek)
 {
        struct debug_info_msg_iter *debug_info_msg_iter =
                bt_self_message_iterator_get_data(self_msg_iter);
        BT_ASSERT(debug_info_msg_iter);
 
-       return bt_self_component_port_input_message_iterator_can_seek_beginning(
-                       debug_info_msg_iter->msg_iter);
+       return (int) bt_self_component_port_input_message_iterator_can_seek_beginning(
+               debug_info_msg_iter->msg_iter, can_seek);
 }
 
 BT_HIDDEN
This page took 0.025814 seconds and 4 git commands to generate.