From 73ea076192095461cdf0e1ef81f703eae95b22ae Mon Sep 17 00:00:00 2001 From: Philippe Proulx Date: Mon, 5 Aug 2019 16:35:56 -0400 Subject: [PATCH] lib: remove colander sink component class This is not used anymore. Signed-off-by: Philippe Proulx Change-Id: Ib0592d3adf02f82159e262184d92e6eaf67f2386 Reviewed-on: https://review.lttng.org/c/babeltrace/+/1827 Tested-by: jenkins Reviewed-by: Francis Deslauriers Reviewed-by: Simon Marchi --- src/lib/graph/Makefile.am | 2 - src/lib/graph/component-class-sink-colander.c | 194 ------------------ src/lib/graph/component-class-sink-colander.h | 52 ----- src/lib/graph/iterator.c | 1 - src/lib/lib-logging.c | 1 - 5 files changed, 250 deletions(-) delete mode 100644 src/lib/graph/component-class-sink-colander.c delete mode 100644 src/lib/graph/component-class-sink-colander.h diff --git a/src/lib/graph/Makefile.am b/src/lib/graph/Makefile.am index a7a9c037..aa9d86c7 100644 --- a/src/lib/graph/Makefile.am +++ b/src/lib/graph/Makefile.am @@ -7,8 +7,6 @@ libgraph_la_SOURCES = \ component.c \ component-class.c \ component-class.h \ - component-class-sink-colander.c \ - component-class-sink-colander.h \ component-filter.c \ component-filter.h \ component.h \ diff --git a/src/lib/graph/component-class-sink-colander.c b/src/lib/graph/component-class-sink-colander.c deleted file mode 100644 index d1978c95..00000000 --- a/src/lib/graph/component-class-sink-colander.c +++ /dev/null @@ -1,194 +0,0 @@ -/* - * Copyright 2017-2018 Philippe Proulx - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#define BT_LOG_TAG "LIB/COLANDER" -#include "lib/logging.h" - -#include "common/assert.h" -#include "lib/assert-pre.h" -#include "lib/object.h" -#include -#include -#include -#include -#include -#include - -#include "component-class-sink-colander.h" -#include "lib/func-status.h" - -static -struct bt_component_class_sink *colander_comp_cls; - -static -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) -{ - 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; - - BT_ASSERT(init_method_data); - colander_data = g_new0( - struct bt_component_class_sink_colander_priv_data, 1); - if (!colander_data) { - BT_LIB_LOGE_APPEND_CAUSE( - "Failed to allocate colander sink data."); - status = BT_FUNC_STATUS_MEMORY_ERROR; - goto end; - } - - colander_data->msgs = user_provided_data->msgs; - 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_FUNC_STATUS_OK) { - BT_LIB_LOGE_APPEND_CAUSE( - "Cannot add input port to colander sink."); - goto end; - } - - bt_self_component_set_data( - bt_self_component_sink_as_self_component(self_comp), - colander_data); - -end: - return status; -} - -static -void colander_finalize(struct bt_self_component_sink *self_comp) -{ - struct bt_component_class_sink_colander_priv_data *colander_data = - bt_self_component_get_data( - bt_self_component_sink_as_self_component(self_comp)); - - if (!colander_data) { - return; - } - - BT_OBJECT_PUT_REF_AND_RESET(colander_data->msg_iter); - g_free(colander_data); -} - -static -enum bt_component_class_sink_graph_is_configured_method_status -colander_graph_is_configured( - bt_self_component_sink *self_comp) -{ - 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)); - - struct bt_self_component_port_input *self_port = - bt_self_component_sink_borrow_input_port_by_name(self_comp, "in"); - BT_ASSERT(self_port); - - BT_ASSERT(colander_data); - BT_OBJECT_PUT_REF_AND_RESET(colander_data->msg_iter); - colander_data->msg_iter = - bt_self_component_port_input_message_iterator_create_from_sink_component( - self_comp, self_port); - if (!colander_data->msg_iter) { - BT_LIB_LOGE_APPEND_CAUSE("Cannot create message iterator on " - "self component input port: %![port-]+p", - self_port); - status = BT_FUNC_STATUS_MEMORY_ERROR; - goto end; - } - -end: - return status; -} - -static -enum bt_component_class_sink_consume_method_status colander_consume( - struct bt_self_component_sink *self_comp) -{ - 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); - 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_FUNC_STATUS_END: - status = BT_FUNC_STATUS_END; - goto end; - 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_FUNC_STATUS_ERROR; - goto end; - } - -end: - return status; -} - -struct bt_component_class_sink *bt_component_class_sink_colander_get(void) -{ - if (colander_comp_cls) { - goto end; - } - - colander_comp_cls = bt_component_class_sink_create("colander", - colander_consume); - if (!colander_comp_cls) { - BT_LIB_LOGE_APPEND_CAUSE( - "Cannot create sink colander component class."); - goto end; - } - - (void) bt_component_class_sink_set_init_method( - colander_comp_cls, colander_init); - (void) bt_component_class_sink_set_finalize_method( - colander_comp_cls, colander_finalize); - (void) bt_component_class_sink_set_graph_is_configured_method( - colander_comp_cls, colander_graph_is_configured); - -end: - bt_object_get_ref(colander_comp_cls); - return colander_comp_cls; -} - -__attribute__((destructor)) static -void put_colander(void) { - BT_OBJECT_PUT_REF_AND_RESET(colander_comp_cls); -} diff --git a/src/lib/graph/component-class-sink-colander.h b/src/lib/graph/component-class-sink-colander.h deleted file mode 100644 index faa7a6eb..00000000 --- a/src/lib/graph/component-class-sink-colander.h +++ /dev/null @@ -1,52 +0,0 @@ -#ifndef BABELTRACE_GRAPH_COMPONENT_CLASS_SINK_COLANDER_H -#define BABELTRACE_GRAPH_COMPONENT_CLASS_SINK_COLANDER_H - -/* - * Copyright 2017-2018 Philippe Proulx - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -struct bt_component_class_sink_colander_priv_data { - bt_message_array_const msgs; - uint64_t *count_addr; - struct bt_self_component_port_input_message_iterator *msg_iter; -}; - -struct bt_component_class_sink_colander_data { - bt_message_array_const msgs; - uint64_t *count_addr; -}; - -extern struct bt_component_class_sink * -bt_component_class_sink_colander_get(void); - -#ifdef __cplusplus -} -#endif - -#endif /* BABELTRACE_GRAPH_COMPONENT_CLASS_SINK_COLANDER_H */ diff --git a/src/lib/graph/iterator.c b/src/lib/graph/iterator.c index 62e1f91e..21cd6eb8 100644 --- a/src/lib/graph/iterator.c +++ b/src/lib/graph/iterator.c @@ -63,7 +63,6 @@ #include #include "component-class.h" -#include "component-class-sink-colander.h" #include "component.h" #include "component-sink.h" #include "component-source.h" diff --git a/src/lib/lib-logging.c b/src/lib/lib-logging.c index ce261a1a..42eef208 100644 --- a/src/lib/lib-logging.c +++ b/src/lib/lib-logging.c @@ -43,7 +43,6 @@ #include "object-pool.h" #include "graph/interrupter.h" #include "graph/component-class.h" -#include "graph/component-class-sink-colander.h" #include "graph/component-filter.h" #include "graph/component.h" #include "graph/component-sink.h" -- 2.34.1