* SOFTWARE.
*/
-#define BT_LOG_TAG "PLUGIN-UTILS-COUNTER-FLT"
-#include "logging.h"
+#define BT_COMP_LOG_SELF_COMP (counter->self_comp)
+#define BT_LOG_OUTPUT_LEVEL (counter->log_level)
+#define BT_LOG_TAG "PLUGIN/FLT.UTILS.COUNTER"
+#include "logging/comp-logging.h"
#include <babeltrace2/babeltrace.h>
#include "common/macros.h"
return counter->count.event +
counter->count.stream_begin +
counter->count.stream_end +
- counter->count.stream_activity_begin +
- counter->count.stream_activity_end +
counter->count.packet_begin +
counter->count.packet_end +
counter->count.disc_events +
PRINTF_COUNT("Event", event);
PRINTF_COUNT("Stream beginning", stream_begin);
PRINTF_COUNT("Stream end", stream_end);
- PRINTF_COUNT("Stream activity beginning", stream_activity_begin);
- PRINTF_COUNT("Stream activity end", stream_activity_end);
PRINTF_COUNT("Packet beginning", packet_begin);
PRINTF_COUNT("Packet end", packet_end);
PRINTF_COUNT("Discarded event", disc_events);
}
BT_HIDDEN
-bt_self_component_status counter_init(
+bt_component_class_init_method_status counter_init(
bt_self_component_sink *component,
const bt_value *params,
__attribute__((unused)) void *init_method_data)
{
- bt_self_component_status ret;
+ bt_component_class_init_method_status status =
+ BT_COMPONENT_CLASS_INIT_METHOD_STATUS_OK;
+ bt_self_component_add_port_status add_port_status;
struct counter *counter = g_new0(struct counter, 1);
const bt_value *step = NULL;
const bt_value *hide_zero = NULL;
if (!counter) {
- ret = BT_SELF_COMPONENT_STATUS_NOMEM;
+ status = BT_COMPONENT_CLASS_INIT_METHOD_STATUS_MEMORY_ERROR;
goto error;
}
- ret = bt_self_component_sink_add_input_port(component,
+ counter->self_comp =
+ bt_self_component_sink_as_self_component(component);
+ counter->log_level = bt_component_get_logging_level(
+ bt_self_component_as_component(counter->self_comp));
+ add_port_status = bt_self_component_sink_add_input_port(component,
"in", NULL, NULL);
- if (ret != BT_SELF_COMPONENT_STATUS_OK) {
+ switch (add_port_status) {
+ case BT_SELF_COMPONENT_ADD_PORT_STATUS_ERROR:
+ status = BT_COMPONENT_CLASS_INIT_METHOD_STATUS_ERROR;
goto error;
+ case BT_SELF_COMPONENT_ADD_PORT_STATUS_MEMORY_ERROR:
+ status = BT_COMPONENT_CLASS_INIT_METHOD_STATUS_MEMORY_ERROR;
+ goto error;
+ default:
+ break;
}
counter->last_printed_total = -1ULL;
step = bt_value_map_borrow_entry_value_const(params, "step");
if (step) {
if (!bt_value_is_unsigned_integer(step)) {
- BT_LOGE("`step` parameter: expecting an unsigned integer value: "
+ BT_COMP_LOGE("`step` parameter: expecting an unsigned integer value: "
"type=%s", bt_common_value_type_string(
bt_value_get_type(step)));
goto error;
}
- counter->step = bt_value_unsigned_integer_get(step);
+ counter->step = bt_value_integer_unsigned_get(step);
}
hide_zero = bt_value_map_borrow_entry_value_const(params, "hide-zero");
if (hide_zero) {
if (!bt_value_is_bool(hide_zero)) {
- BT_LOGE("`hide-zero` parameter: expecting a boolean value: "
+ BT_COMP_LOGE("`hide-zero` parameter: expecting a boolean value: "
"type=%s", bt_common_value_type_string(
bt_value_get_type(hide_zero)));
goto error;
error:
destroy_private_counter_data(counter);
- ret = BT_SELF_COMPONENT_STATUS_ERROR;
+
+ if (status == BT_COMPONENT_CLASS_INIT_METHOD_STATUS_OK) {
+ status = BT_COMPONENT_CLASS_INIT_METHOD_STATUS_ERROR;
+ }
end:
- return ret;
+ return status;
}
BT_HIDDEN
-bt_self_component_status counter_graph_is_configured(
+bt_component_class_sink_graph_is_configured_method_status
+counter_graph_is_configured(
bt_self_component_sink *comp)
{
- bt_self_component_status status = BT_SELF_COMPONENT_STATUS_OK;
+ bt_component_class_sink_graph_is_configured_method_status status =
+ BT_COMPONENT_CLASS_SINK_GRAPH_IS_CONFIGURED_METHOD_STATUS_OK;
struct counter *counter;
bt_self_component_port_input_message_iterator *iterator;
counter = bt_self_component_get_data(
bt_self_component_sink_as_self_component(comp));
BT_ASSERT(counter);
- iterator = bt_self_component_port_input_message_iterator_create(
- bt_self_component_sink_borrow_input_port_by_name(comp,
+ iterator = bt_self_component_port_input_message_iterator_create_from_sink_component(
+ comp, bt_self_component_sink_borrow_input_port_by_name(comp,
in_port_name));
if (!iterator) {
- status = BT_SELF_COMPONENT_STATUS_NOMEM;
+ status = BT_COMPONENT_CLASS_SINK_GRAPH_IS_CONFIGURED_METHOD_STATUS_MEMORY_ERROR;
goto end;
}
}
BT_HIDDEN
-bt_self_component_status counter_consume(
+bt_component_class_sink_consume_method_status counter_consume(
bt_self_component_sink *comp)
{
- bt_self_component_status ret = BT_SELF_COMPONENT_STATUS_OK;
+ bt_component_class_sink_consume_method_status status =
+ BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_OK;
struct counter *counter;
- bt_message_iterator_status it_ret;
+ bt_message_iterator_next_status next_status;
uint64_t msg_count;
bt_message_array_const msgs;
if (G_UNLIKELY(!counter->msg_iter)) {
try_print_last(counter);
- ret = BT_SELF_COMPONENT_STATUS_END;
+ status = BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_END;
goto end;
}
/* Consume messages */
- it_ret = bt_self_component_port_input_message_iterator_next(
+ next_status = bt_self_component_port_input_message_iterator_next(
counter->msg_iter, &msgs, &msg_count);
- if (it_ret < 0) {
- ret = BT_SELF_COMPONENT_STATUS_ERROR;
+ if (next_status < 0) {
+ status = (int) next_status;
goto end;
}
- switch (it_ret) {
- case BT_MESSAGE_ITERATOR_STATUS_OK:
+ switch (next_status) {
+ case BT_MESSAGE_ITERATOR_NEXT_STATUS_OK:
{
uint64_t i;
case BT_MESSAGE_TYPE_STREAM_END:
counter->count.stream_end++;
break;
- case BT_MESSAGE_TYPE_STREAM_ACTIVITY_BEGINNING:
- counter->count.stream_activity_begin++;
- break;
- case BT_MESSAGE_TYPE_STREAM_ACTIVITY_END:
- counter->count.stream_activity_end++;
- break;
case BT_MESSAGE_TYPE_DISCARDED_EVENTS:
counter->count.disc_events++;
break;
bt_message_put_ref(msg);
}
- ret = BT_SELF_COMPONENT_STATUS_OK;
+ status = BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_OK;
break;
}
- case BT_MESSAGE_ITERATOR_STATUS_AGAIN:
- ret = BT_SELF_COMPONENT_STATUS_AGAIN;
+ case BT_MESSAGE_ITERATOR_NEXT_STATUS_AGAIN:
+ status = BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_AGAIN;
goto end;
- case BT_MESSAGE_ITERATOR_STATUS_END:
+ case BT_MESSAGE_ITERATOR_NEXT_STATUS_END:
try_print_last(counter);
- ret = BT_SELF_COMPONENT_STATUS_END;
+ status = BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_END;
goto end;
- case BT_MESSAGE_ITERATOR_STATUS_NOMEM:
- ret = BT_SELF_COMPONENT_STATUS_NOMEM;
+ case BT_MESSAGE_ITERATOR_NEXT_STATUS_MEMORY_ERROR:
+ status = BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_MEMORY_ERROR;
goto end;
default:
break;
try_print_count(counter, msg_count);
end:
- return ret;
+ return status;
}