lib: graph: add "self" and some "private" APIs
[babeltrace.git] / plugins / utils / dummy / dummy.c
index 31d1b70db2d83b2ec41c1b933968631ee8bcebda..b3178416bfd8f692edd125bbe2419b53240c38b3 100644 (file)
@@ -30,40 +30,42 @@ void destroy_private_dummy_data(struct dummy *dummy)
 {
        bt_object_put_ref(dummy->notif_iter);
        g_free(dummy);
+
 }
 
-void dummy_finalize(struct bt_private_component *component)
+BT_HIDDEN
+void dummy_finalize(struct bt_self_component_sink *comp)
 {
        struct dummy *dummy;
 
-       BT_ASSERT(component);
-       dummy = bt_private_component_get_user_data(component);
+       BT_ASSERT(comp);
+       dummy = bt_self_component_get_data(
+                       bt_self_component_sink_borrow_self_component(comp));
        BT_ASSERT(dummy);
        destroy_private_dummy_data(dummy);
 }
 
-enum bt_component_status dummy_init(struct bt_private_component *component,
+BT_HIDDEN
+enum bt_self_component_status dummy_init(
+               struct bt_self_component_sink *component,
                struct bt_value *params, UNUSED_VAR void *init_method_data)
 {
-       enum bt_component_status ret;
+       enum bt_self_component_status ret;
        struct dummy *dummy = g_new0(struct dummy, 1);
 
        if (!dummy) {
-               ret = BT_COMPONENT_STATUS_NOMEM;
+               ret = BT_SELF_COMPONENT_STATUS_NOMEM;
                goto end;
        }
 
-       ret = bt_private_component_sink_add_input_port(component,
+       ret = bt_self_component_sink_add_input_port(component,
                "in", NULL, NULL);
-       if (ret != BT_COMPONENT_STATUS_OK) {
-               goto end;
-       }
-
-       ret = bt_private_component_set_user_data(component, dummy);
-       if (ret != BT_COMPONENT_STATUS_OK) {
+       if (ret != BT_SELF_COMPONENT_STATUS_OK) {
                goto error;
        }
 
+       bt_self_component_set_data(
+               bt_self_component_sink_borrow_self_component(component), dummy);
        goto end;
 
 error:
@@ -73,58 +75,58 @@ end:
        return ret;
 }
 
-enum bt_component_status dummy_port_connected(
-               struct bt_private_component *component,
-               struct bt_private_port *self_port,
-               struct bt_port *other_port)
+BT_HIDDEN
+enum bt_self_component_status dummy_port_connected(
+               struct bt_self_component_sink *comp,
+               struct bt_self_component_port_input *self_port,
+               struct bt_port_output *other_port)
 {
-       enum bt_component_status status = BT_COMPONENT_STATUS_OK;
+       enum bt_self_component_status status = BT_SELF_COMPONENT_STATUS_OK;
        struct dummy *dummy;
-       struct bt_notification_iterator *iterator;
-       struct bt_private_connection *connection;
-       enum bt_connection_status conn_status;
+       struct bt_self_component_port_input_notification_iterator *iterator;
 
-       dummy = bt_private_component_get_user_data(component);
+       dummy = bt_self_component_get_data(
+               bt_self_component_sink_borrow_self_component(comp));
        BT_ASSERT(dummy);
-       connection = bt_private_port_get_connection(self_port);
-       BT_ASSERT(connection);
-       conn_status = bt_private_connection_create_notification_iterator(
-               connection, &iterator);
-       if (conn_status != BT_CONNECTION_STATUS_OK) {
-               status = BT_COMPONENT_STATUS_ERROR;
+       iterator = bt_self_component_port_input_notification_iterator_create(
+               self_port);
+       if (!iterator) {
+               status = BT_SELF_COMPONENT_STATUS_NOMEM;
                goto end;
        }
 
        BT_OBJECT_MOVE_REF(dummy->notif_iter, iterator);
 
 end:
-       bt_object_put_ref(connection);
        return status;
 }
 
-enum bt_component_status dummy_consume(struct bt_private_component *component)
+BT_HIDDEN
+enum bt_self_component_status dummy_consume(
+               struct bt_self_component_sink *component)
 {
-       enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
+       enum bt_self_component_status ret = BT_SELF_COMPONENT_STATUS_OK;
        bt_notification_array notifs;
        uint64_t count;
        struct dummy *dummy;
        enum bt_notification_iterator_status it_ret;
        uint64_t i;
 
-       dummy = bt_private_component_get_user_data(component);
+       dummy = bt_self_component_get_data(
+               bt_self_component_sink_borrow_self_component(component));
        BT_ASSERT(dummy);
 
        if (unlikely(!dummy->notif_iter)) {
-               ret = BT_COMPONENT_STATUS_END;
+               ret = BT_SELF_COMPONENT_STATUS_END;
                goto end;
        }
 
        /* Consume one notification  */
-       it_ret = bt_private_connection_notification_iterator_next(
+       it_ret = bt_self_component_port_input_notification_iterator_next(
                dummy->notif_iter, &notifs, &count);
        switch (it_ret) {
        case BT_NOTIFICATION_ITERATOR_STATUS_OK:
-               ret = BT_COMPONENT_STATUS_OK;
+               ret = BT_SELF_COMPONENT_STATUS_OK;
 
                for (i = 0; i < count; i++) {
                        bt_object_put_ref(notifs[i]);
@@ -132,13 +134,16 @@ enum bt_component_status dummy_consume(struct bt_private_component *component)
 
                break;
        case BT_NOTIFICATION_ITERATOR_STATUS_AGAIN:
-               ret = BT_COMPONENT_STATUS_AGAIN;
+               ret = BT_SELF_COMPONENT_STATUS_AGAIN;
                goto end;
        case BT_NOTIFICATION_ITERATOR_STATUS_END:
-               ret = BT_COMPONENT_STATUS_END;
+               ret = BT_SELF_COMPONENT_STATUS_END;
                goto end;
        case BT_NOTIFICATION_ITERATOR_STATUS_ERROR:
-               ret = BT_COMPONENT_STATUS_ERROR;
+               ret = BT_SELF_COMPONENT_STATUS_ERROR;
+               goto end;
+       case BT_NOTIFICATION_ITERATOR_STATUS_NOMEM:
+               ret = BT_SELF_COMPONENT_STATUS_NOMEM;
                goto end;
        default:
                break;
This page took 0.025157 seconds and 4 git commands to generate.