X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=plugins%2Fwriter%2Fwriter.c;h=8f1d2fc1942eec526cb457a5954cbf5a635eec46;hb=b2e0c9076135f47110af2d96dfaee397c597bc90;hp=320642f9a73d6058b368217940c74752138f5d58;hpb=d71dcf2c09c27291afa19a40eb99cc3556842e99;p=babeltrace.git diff --git a/plugins/writer/writer.c b/plugins/writer/writer.c index 320642f9..8f1d2fc1 100644 --- a/plugins/writer/writer.c +++ b/plugins/writer/writer.c @@ -28,20 +28,27 @@ #include #include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include #include "writer.h" +#include static void destroy_writer_component_data(struct writer_component *writer_component) { + bt_put(writer_component->input_iterator); g_hash_table_destroy(writer_component->stream_map); g_hash_table_destroy(writer_component->stream_class_map); g_hash_table_destroy(writer_component->trace_map); @@ -50,10 +57,10 @@ void destroy_writer_component_data(struct writer_component *writer_component) } static -void destroy_writer_component(struct bt_component *component) +void finalize_writer_component(struct bt_private_component *component) { struct writer_component *writer_component = (struct writer_component *) - bt_component_get_private_data(component); + bt_private_component_get_user_data(component); destroy_writer_component_data(writer_component); g_free(writer_component); @@ -180,18 +187,42 @@ end: } static -enum bt_component_status run(struct bt_component *component) +enum bt_component_status writer_component_accept_port_connection( + struct bt_private_component *component, + struct bt_private_port *self_port, + struct bt_port *other_port) +{ + enum bt_component_status ret = BT_COMPONENT_STATUS_OK; + struct bt_private_connection *connection; + struct writer_component *writer; + + writer = bt_private_component_get_user_data(component); + assert(writer); + assert(!writer->input_iterator); + connection = bt_private_port_get_private_connection(self_port); + assert(connection); + writer->input_iterator = + bt_private_connection_create_notification_iterator(connection); + + if (!writer->input_iterator) { + ret = BT_COMPONENT_STATUS_ERROR; + } + bt_put(connection); + return ret; +} + +static +enum bt_component_status run(struct bt_private_component *component) { enum bt_component_status ret; + enum bt_notification_iterator_status it_status; struct bt_notification *notification = NULL; struct bt_notification_iterator *it; struct writer_component *writer_component = - bt_component_get_private_data(component); + bt_private_component_get_user_data(component); - ret = bt_component_sink_get_input_iterator(component, 0, &it); - if (ret != BT_COMPONENT_STATUS_OK) { - goto end; - } + it = writer_component->input_iterator; + assert(it); notification = bt_notification_iterator_get_notification(it); if (!notification) { @@ -199,8 +230,9 @@ enum bt_component_status run(struct bt_component *component) goto end; } - ret = bt_notification_iterator_next(it); - if (ret != BT_COMPONENT_STATUS_OK) { + it_status = bt_notification_iterator_next(it); + if (it_status != BT_COMPONENT_STATUS_OK) { + ret = BT_COMPONENT_STATUS_ERROR; goto end; } @@ -213,7 +245,8 @@ end: static enum bt_component_status writer_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; enum bt_value_status value_ret; @@ -246,7 +279,7 @@ enum bt_component_status writer_component_init( goto error; } - ret = bt_component_set_private_data(component, writer_component); + ret = bt_private_component_set_user_data(component, writer_component); if (ret != BT_COMPONENT_STATUS_OK) { goto error; } @@ -266,5 +299,7 @@ BT_PLUGIN_AUTHOR("Jérémie Galarneau"); BT_PLUGIN_LICENSE("MIT"); BT_PLUGIN_SINK_COMPONENT_CLASS(writer, run); BT_PLUGIN_SINK_COMPONENT_CLASS_INIT_METHOD(writer, writer_component_init); -BT_PLUGIN_SINK_COMPONENT_CLASS_DESTROY_METHOD(writer, destroy_writer_component); +BT_PLUGIN_SINK_COMPONENT_CLASS_ACCEPT_PORT_CONNECTION_METHOD(writer, + writer_component_accept_port_connection); +BT_PLUGIN_SINK_COMPONENT_CLASS_FINALIZE_METHOD(writer, finalize_writer_component); BT_PLUGIN_SINK_COMPONENT_CLASS_DESCRIPTION(writer, "Formats CTF-IR to CTF.");