lib: add aliases for Babeltrace structure types
[babeltrace.git] / plugins / utils / muxer / muxer.c
index ac48ceaefe5a392a4afebfe7429dd2d87aa0565b..9aa69223dc8bdf9d44a06827bce090f250da7810 100644 (file)
@@ -26,7 +26,7 @@
 #include <babeltrace/babeltrace-internal.h>
 #include <babeltrace/compat/uuid-internal.h>
 #include <babeltrace/babeltrace.h>
-#include <babeltrace/values-internal.h>
+#include <babeltrace/value-internal.h>
 #include <babeltrace/graph/component-internal.h>
 #include <babeltrace/graph/notification-iterator-internal.h>
 #include <babeltrace/graph/connection-internal.h>
@@ -50,7 +50,7 @@ struct muxer_comp {
        GPtrArray *muxer_notif_iters;
 
        /* Weak ref */
-       struct bt_self_component_filter *self_comp;
+       bt_self_component_filter *self_comp;
 
        unsigned int next_port_num;
        size_t available_input_ports;
@@ -60,9 +60,9 @@ struct muxer_comp {
 
 struct muxer_upstream_notif_iter {
        /* Owned by this, NULL if ended */
-       struct bt_self_component_port_input_notification_iterator *notif_iter;
+       bt_self_component_port_input_notification_iterator *notif_iter;
 
-       /* Contains `struct bt_notification *`, owned by this */
+       /* Contains `const bt_notification *`, owned by this */
        GQueue *notifs;
 };
 
@@ -122,14 +122,14 @@ void destroy_muxer_upstream_notif_iter(
                muxer_upstream_notif_iter,
                muxer_upstream_notif_iter->notif_iter,
                muxer_upstream_notif_iter->notifs->length);
-       bt_object_put_ref(muxer_upstream_notif_iter->notif_iter);
+       bt_self_component_port_input_notification_iterator_put_ref(muxer_upstream_notif_iter->notif_iter);
 
        if (muxer_upstream_notif_iter->notifs) {
-               struct bt_notification *notif;
+               const bt_notification *notif;
 
                while ((notif = g_queue_pop_head(
                                muxer_upstream_notif_iter->notifs))) {
-                       bt_object_put_ref(notif);
+                       bt_notification_put_ref(notif);
                }
 
                g_queue_free(muxer_upstream_notif_iter->notifs);
@@ -141,7 +141,7 @@ void destroy_muxer_upstream_notif_iter(
 static
 struct muxer_upstream_notif_iter *muxer_notif_iter_add_upstream_notif_iter(
                struct muxer_notif_iter *muxer_notif_iter,
-               struct bt_self_component_port_input_notification_iterator *self_notif_iter)
+               bt_self_component_port_input_notification_iterator *self_notif_iter)
 {
        struct muxer_upstream_notif_iter *muxer_upstream_notif_iter =
                g_new0(struct muxer_upstream_notif_iter, 1);
@@ -151,7 +151,8 @@ struct muxer_upstream_notif_iter *muxer_notif_iter_add_upstream_notif_iter(
                goto end;
        }
 
-       muxer_upstream_notif_iter->notif_iter = bt_object_get_ref(self_notif_iter);
+       muxer_upstream_notif_iter->notif_iter = self_notif_iter;
+       bt_self_component_port_input_notification_iterator_get_ref(muxer_upstream_notif_iter->notif_iter);
        muxer_upstream_notif_iter->notifs = g_queue_new();
        if (!muxer_upstream_notif_iter->notifs) {
                BT_LOGE_STR("Failed to allocate a GQueue.");
@@ -171,10 +172,10 @@ end:
 
 static
 enum bt_self_component_status ensure_available_input_port(
-               struct bt_self_component_filter *self_comp)
+               bt_self_component_filter *self_comp)
 {
        struct muxer_comp *muxer_comp = bt_self_component_get_data(
-               bt_self_component_filter_borrow_self_component(self_comp));
+               bt_self_component_filter_as_self_component(self_comp));
        enum bt_self_component_status status = BT_SELF_COMPONENT_STATUS_OK;
        GString *port_name = NULL;
 
@@ -217,7 +218,7 @@ end:
 
 static
 enum bt_self_component_status create_output_port(
-               struct bt_self_component_filter *self_comp)
+               bt_self_component_filter *self_comp)
 {
        return bt_self_component_filter_add_output_port(
                self_comp, "out", NULL, NULL);
@@ -243,18 +244,18 @@ void destroy_muxer_comp(struct muxer_comp *muxer_comp)
 }
 
 static
-struct bt_private_value *get_default_params(void)
+bt_value *get_default_params(void)
 {
-       struct bt_private_value *params;
+       bt_value *params;
        int ret;
 
-       params = bt_private_value_map_create();
+       params = bt_value_map_create();
        if (!params) {
                BT_LOGE_STR("Cannot create a map value object.");
                goto error;
        }
 
-       ret = bt_private_value_map_insert_bool_entry(params,
+       ret = bt_value_map_insert_bool_entry(params,
                ASSUME_ABSOLUTE_CLOCK_CLASSES_PARAM_NAME, false);
        if (ret) {
                BT_LOGE_STR("Cannot add boolean value to map value object.");
@@ -264,18 +265,19 @@ struct bt_private_value *get_default_params(void)
        goto end;
 
 error:
-       BT_OBJECT_PUT_REF_AND_RESET(params);
+       BT_VALUE_PUT_REF_AND_RESET(params);
 
 end:
        return params;
 }
 
 static
-int configure_muxer_comp(struct muxer_comp *muxer_comp, struct bt_value *params)
+int configure_muxer_comp(struct muxer_comp *muxer_comp,
+               const bt_value *params)
 {
-       struct bt_private_value *default_params = NULL;
-       struct bt_private_value *real_params = NULL;
-       struct bt_value *assume_absolute_clock_classes = NULL;
+       bt_value *default_params = NULL;
+       bt_value *real_params = NULL;
+       const bt_value *assume_absolute_clock_classes = NULL;
        int ret = 0;
        bt_bool bool_val;
 
@@ -286,8 +288,7 @@ int configure_muxer_comp(struct muxer_comp *muxer_comp, struct bt_value *params)
                goto error;
        }
 
-       ret = bt_value_map_extend(&real_params,
-               bt_private_value_borrow_value(default_params), params);
+       ret = bt_value_map_extend(default_params, params, &real_params);
        if (ret) {
                BT_LOGE("Cannot extend default parameters map value: "
                        "muxer-comp-addr=%p, def-params-addr=%p, "
@@ -296,9 +297,8 @@ int configure_muxer_comp(struct muxer_comp *muxer_comp, struct bt_value *params)
                goto error;
        }
 
-       assume_absolute_clock_classes = bt_value_map_borrow_entry_value(
-               bt_private_value_borrow_value(real_params),
-               ASSUME_ABSOLUTE_CLOCK_CLASSES_PARAM_NAME);
+       assume_absolute_clock_classes = bt_value_map_borrow_entry_value(real_params,
+                                                                       ASSUME_ABSOLUTE_CLOCK_CLASSES_PARAM_NAME);
        if (assume_absolute_clock_classes &&
                        !bt_value_is_bool(assume_absolute_clock_classes)) {
                BT_LOGE("Expecting a boolean value for the `%s` parameter: "
@@ -320,15 +320,15 @@ error:
        ret = -1;
 
 end:
-       bt_object_put_ref(default_params);
-       bt_object_put_ref(real_params);
+       bt_value_put_ref(default_params);
+       bt_value_put_ref(real_params);
        return ret;
 }
 
 BT_HIDDEN
 enum bt_self_component_status muxer_init(
-               struct bt_self_component_filter *self_comp,
-               struct bt_value *params, void *init_data)
+               bt_self_component_filter *self_comp,
+               bt_value *params, void *init_data)
 {
        int ret;
        enum bt_self_component_status status = BT_SELF_COMPONENT_STATUS_OK;
@@ -358,7 +358,7 @@ enum bt_self_component_status muxer_init(
 
        muxer_comp->self_comp = self_comp;
        bt_self_component_set_data(
-               bt_self_component_filter_borrow_self_component(self_comp),
+               bt_self_component_filter_as_self_component(self_comp),
                muxer_comp);
        status = ensure_available_input_port(self_comp);
        if (status != BT_SELF_COMPONENT_STATUS_OK) {
@@ -387,7 +387,7 @@ enum bt_self_component_status muxer_init(
 error:
        destroy_muxer_comp(muxer_comp);
        bt_self_component_set_data(
-               bt_self_component_filter_borrow_self_component(self_comp),
+               bt_self_component_filter_as_self_component(self_comp),
                NULL);
 
        if (status == BT_SELF_COMPONENT_STATUS_OK) {
@@ -399,10 +399,10 @@ end:
 }
 
 BT_HIDDEN
-void muxer_finalize(struct bt_self_component_filter *self_comp)
+void muxer_finalize(bt_self_component_filter *self_comp)
 {
        struct muxer_comp *muxer_comp = bt_self_component_get_data(
-               bt_self_component_filter_borrow_self_component(self_comp));
+               bt_self_component_filter_as_self_component(self_comp));
 
        BT_LOGD("Finalizing muxer component: comp-addr=%p",
                self_comp);
@@ -410,14 +410,14 @@ void muxer_finalize(struct bt_self_component_filter *self_comp)
 }
 
 static
-struct bt_self_component_port_input_notification_iterator *
+bt_self_component_port_input_notification_iterator *
 create_notif_iter_on_input_port(
-               struct bt_self_component_port_input *self_port, int *ret)
+               bt_self_component_port_input *self_port, int *ret)
 {
-       struct bt_port *port = bt_self_component_port_borrow_port(
-               bt_self_component_port_input_borrow_self_component_port(
+       const bt_port *port = bt_self_component_port_as_port(
+               bt_self_component_port_input_as_self_component_port(
                        self_port));
-       struct bt_self_component_port_input_notification_iterator *notif_iter =
+       bt_self_component_port_input_notification_iterator *notif_iter =
                NULL;
 
        BT_ASSERT(ret);
@@ -451,7 +451,7 @@ enum bt_notification_iterator_status muxer_upstream_notif_iter_next(
                struct muxer_upstream_notif_iter *muxer_upstream_notif_iter)
 {
        enum bt_notification_iterator_status status;
-       bt_notification_array notifs;
+       bt_notification_array_const notifs;
        uint64_t i;
        uint64_t count;
 
@@ -481,7 +481,7 @@ enum bt_notification_iterator_status muxer_upstream_notif_iter_next(
                         * from the head first.
                         */
                        g_queue_push_tail(muxer_upstream_notif_iter->notifs,
-                               notifs[i]);
+                               (void *) notifs[i]);
                }
                break;
        case BT_NOTIFICATION_ITERATOR_STATUS_AGAIN:
@@ -498,7 +498,7 @@ enum bt_notification_iterator_status muxer_upstream_notif_iter_next(
                 * won't be considered again to find the youngest
                 * notification.
                 */
-               BT_OBJECT_PUT_REF_AND_RESET(muxer_upstream_notif_iter->notif_iter);
+               BT_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_PUT_REF_AND_RESET(muxer_upstream_notif_iter->notif_iter);
                status = BT_NOTIFICATION_ITERATOR_STATUS_OK;
                break;
        default:
@@ -531,9 +531,9 @@ int muxer_notif_iter_handle_newly_connected_ports(
         */
        while (true) {
                GList *node = muxer_notif_iter->newly_connected_self_ports;
-               struct bt_self_component_port_input *self_port;
-               struct bt_port *port;
-               struct bt_self_component_port_input_notification_iterator *
+               bt_self_component_port_input *self_port;
+               const bt_port *port;
+               bt_self_component_port_input_notification_iterator *
                        upstream_notif_iter = NULL;
                struct muxer_upstream_notif_iter *muxer_upstream_notif_iter;
 
@@ -542,8 +542,8 @@ int muxer_notif_iter_handle_newly_connected_ports(
                }
 
                self_port = node->data;
-               port = bt_self_component_port_borrow_port(
-                       bt_self_component_port_input_borrow_self_component_port(
+               port = bt_self_component_port_as_port(
+                       bt_self_component_port_input_as_self_component_port(
                                (self_port)));
                BT_ASSERT(port);
 
@@ -568,7 +568,7 @@ int muxer_notif_iter_handle_newly_connected_ports(
                muxer_upstream_notif_iter =
                        muxer_notif_iter_add_upstream_notif_iter(
                                muxer_notif_iter, upstream_notif_iter);
-               BT_OBJECT_PUT_REF_AND_RESET(upstream_notif_iter);
+               BT_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_PUT_REF_AND_RESET(upstream_notif_iter);
                if (!muxer_upstream_notif_iter) {
                        /*
                         * muxer_notif_iter_add_upstream_notif_iter()
@@ -578,7 +578,7 @@ int muxer_notif_iter_handle_newly_connected_ports(
                }
 
 remove_node:
-               bt_object_put_ref(upstream_notif_iter);
+               bt_self_component_port_input_notification_iterator_put_ref(upstream_notif_iter);
                muxer_notif_iter->newly_connected_self_ports =
                        g_list_delete_link(
                                muxer_notif_iter->newly_connected_self_ports,
@@ -599,12 +599,12 @@ end:
 static
 int get_notif_ts_ns(struct muxer_comp *muxer_comp,
                struct muxer_notif_iter *muxer_notif_iter,
-               struct bt_notification *notif, int64_t last_returned_ts_ns,
+               const bt_notification *notif, int64_t last_returned_ts_ns,
                int64_t *ts_ns)
 {
-       struct bt_clock_class *clock_class = NULL;
-       struct bt_clock_value *clock_value = NULL;
-       struct bt_event *event = NULL;
+       const bt_clock_class *clock_class = NULL;
+       const bt_clock_value *clock_value = NULL;
+       const bt_event *event = NULL;
        int ret = 0;
        const unsigned char *cc_uuid;
        const char *cc_name;
@@ -620,15 +620,15 @@ int get_notif_ts_ns(struct muxer_comp *muxer_comp,
 
        switch (bt_notification_get_type(notif)) {
        case BT_NOTIFICATION_TYPE_EVENT:
-               event = bt_notification_event_borrow_event(notif);
+               event = bt_notification_event_borrow_event_const(notif);
                BT_ASSERT(event);
-               cv_status = bt_event_borrow_default_clock_value(event,
+               cv_status = bt_event_borrow_default_clock_value_const(event,
                        &clock_value);
                break;
 
        case BT_NOTIFICATION_TYPE_INACTIVITY:
                clock_value =
-                       bt_notification_inactivity_borrow_default_clock_value(
+                       bt_notification_inactivity_borrow_default_clock_value_const(
                                notif);
                break;
        default:
@@ -656,7 +656,7 @@ int get_notif_ts_ns(struct muxer_comp *muxer_comp,
                goto end;
        }
 
-       clock_class = bt_clock_value_borrow_clock_class(clock_value);
+       clock_class = bt_clock_value_borrow_clock_class_const(clock_value);
        BT_ASSERT(clock_class);
        cc_uuid = bt_clock_class_get_uuid(clock_class);
        cc_name = bt_clock_class_get_name(clock_class);
@@ -870,7 +870,7 @@ muxer_notif_iter_youngest_upstream_notif_iter(
        *muxer_upstream_notif_iter = NULL;
 
        for (i = 0; i < muxer_notif_iter->muxer_upstream_notif_iters->len; i++) {
-               struct bt_notification *notif;
+               const bt_notification *notif;
                struct muxer_upstream_notif_iter *cur_muxer_upstream_notif_iter =
                        g_ptr_array_index(muxer_notif_iter->muxer_upstream_notif_iters, i);
                int64_t notif_ts_ns;
@@ -1004,7 +1004,7 @@ static inline
 enum bt_notification_iterator_status muxer_notif_iter_do_next_one(
                struct muxer_comp *muxer_comp,
                struct muxer_notif_iter *muxer_notif_iter,
-               struct bt_notification **notif)
+               const bt_notification **notif)
 {
        enum bt_notification_iterator_status status =
                BT_NOTIFICATION_ITERATOR_STATUS_OK;
@@ -1105,7 +1105,7 @@ static
 enum bt_notification_iterator_status muxer_notif_iter_do_next(
                struct muxer_comp *muxer_comp,
                struct muxer_notif_iter *muxer_notif_iter,
-               bt_notification_array notifs, uint64_t capacity,
+               bt_notification_array_const notifs, uint64_t capacity,
                uint64_t *count)
 {
        enum bt_notification_iterator_status status =
@@ -1174,7 +1174,7 @@ int muxer_notif_iter_init_newly_connected_ports(struct muxer_comp *muxer_comp,
         * handled by muxer_notif_iter_handle_newly_connected_ports().
         */
        count = bt_component_filter_get_input_port_count(
-               bt_self_component_filter_borrow_component_filter(
+               bt_self_component_filter_as_component_filter(
                        muxer_comp->self_comp));
        if (count < 0) {
                BT_LOGD("No input port to initialize for muxer component's notification iterator: "
@@ -1184,14 +1184,14 @@ int muxer_notif_iter_init_newly_connected_ports(struct muxer_comp *muxer_comp,
        }
 
        for (i = 0; i < count; i++) {
-               struct bt_self_component_port_input *self_port =
+               bt_self_component_port_input *self_port =
                        bt_self_component_filter_borrow_input_port_by_index(
                                muxer_comp->self_comp, i);
-               struct bt_port *port;
+               const bt_port *port;
 
                BT_ASSERT(self_port);
-               port = bt_self_component_port_borrow_port(
-                       bt_self_component_port_input_borrow_self_component_port(
+               port = bt_self_component_port_as_port(
+                       bt_self_component_port_input_as_self_component_port(
                                self_port));
                BT_ASSERT(port);
 
@@ -1227,9 +1227,9 @@ end:
 
 BT_HIDDEN
 enum bt_self_notification_iterator_status muxer_notif_iter_init(
-               struct bt_self_notification_iterator *self_notif_iter,
-               struct bt_self_component_filter *self_comp,
-               struct bt_self_component_port_output *port)
+               bt_self_notification_iterator *self_notif_iter,
+               bt_self_component_filter *self_comp,
+               bt_self_component_port_output *port)
 {
        struct muxer_comp *muxer_comp = NULL;
        struct muxer_notif_iter *muxer_notif_iter = NULL;
@@ -1238,7 +1238,7 @@ enum bt_self_notification_iterator_status muxer_notif_iter_init(
        int ret;
 
        muxer_comp = bt_self_component_get_data(
-               bt_self_component_filter_borrow_self_component(self_comp));
+               bt_self_component_filter_as_self_component(self_comp));
        BT_ASSERT(muxer_comp);
        BT_LOGD("Initializing muxer component's notification iterator: "
                "comp-addr=%p, muxer-comp-addr=%p, notif-iter-addr=%p",
@@ -1319,11 +1319,11 @@ end:
 
 BT_HIDDEN
 void muxer_notif_iter_finalize(
-               struct bt_self_notification_iterator *self_notif_iter)
+               bt_self_notification_iterator *self_notif_iter)
 {
        struct muxer_notif_iter *muxer_notif_iter =
                bt_self_notification_iterator_get_data(self_notif_iter);
-       struct bt_self_component *self_comp = NULL;
+       bt_self_component *self_comp = NULL;
        struct muxer_comp *muxer_comp = NULL;
 
        self_comp = bt_self_notification_iterator_borrow_component(
@@ -1344,14 +1344,14 @@ void muxer_notif_iter_finalize(
 
 BT_HIDDEN
 enum bt_notification_iterator_status muxer_notif_iter_next(
-               struct bt_self_notification_iterator *self_notif_iter,
-               bt_notification_array notifs, uint64_t capacity,
+               bt_self_notification_iterator *self_notif_iter,
+               bt_notification_array_const notifs, uint64_t capacity,
                uint64_t *count)
 {
        enum bt_notification_iterator_status status;
        struct muxer_notif_iter *muxer_notif_iter =
                bt_self_notification_iterator_get_data(self_notif_iter);
-       struct bt_self_component *self_comp = NULL;
+       bt_self_component *self_comp = NULL;
        struct muxer_comp *muxer_comp = NULL;
 
        BT_ASSERT(muxer_notif_iter);
@@ -1384,17 +1384,17 @@ enum bt_notification_iterator_status muxer_notif_iter_next(
 
 BT_HIDDEN
 enum bt_self_component_status muxer_input_port_connected(
-               struct bt_self_component_filter *self_comp,
-               struct bt_self_component_port_input *self_port,
-               struct bt_port_output *other_port)
+               bt_self_component_filter *self_comp,
+               bt_self_component_port_input *self_port,
+               const bt_port_output *other_port)
 {
        enum bt_self_component_status status = BT_SELF_COMPONENT_STATUS_OK;
-       struct bt_port *port = bt_self_component_port_borrow_port(
-               bt_self_component_port_input_borrow_self_component_port(
+       const bt_port *port = bt_self_component_port_as_port(
+               bt_self_component_port_input_as_self_component_port(
                        self_port));
        struct muxer_comp *muxer_comp =
                bt_self_component_get_data(
-                       bt_self_component_filter_borrow_self_component(
+                       bt_self_component_filter_as_self_component(
                                self_comp));
        size_t i;
        int ret;
@@ -1407,7 +1407,7 @@ enum bt_self_component_status muxer_input_port_connected(
                "other-port-addr=%p, other-port-name=\"%s\"",
                self_comp, muxer_comp, self_port, bt_port_get_name(port),
                other_port,
-               bt_port_get_name(bt_port_output_borrow_port(other_port)));
+               bt_port_get_name(bt_port_output_as_port_const(other_port)));
 
        for (i = 0; i < muxer_comp->muxer_notif_iters->len; i++) {
                struct muxer_notif_iter *muxer_notif_iter =
@@ -1460,16 +1460,16 @@ end:
 
 BT_HIDDEN
 void muxer_input_port_disconnected(
-               struct bt_self_component_filter *self_component,
-               struct bt_self_component_port_input *self_port)
+               bt_self_component_filter *self_component,
+               bt_self_component_port_input *self_port)
 {
        struct muxer_comp *muxer_comp =
                bt_self_component_get_data(
-                       bt_self_component_filter_borrow_self_component(
+                       bt_self_component_filter_as_self_component(
                                self_component));
-       struct bt_port *port =
-               bt_self_component_port_borrow_port(
-                       bt_self_component_port_input_borrow_self_component_port(
+       const bt_port *port =
+               bt_self_component_port_as_port(
+                       bt_self_component_port_input_as_self_component_port(
                                self_port));
 
        BT_ASSERT(port);
This page took 0.033103 seconds and 4 git commands to generate.