#include <glib.h>
#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;
+ int 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;
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;
+ BT_LIB_LOGE_APPEND_CAUSE(
+ "Failed to allocate colander sink data.");
+ status = BT_FUNC_STATUS_MEMORY_ERROR;
goto end;
}
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) {
- BT_LOGE_STR("Cannot add input port.");
+ if (status != BT_FUNC_STATUS_OK) {
+ BT_LIB_LOGE_APPEND_CAUSE(
+ "Cannot add input port to colander sink.");
goto end;
}
}
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));
bt_self_component_port_input_message_iterator_create(
self_port);
if (!colander_data->msg_iter) {
- BT_LIB_LOGE("Cannot create message iterator on "
+ BT_LIB_LOGE_APPEND_CAUSE("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;
}
}
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_ASSERT(colander_data);
BT_ASSERT(colander_data->msg_iter);
- 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;
+ 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;
}
colander_comp_cls = bt_component_class_sink_create("colander",
colander_consume);
if (!colander_comp_cls) {
- BT_LOGE_STR("Cannot create sink colander component class.");
+ BT_LIB_LOGE_APPEND_CAUSE(
+ "Cannot create sink colander component class.");
goto end;
}