X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=src%2Flib%2Fgraph%2Fcomponent-class-sink-colander.c;h=b68a3ab0461074cc71f26b456671b4688697ad42;hb=d24d56638469189904fb6ddbb3c725817b3e9417;hp=667b997c3189e5423aae0b59502c470856ea0e2d;hpb=578e048b5debf169e286e5b5cc747b5d6c16886d;p=babeltrace.git diff --git a/src/lib/graph/component-class-sink-colander.c b/src/lib/graph/component-class-sink-colander.c index 667b997c..b68a3ab0 100644 --- a/src/lib/graph/component-class-sink-colander.c +++ b/src/lib/graph/component-class-sink-colander.c @@ -20,8 +20,8 @@ * SOFTWARE. */ -#define BT_LOG_TAG "COLANDER" -#include "lib/lib-logging.h" +#define BT_LOG_TAG "LIB/COLANDER" +#include "lib/logging.h" #include "common/assert.h" #include "lib/assert-pre.h" @@ -34,31 +34,28 @@ #include #include "component-class-sink-colander.h" +#include "lib/func-status.h" static struct bt_component_class_sink *colander_comp_cls; static -enum bt_self_component_status colander_init( +enum bt_component_class_init_method_status colander_init( struct bt_self_component_sink *self_comp, const struct bt_value *params, void *init_method_data) { - enum bt_self_component_status status = BT_SELF_COMPONENT_STATUS_OK; + enum bt_component_class_init_method_status status = + BT_FUNC_STATUS_OK; struct bt_component_class_sink_colander_priv_data *colander_data = NULL; struct bt_component_class_sink_colander_data *user_provided_data = init_method_data; - if (!init_method_data) { - BT_LOGW_STR("Component initialization method data is NULL."); - status = BT_SELF_COMPONENT_STATUS_ERROR; - goto end; - } - + BT_ASSERT(init_method_data); colander_data = g_new0( struct bt_component_class_sink_colander_priv_data, 1); if (!colander_data) { BT_LOGE_STR("Failed to allocate colander data."); - status = BT_SELF_COMPONENT_STATUS_NOMEM; + status = BT_FUNC_STATUS_MEMORY_ERROR; goto end; } @@ -66,7 +63,7 @@ enum bt_self_component_status colander_init( colander_data->count_addr = user_provided_data->count_addr; status = bt_self_component_sink_add_input_port(self_comp, "in", NULL, NULL); - if (status != BT_SELF_COMPONENT_STATUS_OK) { + if (status != BT_FUNC_STATUS_OK) { BT_LOGE_STR("Cannot add input port."); goto end; } @@ -95,10 +92,12 @@ void colander_finalize(struct bt_self_component_sink *self_comp) } static -enum bt_self_component_status colander_graph_is_configured( +enum bt_component_class_sink_graph_is_configured_method_status +colander_graph_is_configured( bt_self_component_sink *self_comp) { - enum bt_self_component_status status = BT_SELF_COMPONENT_STATUS_OK; + enum bt_component_class_sink_graph_is_configured_method_status status = + BT_FUNC_STATUS_OK; struct bt_component_class_sink_colander_priv_data *colander_data = bt_self_component_get_data( bt_self_component_sink_as_self_component(self_comp)); @@ -116,7 +115,7 @@ enum bt_self_component_status colander_graph_is_configured( BT_LIB_LOGE("Cannot create message iterator on " "self component input port: %![port-]+p", self_port); - status = BT_SELF_COMPONENT_STATUS_NOMEM; + status = BT_FUNC_STATUS_MEMORY_ERROR; goto end; } @@ -125,43 +124,36 @@ end: } static -enum bt_self_component_status colander_consume( +enum bt_component_class_sink_consume_method_status colander_consume( struct bt_self_component_sink *self_comp) { - enum bt_self_component_status status = BT_SELF_COMPONENT_STATUS_OK; - enum bt_message_iterator_status msg_iter_status; + enum bt_component_class_sink_consume_method_status status = + BT_FUNC_STATUS_OK; + enum bt_message_iterator_next_status next_status; struct bt_component_class_sink_colander_priv_data *colander_data = bt_self_component_get_data( bt_self_component_sink_as_self_component(self_comp)); bt_message_array_const msgs; BT_ASSERT(colander_data); - - if (!colander_data->msg_iter) { - BT_LIB_LOGW("Trying to consume without an " - "upstream message iterator: %![comp-]+c", - self_comp); - goto end; - } - - msg_iter_status = - bt_self_component_port_input_message_iterator_next( - colander_data->msg_iter, &msgs, - colander_data->count_addr); - switch (msg_iter_status) { - case BT_MESSAGE_ITERATOR_STATUS_AGAIN: - status = BT_SELF_COMPONENT_STATUS_AGAIN; + BT_ASSERT(colander_data->msg_iter); + next_status = bt_self_component_port_input_message_iterator_next( + colander_data->msg_iter, &msgs, + colander_data->count_addr); + switch (next_status) { + case BT_FUNC_STATUS_AGAIN: + status = BT_FUNC_STATUS_AGAIN; goto end; - case BT_MESSAGE_ITERATOR_STATUS_END: - status = BT_SELF_COMPONENT_STATUS_END; + case BT_FUNC_STATUS_END: + status = BT_FUNC_STATUS_END; goto end; - case BT_MESSAGE_ITERATOR_STATUS_OK: + case BT_FUNC_STATUS_OK: /* Move messages to user (count already set) */ memcpy(colander_data->msgs, msgs, sizeof(*msgs) * *colander_data->count_addr); break; default: - status = BT_SELF_COMPONENT_STATUS_ERROR; + status = BT_FUNC_STATUS_ERROR; goto end; } @@ -191,7 +183,7 @@ struct bt_component_class_sink *bt_component_class_sink_colander_get(void) end: bt_object_get_ref(colander_comp_cls); - return (void *) colander_comp_cls; + return colander_comp_cls; } __attribute__((destructor)) static