Remove default port API
[babeltrace.git] / plugins / utils / trimmer / trimmer.c
index af838d723e8adfbed3b938e6e4662f5e3d57ef8c..8ec1332fb0b09f2e9935df6c421d0d13448ff314 100644 (file)
  */
 
 #include <babeltrace/plugin/plugin-dev.h>
-#include <babeltrace/component/component.h>
-#include <babeltrace/component/component-filter.h>
-#include <babeltrace/component/notification/notification.h>
-#include <babeltrace/component/notification/iterator.h>
-#include <babeltrace/component/notification/event.h>
+#include <babeltrace/graph/component.h>
+#include <babeltrace/graph/private-component.h>
+#include <babeltrace/graph/component-filter.h>
+#include <babeltrace/graph/notification.h>
+#include <babeltrace/graph/notification-iterator.h>
+#include <babeltrace/graph/private-notification-iterator.h>
+#include <babeltrace/graph/private-component-filter.h>
+#include <babeltrace/graph/notification-event.h>
 #include <plugins-common.h>
 #include "trimmer.h"
 #include "iterator.h"
@@ -56,9 +59,9 @@ end:
        return trimmer;
 }
 
-void destroy_trimmer(struct bt_component *component)
+void finalize_trimmer(struct bt_private_component *component)
 {
-       void *data = bt_component_get_private_data(component);
+       void *data = bt_private_component_get_user_data(component);
 
        destroy_trimmer_data(data);
 }
@@ -285,7 +288,8 @@ lazy:
 }
 
 static
-enum bt_component_status init_from_params(struct trimmer *trimmer, struct bt_value *params)
+enum bt_component_status init_from_params(struct trimmer *trimmer,
+               struct bt_value *params)
 {
        struct bt_value *value = NULL;
        bool gmt = false;
@@ -349,26 +353,43 @@ end:
 }
 
 enum bt_component_status trimmer_component_init(
-       struct bt_component *component, struct bt_value *params,
+       struct bt_private_component *component, struct bt_value *params,
        UNUSED_VAR void *init_method_data)
 {
        enum bt_component_status ret;
        struct trimmer *trimmer = create_trimmer_data();
+       struct bt_private_port *priv_port = NULL;
 
        if (!trimmer) {
                ret = BT_COMPONENT_STATUS_NOMEM;
                goto end;
        }
 
-       ret = bt_component_set_private_data(component, trimmer);
+       /* Create input and output ports */
+       priv_port = bt_private_component_filter_add_input_private_port(
+               component, "in", NULL);
+       if (!priv_port) {
+               goto error;
+       }
+
+       bt_put(priv_port);
+       priv_port = bt_private_component_filter_add_output_private_port(
+               component, "out", NULL);
+       if (!priv_port) {
+               goto error;
+       }
+
+       ret = bt_private_component_set_user_data(component, trimmer);
        if (ret != BT_COMPONENT_STATUS_OK) {
                goto error;
        }
 
        ret = init_from_params(trimmer, params);
 end:
+       bt_put(priv_port);
        return ret;
 error:
        destroy_trimmer_data(trimmer);
+       ret = BT_COMPONENT_STATUS_ERROR;
        return ret;
 }
This page took 0.025468 seconds and 4 git commands to generate.