From a3f0c7db90f4cfc81090a83a7442b7bc624d5789 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Fri, 20 Dec 2019 17:20:55 -0500 Subject: [PATCH] lib: introduce bt_message_iterator_class Today, when defining a source or filter component class, the user sets the message iterator methods directly on the class. The `next` methods is mandatory, so it is passed to bt_component_class_{source,filter}_create, and the rest are optional, so they are set by dedicated setters. All these setters are therefore duplicated for source and filter, for example: - bt_component_class_source_set_message_iterator_initialize_method - bt_component_class_filter_set_message_iterator_initialize_method This patch factorizes everything related to message iterator methods and introduces the concept of "message iterator class". Instead of setting the message iterator methods on a component class, the user will now prepare a message iterator class, and pass a reference to this class when creating a source or filter component class. So, what used to be this: src_cls = bt_component_class_source_create(my_iter_next_method); bt_component_class_source_set_message_iterator_initialize_method(my_iter_init_method); would now become: iter_cls = bt_message_iterator_class_create(my_iter_next_method); bt_message_iterator_class_set_initialize_method(my_iter_init_method); src_cls = bt_component_class_source_create(iter_cls); The message iterator class is a ref-counted object, and bt_component_class_{source,filter}_create take their own references, so a user would typically call bt_message_iterator_class_put_ref just after that, as they would likely have no more use for the iterator class. It would be possible, in theory, to share an iterator class between multiple component classes, but to this day no practical usage has been found. The search continues. The macros to define a component class in a plugin remain the same, where the message iterator methods are attached to the component class. For example BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_INITIALIZE_METHOD_WITH_ID In other words, the message iterator class concept is not exposed in this area. There is a small change on the message iterator `initialize` methods impacting existing components: the `initialize` method of `bt_message_iterator_class` accepts a `bt_self_component` instead of a specialized `bt_self_component_source` or `bt_self_component_filter`. If the `initialize` method requires the specialized version, the user should pass it through the user data attached to the component. This had to be changed in the debug info component, for example. Change-Id: Idf8666d028eadae34589cc0460dc1da19ca75765 Signed-off-by: Simon Marchi Reviewed-on: https://review.lttng.org/c/babeltrace/+/2725 Tested-by: jenkins --- CONTRIBUTING.adoc | 4 + include/Makefile.am | 1 + .../graph/component-class-filter.h | 59 +--- .../graph/component-class-source.h | 59 +--- include/babeltrace2/graph/component-class.h | 42 --- .../graph/message-iterator-class.h | 164 +++++++++++ include/babeltrace2/plugin/plugin-dev.h | 47 ++-- include/babeltrace2/types.h | 1 + .../bt2/bt2/native_bt_component_class.i.h | 144 +++++----- src/lib/graph/Makefile.am | 2 + src/lib/graph/component-class.c | 177 +++--------- src/lib/graph/component-class.h | 16 +- src/lib/graph/iterator.c | 58 ++-- src/lib/graph/message-iterator-class.c | 157 +++++++++++ src/lib/graph/message-iterator-class.h | 61 ++++ src/lib/graph/message/iterator.h | 10 +- src/lib/lib-logging.c | 10 + src/lib/plugin/plugin-so.c | 264 +++++++++--------- src/plugins/ctf/fs-src/fs.c | 44 ++- src/plugins/ctf/fs-src/fs.h | 10 +- src/plugins/ctf/lttng-live/lttng-live.c | 36 ++- src/plugins/ctf/lttng-live/lttng-live.h | 6 +- .../lttng-utils/debug-info/debug-info.c | 59 ++-- .../lttng-utils/debug-info/debug-info.h | 10 +- src/plugins/text/dmesg/dmesg.c | 49 ++-- src/plugins/text/dmesg/dmesg.h | 10 +- src/plugins/text/pretty/pretty.c | 10 +- src/plugins/utils/muxer/muxer.c | 115 ++++---- src/plugins/utils/muxer/muxer.h | 10 +- src/plugins/utils/trimmer/trimmer.c | 140 +++++----- src/plugins/utils/trimmer/trimmer.h | 6 +- tests/lib/test-plugin-plugins/sfs.c | 16 +- tests/lib/test_graph_topo.c | 10 +- ...ruction_listener_in_destruction_listener.c | 11 +- tests/lib/test_simple_sink.c | 12 +- tests/lib/test_trace_ir_ref.c | 11 +- 36 files changed, 983 insertions(+), 858 deletions(-) create mode 100644 include/babeltrace2/graph/message-iterator-class.h create mode 100644 src/lib/graph/message-iterator-class.c create mode 100644 src/lib/graph/message-iterator-class.h diff --git a/CONTRIBUTING.adoc b/CONTRIBUTING.adoc index 72434e89..0eeb43ec 100644 --- a/CONTRIBUTING.adoc +++ b/CONTRIBUTING.adoc @@ -689,6 +689,10 @@ The available format specifiers are: |Message |`+const struct bt_message *+` +|`I` +|Message iterator class +|`struct bt_message_iterator_class *` + |`i` |Message iterator |`struct bt_message_iterator *` diff --git a/include/Makefile.am b/include/Makefile.am index 1594d2ca..a44ef6ee 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -101,6 +101,7 @@ babeltrace2graphinclude_HEADERS = \ babeltrace2/graph/message-message-iterator-inactivity-const.h \ babeltrace2/graph/message-message-iterator-inactivity.h \ babeltrace2/graph/message-iterator.h \ + babeltrace2/graph/message-iterator-class.h \ babeltrace2/graph/message-packet-beginning-const.h \ babeltrace2/graph/message-packet-beginning.h \ babeltrace2/graph/message-packet-end-const.h \ diff --git a/include/babeltrace2/graph/component-class-filter.h b/include/babeltrace2/graph/component-class-filter.h index a6a69bea..9aa7a9c5 100644 --- a/include/babeltrace2/graph/component-class-filter.h +++ b/include/babeltrace2/graph/component-class-filter.h @@ -53,41 +53,6 @@ typedef bt_component_class_initialize_method_status typedef void (*bt_component_class_filter_finalize_method)( bt_self_component_filter *self_component); -typedef bt_component_class_message_iterator_initialize_method_status -(*bt_component_class_filter_message_iterator_initialize_method)( - bt_self_message_iterator *message_iterator, - bt_self_message_iterator_configuration *config, - bt_self_component_filter *self_component, - bt_self_component_port_output *port); - -typedef void -(*bt_component_class_filter_message_iterator_finalize_method)( - bt_self_message_iterator *message_iterator); - -typedef bt_component_class_message_iterator_next_method_status -(*bt_component_class_filter_message_iterator_next_method)( - bt_self_message_iterator *message_iterator, - bt_message_array_const msgs, uint64_t capacity, - uint64_t *count); - -typedef bt_component_class_message_iterator_seek_ns_from_origin_method_status -(*bt_component_class_filter_message_iterator_seek_ns_from_origin_method)( - bt_self_message_iterator *message_iterator, - int64_t ns_from_origin); - -typedef bt_component_class_message_iterator_seek_beginning_method_status -(*bt_component_class_filter_message_iterator_seek_beginning_method)( - bt_self_message_iterator *message_iterator); - -typedef bt_component_class_message_iterator_can_seek_ns_from_origin_method_status -(*bt_component_class_filter_message_iterator_can_seek_ns_from_origin_method)( - bt_self_message_iterator *message_iterator, - int64_t ns_from_origin, bt_bool *can_seek); - -typedef bt_component_class_message_iterator_can_seek_beginning_method_status -(*bt_component_class_filter_message_iterator_can_seek_beginning_method)( - bt_self_message_iterator *message_iterator, bt_bool *can_seek); - typedef bt_component_class_query_method_status (*bt_component_class_filter_query_method)( bt_self_component_class_filter *comp_class, @@ -117,7 +82,7 @@ bt_component_class *bt_component_class_filter_as_component_class( extern bt_component_class_filter *bt_component_class_filter_create( const char *name, - bt_component_class_filter_message_iterator_next_method method); + bt_message_iterator_class *message_iterator_class); extern bt_component_class_set_method_status bt_component_class_filter_set_get_supported_mip_versions_method( @@ -149,28 +114,6 @@ bt_component_class_filter_set_query_method( bt_component_class_filter *comp_class, bt_component_class_filter_query_method method); -extern bt_component_class_set_method_status -bt_component_class_filter_set_message_iterator_initialize_method( - bt_component_class_filter *comp_class, - bt_component_class_filter_message_iterator_initialize_method method); - -extern bt_component_class_set_method_status -bt_component_class_filter_set_message_iterator_finalize_method( - bt_component_class_filter *comp_class, - bt_component_class_filter_message_iterator_finalize_method method); - -extern bt_component_class_set_method_status -bt_component_class_filter_set_message_iterator_seek_ns_from_origin_methods( - bt_component_class_filter *comp_class, - bt_component_class_filter_message_iterator_seek_ns_from_origin_method seek_method, - bt_component_class_filter_message_iterator_can_seek_ns_from_origin_method can_seek_method); - -extern bt_component_class_set_method_status -bt_component_class_filter_set_message_iterator_seek_beginning_methods( - bt_component_class_filter *comp_class, - bt_component_class_filter_message_iterator_seek_beginning_method seek_method, - bt_component_class_filter_message_iterator_can_seek_beginning_method can_seek_method); - #ifdef __cplusplus } #endif diff --git a/include/babeltrace2/graph/component-class-source.h b/include/babeltrace2/graph/component-class-source.h index bdc85180..10942f88 100644 --- a/include/babeltrace2/graph/component-class-source.h +++ b/include/babeltrace2/graph/component-class-source.h @@ -53,41 +53,6 @@ typedef bt_component_class_initialize_method_status typedef void (*bt_component_class_source_finalize_method)( bt_self_component_source *self_component); -typedef bt_component_class_message_iterator_initialize_method_status -(*bt_component_class_source_message_iterator_initialize_method)( - bt_self_message_iterator *message_iterator, - bt_self_message_iterator_configuration *config, - bt_self_component_source *self_component, - bt_self_component_port_output *port); - -typedef void -(*bt_component_class_source_message_iterator_finalize_method)( - bt_self_message_iterator *message_iterator); - -typedef bt_component_class_message_iterator_next_method_status -(*bt_component_class_source_message_iterator_next_method)( - bt_self_message_iterator *message_iterator, - bt_message_array_const msgs, uint64_t capacity, - uint64_t *count); - -typedef bt_component_class_message_iterator_seek_ns_from_origin_method_status -(*bt_component_class_source_message_iterator_seek_ns_from_origin_method)( - bt_self_message_iterator *message_iterator, - int64_t ns_from_origin); - -typedef bt_component_class_message_iterator_seek_beginning_method_status -(*bt_component_class_source_message_iterator_seek_beginning_method)( - bt_self_message_iterator *message_iterator); - -typedef bt_component_class_message_iterator_can_seek_ns_from_origin_method_status -(*bt_component_class_source_message_iterator_can_seek_ns_from_origin_method)( - bt_self_message_iterator *message_iterator, - int64_t ns_from_origin, bt_bool *can_seek); - -typedef bt_component_class_message_iterator_can_seek_beginning_method_status -(*bt_component_class_source_message_iterator_can_seek_beginning_method)( - bt_self_message_iterator *message_iterator, bt_bool *can_seek); - typedef bt_component_class_query_method_status (*bt_component_class_source_query_method)( bt_self_component_class_source *comp_class, @@ -111,7 +76,7 @@ bt_component_class *bt_component_class_source_as_component_class( extern bt_component_class_source *bt_component_class_source_create( const char *name, - bt_component_class_source_message_iterator_next_method method); + bt_message_iterator_class *message_iterator_class); extern bt_component_class_set_method_status bt_component_class_source_set_get_supported_mip_versions_method( @@ -138,28 +103,6 @@ bt_component_class_source_set_query_method( bt_component_class_source *comp_class, bt_component_class_source_query_method method); -extern bt_component_class_set_method_status -bt_component_class_source_set_message_iterator_initialize_method( - bt_component_class_source *comp_class, - bt_component_class_source_message_iterator_initialize_method method); - -extern bt_component_class_set_method_status -bt_component_class_source_set_message_iterator_finalize_method( - bt_component_class_source *comp_class, - bt_component_class_source_message_iterator_finalize_method method); - -extern bt_component_class_set_method_status -bt_component_class_source_set_message_iterator_seek_ns_from_origin_methods( - bt_component_class_source *comp_class, - bt_component_class_source_message_iterator_seek_ns_from_origin_method seek_method, - bt_component_class_source_message_iterator_can_seek_ns_from_origin_method can_seek_method); - -extern bt_component_class_set_method_status -bt_component_class_source_set_message_iterator_seek_beginning_methods( - bt_component_class_source *comp_class, - bt_component_class_source_message_iterator_seek_beginning_method seek_method, - bt_component_class_source_message_iterator_can_seek_beginning_method can_seek_method); - #ifdef __cplusplus } #endif diff --git a/include/babeltrace2/graph/component-class.h b/include/babeltrace2/graph/component-class.h index b68439e8..b8495d45 100644 --- a/include/babeltrace2/graph/component-class.h +++ b/include/babeltrace2/graph/component-class.h @@ -59,48 +59,6 @@ typedef enum bt_component_class_query_method_status { BT_COMPONENT_CLASS_QUERY_METHOD_STATUS_UNKNOWN_OBJECT = __BT_FUNC_STATUS_UNKNOWN_OBJECT, } bt_component_class_query_method_status; -typedef enum bt_component_class_message_iterator_initialize_method_status { - BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INITIALIZE_METHOD_STATUS_OK = __BT_FUNC_STATUS_OK, - BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INITIALIZE_METHOD_STATUS_ERROR = __BT_FUNC_STATUS_ERROR, - BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INITIALIZE_METHOD_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR, -} bt_component_class_message_iterator_initialize_method_status; - -typedef enum bt_component_class_message_iterator_next_method_status { - BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK = __BT_FUNC_STATUS_OK, - BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_AGAIN = __BT_FUNC_STATUS_AGAIN, - BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_ERROR = __BT_FUNC_STATUS_ERROR, - BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR, - BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_END = __BT_FUNC_STATUS_END, -} bt_component_class_message_iterator_next_method_status; - -typedef enum bt_component_class_message_iterator_seek_beginning_method_status { - BT_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_BEGINNING_METHOD_STATUS_OK = __BT_FUNC_STATUS_OK, - BT_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_BEGINNING_METHOD_STATUS_AGAIN = __BT_FUNC_STATUS_AGAIN, - BT_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_BEGINNING_METHOD_STATUS_ERROR = __BT_FUNC_STATUS_ERROR, - BT_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_BEGINNING_METHOD_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR, -} bt_component_class_message_iterator_seek_beginning_method_status; - -typedef enum bt_component_class_message_iterator_seek_ns_from_origin_method_status { - BT_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_NS_FROM_ORIGIN_METHOD_STATUS_OK = __BT_FUNC_STATUS_OK, - BT_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_NS_FROM_ORIGIN_METHOD_STATUS_AGAIN = __BT_FUNC_STATUS_AGAIN, - BT_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_NS_FROM_ORIGIN_METHOD_STATUS_ERROR = __BT_FUNC_STATUS_ERROR, - BT_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_NS_FROM_ORIGIN_METHOD_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR, -} bt_component_class_message_iterator_seek_ns_from_origin_method_status; - -typedef enum bt_component_class_message_iterator_can_seek_beginning_method_status { - BT_COMPONENT_CLASS_MESSAGE_ITERATOR_CAN_SEEK_BEGINNING_METHOD_STATUS_OK = __BT_FUNC_STATUS_OK, - BT_COMPONENT_CLASS_MESSAGE_ITERATOR_CAN_SEEK_BEGINNING_METHOD_STATUS_AGAIN = __BT_FUNC_STATUS_AGAIN, - BT_COMPONENT_CLASS_MESSAGE_ITERATOR_CAN_SEEK_BEGINNING_METHOD_STATUS_ERROR = __BT_FUNC_STATUS_ERROR, - BT_COMPONENT_CLASS_MESSAGE_ITERATOR_CAN_SEEK_BEGINNING_METHOD_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR, -} bt_component_class_message_iterator_can_seek_beginning_method_status; - -typedef enum bt_component_class_message_iterator_can_seek_ns_from_origin_method_status { - BT_COMPONENT_CLASS_MESSAGE_ITERATOR_CAN_SEEK_NS_FROM_ORIGIN_METHOD_STATUS_OK = __BT_FUNC_STATUS_OK, - BT_COMPONENT_CLASS_MESSAGE_ITERATOR_CAN_SEEK_NS_FROM_ORIGIN_METHOD_STATUS_AGAIN = __BT_FUNC_STATUS_AGAIN, - BT_COMPONENT_CLASS_MESSAGE_ITERATOR_CAN_SEEK_NS_FROM_ORIGIN_METHOD_STATUS_ERROR = __BT_FUNC_STATUS_ERROR, - BT_COMPONENT_CLASS_MESSAGE_ITERATOR_CAN_SEEK_NS_FROM_ORIGIN_METHOD_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR, -} bt_component_class_message_iterator_can_seek_ns_from_origin_method_status; - typedef enum bt_component_class_set_method_status { BT_COMPONENT_CLASS_SET_METHOD_STATUS_OK = __BT_FUNC_STATUS_OK, } bt_component_class_set_method_status; diff --git a/include/babeltrace2/graph/message-iterator-class.h b/include/babeltrace2/graph/message-iterator-class.h new file mode 100644 index 00000000..c52fcd72 --- /dev/null +++ b/include/babeltrace2/graph/message-iterator-class.h @@ -0,0 +1,164 @@ +#ifndef BABELTRACE2_GRAPH_MESSAGE_ITERATOR_CLASS_H +#define BABELTRACE2_GRAPH_MESSAGE_ITERATOR_CLASS_H + +/* + * Copyright (c) 2019 EfficiOS Inc. + * + * 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. + */ + +#ifndef __BT_IN_BABELTRACE_H +# error "Please include instead." +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum bt_message_iterator_class_set_method_status { + BT_MESSAGE_ITERATOR_CLASS_SET_METHOD_STATUS_OK = __BT_FUNC_STATUS_OK, +} bt_message_iterator_class_set_method_status; + +typedef enum bt_message_iterator_class_initialize_method_status { + BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_OK = __BT_FUNC_STATUS_OK, + BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_ERROR = __BT_FUNC_STATUS_ERROR, + BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR, +} bt_message_iterator_class_initialize_method_status; + +typedef enum bt_message_iterator_class_next_method_status { + BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK = __BT_FUNC_STATUS_OK, + BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_AGAIN = __BT_FUNC_STATUS_AGAIN, + BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_ERROR = __BT_FUNC_STATUS_ERROR, + BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR, + BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_END = __BT_FUNC_STATUS_END, +} bt_message_iterator_class_next_method_status; + +typedef enum bt_message_iterator_class_seek_ns_from_origin_method_status { + BT_MESSAGE_ITERATOR_CLASS_SEEK_NS_FROM_ORIGIN_METHOD_STATUS_OK = __BT_FUNC_STATUS_OK, + BT_MESSAGE_ITERATOR_CLASS_SEEK_NS_FROM_ORIGIN_METHOD_STATUS_AGAIN = __BT_FUNC_STATUS_AGAIN, + BT_MESSAGE_ITERATOR_CLASS_SEEK_NS_FROM_ORIGIN_METHOD_STATUS_ERROR = __BT_FUNC_STATUS_ERROR, + BT_MESSAGE_ITERATOR_CLASS_SEEK_NS_FROM_ORIGIN_METHOD_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR, +} bt_message_iterator_class_seek_ns_from_origin_method_status; + +typedef enum bt_message_iterator_class_can_seek_ns_from_origin_method_status { + BT_MESSAGE_ITERATOR_CLASS_CAN_SEEK_NS_FROM_ORIGIN_METHOD_STATUS_OK = __BT_FUNC_STATUS_OK, + BT_MESSAGE_ITERATOR_CLASS_CAN_SEEK_NS_FROM_ORIGIN_METHOD_STATUS_AGAIN = __BT_FUNC_STATUS_AGAIN, + BT_MESSAGE_ITERATOR_CLASS_CAN_SEEK_NS_FROM_ORIGIN_METHOD_STATUS_ERROR = __BT_FUNC_STATUS_ERROR, + BT_MESSAGE_ITERATOR_CLASS_CAN_SEEK_NS_FROM_ORIGIN_METHOD_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR, +} bt_message_iterator_class_can_seek_ns_from_origin_method_status; + +typedef enum bt_message_iterator_class_seek_beginning_method_status { + BT_MESSAGE_ITERATOR_CLASS_SEEK_BEGINNING_METHOD_STATUS_OK = __BT_FUNC_STATUS_OK, + BT_MESSAGE_ITERATOR_CLASS_SEEK_BEGINNING_METHOD_STATUS_AGAIN = __BT_FUNC_STATUS_AGAIN, + BT_MESSAGE_ITERATOR_CLASS_SEEK_BEGINNING_METHOD_STATUS_ERROR = __BT_FUNC_STATUS_ERROR, + BT_MESSAGE_ITERATOR_CLASS_SEEK_BEGINNING_METHOD_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR, +} bt_message_iterator_class_seek_beginning_method_status; + +typedef enum bt_message_iterator_class_can_seek_beginning_method_status { + BT_MESSAGE_ITERATOR_CLASS_CAN_SEEK_BEGINNING_METHOD_STATUS_OK = __BT_FUNC_STATUS_OK, + BT_MESSAGE_ITERATOR_CLASS_CAN_SEEK_BEGINNING_METHOD_STATUS_AGAIN = __BT_FUNC_STATUS_AGAIN, + BT_MESSAGE_ITERATOR_CLASS_CAN_SEEK_BEGINNING_METHOD_STATUS_ERROR = __BT_FUNC_STATUS_ERROR, + BT_MESSAGE_ITERATOR_CLASS_CAN_SEEK_BEGINNING_METHOD_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR, +} bt_message_iterator_class_can_seek_beginning_method_status; + +typedef bt_message_iterator_class_initialize_method_status +(*bt_message_iterator_class_initialize_method)( + bt_self_message_iterator *message_iterator, + bt_self_message_iterator_configuration *config, + bt_self_component *self_component, + bt_self_component_port_output *port); + +typedef void +(*bt_message_iterator_class_finalize_method)( + bt_self_message_iterator *message_iterator); + +typedef bt_message_iterator_class_next_method_status +(*bt_message_iterator_class_next_method)( + bt_self_message_iterator *message_iterator, + bt_message_array_const msgs, uint64_t capacity, + uint64_t *count); + +typedef bt_message_iterator_class_seek_ns_from_origin_method_status +(*bt_message_iterator_class_seek_ns_from_origin_method)( + bt_self_message_iterator *message_iterator, + int64_t ns_from_origin); + +typedef bt_message_iterator_class_can_seek_ns_from_origin_method_status +(*bt_message_iterator_class_can_seek_ns_from_origin_method)( + bt_self_message_iterator *message_iterator, + int64_t ns_from_origin, bt_bool *can_seek); + +typedef bt_message_iterator_class_seek_beginning_method_status +(*bt_message_iterator_class_seek_beginning_method)( + bt_self_message_iterator *message_iterator); + +typedef bt_message_iterator_class_can_seek_beginning_method_status +(*bt_message_iterator_class_can_seek_beginning_method)( + bt_self_message_iterator *message_iterator, bt_bool *can_seek); + +extern void bt_message_iterator_class_get_ref( + const bt_message_iterator_class *message_iterator_class); + +extern void bt_message_iterator_class_put_ref( + const bt_message_iterator_class *message_iterator_class); + +#define BT_MESSAGE_ITERATOR_CLASS_PUT_REF_AND_RESET(_var) \ + do { \ + bt_message_iterator_class_put_ref(_var); \ + (_var) = NULL; \ + } while (0) + +#define BT_MESSAGE_ITERATOR_CLASS_MOVE_MOVE_REF(_var_dst, _var_src) \ + do { \ + bt_message_iterator_class_put_ref(_var_dst); \ + (_var_dst) = (_var_src); \ + (_var_src) = NULL; \ + } while (0) + +extern bt_message_iterator_class * +bt_message_iterator_class_create( + bt_message_iterator_class_next_method next_method); + +extern bt_message_iterator_class_set_method_status +bt_message_iterator_class_set_initialize_method( + bt_message_iterator_class *message_iterator_class, + bt_message_iterator_class_initialize_method method); + +extern bt_message_iterator_class_set_method_status +bt_message_iterator_class_set_finalize_method( + bt_message_iterator_class *message_iterator_class, + bt_message_iterator_class_finalize_method method); + +extern bt_message_iterator_class_set_method_status +bt_message_iterator_class_set_seek_ns_from_origin_methods( + bt_message_iterator_class *message_iterator_class, + bt_message_iterator_class_seek_ns_from_origin_method seek_method, + bt_message_iterator_class_can_seek_ns_from_origin_method can_seek_method); + +extern bt_message_iterator_class_set_method_status +bt_message_iterator_class_set_seek_beginning_methods( + bt_message_iterator_class *message_iterator_class, + bt_message_iterator_class_seek_beginning_method seek_method, + bt_message_iterator_class_can_seek_beginning_method can_seek_method); + +#ifdef __cplusplus +} +#endif + +#endif /* BABELTRACE2_GRAPH_MESSAGE_ITERATOR_CLASS_H */ diff --git a/include/babeltrace2/plugin/plugin-dev.h b/include/babeltrace2/plugin/plugin-dev.h index 0db0f6bf..f2e7a079 100644 --- a/include/babeltrace2/plugin/plugin-dev.h +++ b/include/babeltrace2/plugin/plugin-dev.h @@ -33,6 +33,7 @@ #include #include #include +#include #include /* @@ -138,12 +139,12 @@ struct __bt_plugin_component_class_descriptor { union { /* BT_COMPONENT_CLASS_TYPE_SOURCE */ struct { - bt_component_class_source_message_iterator_next_method msg_iter_next; + bt_message_iterator_class_next_method msg_iter_next; } source; /* BT_COMPONENT_CLASS_TYPE_FILTER */ struct { - bt_component_class_filter_message_iterator_next_method msg_iter_next; + bt_message_iterator_class_next_method msg_iter_next; } filter; /* BT_COMPONENT_CLASS_TYPE_SINK */ @@ -226,28 +227,22 @@ struct __bt_plugin_component_class_descriptor_attribute { bt_component_class_sink_graph_is_configured_method sink_graph_is_configured_method; /* BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_INITIALIZE_METHOD */ - bt_component_class_source_message_iterator_initialize_method source_msg_iter_initialize_method; - bt_component_class_filter_message_iterator_initialize_method filter_msg_iter_initialize_method; + bt_message_iterator_class_initialize_method msg_iter_initialize_method; /* BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_FINALIZE_METHOD */ - bt_component_class_source_message_iterator_finalize_method source_msg_iter_finalize_method; - bt_component_class_filter_message_iterator_finalize_method filter_msg_iter_finalize_method; + bt_message_iterator_class_finalize_method msg_iter_finalize_method; /* BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_SEEK_NS_FROM_ORIGIN_METHOD */ - bt_component_class_source_message_iterator_seek_ns_from_origin_method source_msg_iter_seek_ns_from_origin_method; - bt_component_class_filter_message_iterator_seek_ns_from_origin_method filter_msg_iter_seek_ns_from_origin_method; + bt_message_iterator_class_seek_ns_from_origin_method msg_iter_seek_ns_from_origin_method; /* BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_SEEK_BEGINNING_METHOD */ - bt_component_class_source_message_iterator_seek_beginning_method source_msg_iter_seek_beginning_method; - bt_component_class_filter_message_iterator_seek_beginning_method filter_msg_iter_seek_beginning_method; + bt_message_iterator_class_seek_beginning_method msg_iter_seek_beginning_method; /* BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_CAN_SEEK_NS_FROM_ORIGIN_METHOD */ - bt_component_class_source_message_iterator_can_seek_ns_from_origin_method source_msg_iter_can_seek_ns_from_origin_method; - bt_component_class_filter_message_iterator_can_seek_ns_from_origin_method filter_msg_iter_can_seek_ns_from_origin_method; + bt_message_iterator_class_can_seek_ns_from_origin_method msg_iter_can_seek_ns_from_origin_method; /* BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_CAN_SEEK_BEGINNING_METHOD */ - bt_component_class_source_message_iterator_can_seek_beginning_method source_msg_iter_can_seek_beginning_method; - bt_component_class_filter_message_iterator_can_seek_beginning_method filter_msg_iter_can_seek_beginning_method; + bt_message_iterator_class_can_seek_beginning_method msg_iter_can_seek_beginning_method; } value; } __attribute__((packed)); @@ -847,7 +842,7 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_ * (bt_component_class_source_message_iterator_initialize_method). */ #define BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_INITIALIZE_METHOD_WITH_ID(_id, _comp_class_id, _x) \ - __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(source_msg_iter_initialize_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_INITIALIZE_METHOD, _id, _comp_class_id, source, _x) + __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(msg_iter_initialize_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_INITIALIZE_METHOD, _id, _comp_class_id, source, _x) /* * Defines an iterator finalize method attribute attached to a specific @@ -859,7 +854,7 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_ * (bt_component_class_source_message_iterator_finalize_method). */ #define BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_FINALIZE_METHOD_WITH_ID(_id, _comp_class_id, _x) \ - __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(source_msg_iter_finalize_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_FINALIZE_METHOD, _id, _comp_class_id, source, _x) + __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(msg_iter_finalize_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_FINALIZE_METHOD, _id, _comp_class_id, source, _x) /* * Defines an iterator "seek nanoseconds from origin" and "can seek nanoseconds @@ -874,8 +869,8 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_ * (bt_component_class_source_message_iterator_can_seek_ns_from_origin_method). */ #define BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_NS_FROM_ORIGIN_METHODS_WITH_ID(_id, _comp_class_id, _seek_method, _can_seek_method) \ - __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(source_msg_iter_seek_ns_from_origin_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_SEEK_NS_FROM_ORIGIN_METHOD, _id, _comp_class_id, source, _seek_method); \ - __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(source_msg_iter_can_seek_ns_from_origin_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_CAN_SEEK_NS_FROM_ORIGIN_METHOD, _id, _comp_class_id, source, _can_seek_method) + __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(msg_iter_seek_ns_from_origin_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_SEEK_NS_FROM_ORIGIN_METHOD, _id, _comp_class_id, source, _seek_method); \ + __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(msg_iter_can_seek_ns_from_origin_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_CAN_SEEK_NS_FROM_ORIGIN_METHOD, _id, _comp_class_id, source, _can_seek_method) /* * Defines an iterator "seek beginning" and "can seek beginning" method @@ -889,8 +884,8 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_ * (bt_component_class_source_message_iterator_can_seek_beginning_method). */ #define BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_BEGINNING_METHODS_WITH_ID(_id, _comp_class_id, _seek_method, _can_seek_method) \ - __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(source_msg_iter_seek_beginning_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_SEEK_BEGINNING_METHOD, _id, _comp_class_id, source, _seek_method); \ - __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(source_msg_iter_can_seek_beginning_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_CAN_SEEK_BEGINNING_METHOD, _id, _comp_class_id, source, _can_seek_method) + __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(msg_iter_seek_beginning_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_SEEK_BEGINNING_METHOD, _id, _comp_class_id, source, _seek_method); \ + __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(msg_iter_can_seek_beginning_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_CAN_SEEK_BEGINNING_METHOD, _id, _comp_class_id, source, _can_seek_method) /* * Defines an iterator initialization method attribute attached to a @@ -902,7 +897,7 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_ * (bt_component_class_filter_message_iterator_initialize_method). */ #define BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_INITIALIZE_METHOD_WITH_ID(_id, _comp_class_id, _x) \ - __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(filter_msg_iter_initialize_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_INITIALIZE_METHOD, _id, _comp_class_id, filter, _x) + __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(msg_iter_initialize_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_INITIALIZE_METHOD, _id, _comp_class_id, filter, _x) /* * Defines an iterator finalize method attribute attached to a specific @@ -914,7 +909,7 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_ * (bt_component_class_filter_message_iterator_finalize_method). */ #define BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_FINALIZE_METHOD_WITH_ID(_id, _comp_class_id, _x) \ - __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(filter_msg_iter_finalize_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_FINALIZE_METHOD, _id, _comp_class_id, filter, _x) + __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(msg_iter_finalize_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_FINALIZE_METHOD, _id, _comp_class_id, filter, _x) /* * Defines an iterator "seek nanoseconds" and "can seek nanoseconds from origin" @@ -928,8 +923,8 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_ * (bt_component_class_filter_message_iterator_can_seek_ns_from_origin_method). */ #define BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_NS_FROM_ORIGIN_METHODS_WITH_ID(_id, _comp_class_id, _seek_method, _can_seek_method) \ - __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(filter_msg_iter_seek_ns_from_origin_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_SEEK_NS_FROM_ORIGIN_METHOD, _id, _comp_class_id, filter, _seek_method); \ - __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(filter_msg_iter_can_seek_ns_from_origin_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_CAN_SEEK_NS_FROM_ORIGIN_METHOD, _id, _comp_class_id, filter, _can_seek_method) + __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(msg_iter_seek_ns_from_origin_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_SEEK_NS_FROM_ORIGIN_METHOD, _id, _comp_class_id, filter, _seek_method); \ + __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(msg_iter_can_seek_ns_from_origin_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_CAN_SEEK_NS_FROM_ORIGIN_METHOD, _id, _comp_class_id, filter, _can_seek_method) /* * Defines an iterator "seek beginning" and "can seek beginning" method @@ -943,8 +938,8 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_ * (bt_component_class_filter_message_iterator_can_seek_beginning_method). */ #define BT_PLUGIN_FILTER_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_BEGINNING_METHODS_WITH_ID(_id, _comp_class_id, _seek_method, _can_seek_method) \ - __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(filter_msg_iter_seek_beginning_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_SEEK_BEGINNING_METHOD, _id, _comp_class_id, filter, _seek_method); \ - __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(filter_msg_iter_can_seek_beginning_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_CAN_SEEK_BEGINNING_METHOD, _id, _comp_class_id, filter, _can_seek_method); + __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(msg_iter_seek_beginning_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_SEEK_BEGINNING_METHOD, _id, _comp_class_id, filter, _seek_method); \ + __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(msg_iter_can_seek_beginning_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_CAN_SEEK_BEGINNING_METHOD, _id, _comp_class_id, filter, _can_seek_method); /* * Defines a plugin descriptor with an automatic ID. diff --git a/include/babeltrace2/types.h b/include/babeltrace2/types.h index 585905f1..e2b9854e 100644 --- a/include/babeltrace2/types.h +++ b/include/babeltrace2/types.h @@ -119,6 +119,7 @@ typedef struct bt_integer_range_unsigned bt_integer_range_unsigned; typedef struct bt_interrupter bt_interrupter; typedef struct bt_message bt_message; typedef struct bt_message_iterator bt_message_iterator; +typedef struct bt_message_iterator_class bt_message_iterator_class; typedef struct bt_object bt_object; typedef struct bt_packet bt_packet; typedef struct bt_plugin bt_plugin; diff --git a/src/bindings/python/bt2/bt2/native_bt_component_class.i.h b/src/bindings/python/bt2/bt2/native_bt_component_class.i.h index 6ea021de..1f193685 100644 --- a/src/bindings/python/bt2/bt2/native_bt_component_class.i.h +++ b/src/bindings/python/bt2/bt2/native_bt_component_class.i.h @@ -647,13 +647,13 @@ void component_class_sink_finalize(bt_self_component_sink *self_component_sink) } static -bt_component_class_message_iterator_can_seek_beginning_method_status +bt_message_iterator_class_can_seek_beginning_method_status component_class_can_seek_beginning( bt_self_message_iterator *self_message_iterator, bt_bool *can_seek) { PyObject *py_iter; PyObject *py_result = NULL; - bt_component_class_message_iterator_can_seek_beginning_method_status status; + bt_message_iterator_class_can_seek_beginning_method_status status; py_iter = bt_self_message_iterator_get_data(self_message_iterator); BT_ASSERT(py_iter); @@ -668,7 +668,7 @@ component_class_can_seek_beginning( BT_ASSERT(PyBool_Check(py_result)); *can_seek = PyObject_IsTrue(py_result); - status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_CAN_SEEK_BEGINNING_METHOD_STATUS_OK; + status = BT_MESSAGE_ITERATOR_CLASS_CAN_SEEK_BEGINNING_METHOD_STATUS_OK; end: Py_XDECREF(py_result); @@ -677,12 +677,12 @@ end: } static -bt_component_class_message_iterator_seek_beginning_method_status +bt_message_iterator_class_seek_beginning_method_status component_class_seek_beginning(bt_self_message_iterator *self_message_iterator) { PyObject *py_iter; PyObject *py_result; - bt_component_class_message_iterator_seek_beginning_method_status status; + bt_message_iterator_class_seek_beginning_method_status status; py_iter = bt_self_message_iterator_get_data(self_message_iterator); BT_ASSERT(py_iter); @@ -697,7 +697,7 @@ component_class_seek_beginning(bt_self_message_iterator *self_message_iterator) BT_ASSERT(py_result == Py_None); - status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_BEGINNING_METHOD_STATUS_OK; + status = BT_MESSAGE_ITERATOR_CLASS_SEEK_BEGINNING_METHOD_STATUS_OK; end: Py_XDECREF(py_result); @@ -706,14 +706,14 @@ end: } static -bt_component_class_message_iterator_can_seek_ns_from_origin_method_status +bt_message_iterator_class_can_seek_ns_from_origin_method_status component_class_can_seek_ns_from_origin( bt_self_message_iterator *self_message_iterator, int64_t ns_from_origin, bt_bool *can_seek) { PyObject *py_iter; PyObject *py_result = NULL; - bt_component_class_message_iterator_can_seek_ns_from_origin_method_status status; + bt_message_iterator_class_can_seek_ns_from_origin_method_status status; py_iter = bt_self_message_iterator_get_data(self_message_iterator); BT_ASSERT(py_iter); @@ -728,7 +728,7 @@ component_class_can_seek_ns_from_origin( BT_ASSERT(PyBool_Check(py_result)); *can_seek = PyObject_IsTrue(py_result); - status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_CAN_SEEK_NS_FROM_ORIGIN_METHOD_STATUS_OK; + status = BT_MESSAGE_ITERATOR_CLASS_CAN_SEEK_NS_FROM_ORIGIN_METHOD_STATUS_OK; end: Py_XDECREF(py_result); @@ -737,14 +737,14 @@ end: } static -bt_component_class_message_iterator_seek_ns_from_origin_method_status +bt_message_iterator_class_seek_ns_from_origin_method_status component_class_seek_ns_from_origin( bt_self_message_iterator *self_message_iterator, int64_t ns_from_origin) { PyObject *py_iter; PyObject *py_result; - bt_component_class_message_iterator_seek_ns_from_origin_method_status status; + bt_message_iterator_class_seek_ns_from_origin_method_status status; py_iter = bt_self_message_iterator_get_data(self_message_iterator); BT_ASSERT(py_iter); @@ -759,7 +759,7 @@ component_class_seek_ns_from_origin( BT_ASSERT(py_result == Py_None); - status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_NS_FROM_ORIGIN_METHOD_STATUS_OK; + status = BT_MESSAGE_ITERATOR_CLASS_SEEK_NS_FROM_ORIGIN_METHOD_STATUS_OK; end: Py_XDECREF(py_result); @@ -1079,14 +1079,14 @@ bt_component_class_query_method_status component_class_sink_query( } static -bt_component_class_message_iterator_initialize_method_status +bt_message_iterator_class_initialize_method_status component_class_message_iterator_init( bt_self_message_iterator *self_message_iterator, bt_self_message_iterator_configuration *config, bt_self_component *self_component, bt_self_component_port_output *self_component_port_output) { - bt_component_class_message_iterator_initialize_method_status status = __BT_FUNC_STATUS_OK; + bt_message_iterator_class_initialize_method_status status = __BT_FUNC_STATUS_OK; PyObject *py_comp_cls = NULL; PyObject *py_iter_cls = NULL; PyObject *py_iter_ptr = NULL; @@ -1231,36 +1231,6 @@ end: return status; } -static -bt_component_class_message_iterator_initialize_method_status -component_class_source_message_iterator_init( - bt_self_message_iterator *self_message_iterator, - bt_self_message_iterator_configuration *config, - bt_self_component_source *self_component_source, - bt_self_component_port_output *self_component_port_output) -{ - bt_self_component *self_component = - bt_self_component_source_as_self_component(self_component_source); - - return component_class_message_iterator_init(self_message_iterator, - config, self_component, self_component_port_output); -} - -static -bt_component_class_message_iterator_initialize_method_status -component_class_filter_message_iterator_init( - bt_self_message_iterator *self_message_iterator, - bt_self_message_iterator_configuration *config, - bt_self_component_filter *self_component_filter, - bt_self_component_port_output *self_component_port_output) -{ - bt_self_component *self_component = - bt_self_component_filter_as_self_component(self_component_filter); - - return component_class_message_iterator_init(self_message_iterator, - config, self_component, self_component_port_output); -} - static void component_class_message_iterator_finalize( bt_self_message_iterator *message_iterator) @@ -1299,13 +1269,13 @@ void component_class_message_iterator_finalize( /* Valid for both sources and filters. */ static -bt_component_class_message_iterator_next_method_status +bt_message_iterator_class_next_method_status component_class_message_iterator_next( bt_self_message_iterator *message_iterator, bt_message_array_const msgs, uint64_t capacity, uint64_t *count) { - bt_component_class_message_iterator_next_method_status status; + bt_message_iterator_class_next_method_status status; PyObject *py_message_iter = bt_self_message_iterator_get_data(message_iterator); PyObject *py_method_result = NULL; @@ -1328,7 +1298,7 @@ component_class_message_iterator_next( /* Overflow errors should never happen. */ BT_ASSERT_DBG(!PyErr_Occurred()); - status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK; + status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK; end: Py_XDECREF(py_method_result); @@ -1391,18 +1361,57 @@ end: return ret; } +static +bt_message_iterator_class *create_message_iterator_class(void) +{ + bt_message_iterator_class *message_iterator_class; + bt_message_iterator_class_set_method_status ret; + + message_iterator_class = bt_message_iterator_class_create( + component_class_message_iterator_next); + if (!message_iterator_class) { + BT_LOGE_STR("Cannot create message iterator class."); + goto end; + } + + ret = bt_message_iterator_class_set_seek_beginning_methods( + message_iterator_class, component_class_seek_beginning, + component_class_can_seek_beginning); + BT_ASSERT(ret == 0); + ret = bt_message_iterator_class_set_seek_ns_from_origin_methods( + message_iterator_class, component_class_seek_ns_from_origin, + component_class_can_seek_ns_from_origin); + BT_ASSERT(ret == 0); + ret = bt_message_iterator_class_set_initialize_method( + message_iterator_class, component_class_message_iterator_init); + BT_ASSERT(ret == 0); + ret = bt_message_iterator_class_set_finalize_method( + message_iterator_class, component_class_message_iterator_finalize); + BT_ASSERT(ret == 0); + +end: + return message_iterator_class; +} + static bt_component_class_source *bt_bt2_component_class_source_create( PyObject *py_cls, const char *name, const char *description, const char *help) { - bt_component_class_source *component_class_source; + bt_component_class_source *component_class_source = NULL; + bt_message_iterator_class *message_iterator_class; bt_component_class *component_class; int ret; BT_ASSERT(py_cls); + + message_iterator_class = create_message_iterator_class(); + if (!message_iterator_class) { + goto end; + } + component_class_source = bt_component_class_source_create(name, - component_class_message_iterator_next); + message_iterator_class); if (!component_class_source) { BT_LOGE_STR("Cannot create source component class."); goto end; @@ -1418,12 +1427,6 @@ bt_component_class_source *bt_bt2_component_class_source_create( BT_ASSERT(ret == 0); ret = bt_component_class_source_set_finalize_method(component_class_source, component_class_source_finalize); BT_ASSERT(ret == 0); - ret = bt_component_class_source_set_message_iterator_seek_beginning_methods(component_class_source, - component_class_seek_beginning, component_class_can_seek_beginning); - ret = bt_component_class_source_set_message_iterator_seek_ns_from_origin_methods( - component_class_source, component_class_seek_ns_from_origin, - component_class_can_seek_ns_from_origin); - BT_ASSERT(ret == 0); ret = bt_component_class_source_set_output_port_connected_method(component_class_source, component_class_source_output_port_connected); BT_ASSERT(ret == 0); @@ -1431,15 +1434,10 @@ bt_component_class_source *bt_bt2_component_class_source_create( BT_ASSERT(ret == 0); ret = bt_component_class_source_set_get_supported_mip_versions_method(component_class_source, component_class_source_get_supported_mip_versions); BT_ASSERT(ret == 0); - ret = bt_component_class_source_set_message_iterator_initialize_method( - component_class_source, component_class_source_message_iterator_init); - BT_ASSERT(ret == 0); - ret = bt_component_class_source_set_message_iterator_finalize_method( - component_class_source, component_class_message_iterator_finalize); - BT_ASSERT(ret == 0); register_cc_ptr_to_py_cls(component_class, py_cls); end: + bt_message_iterator_class_put_ref(message_iterator_class); return component_class_source; } @@ -1448,13 +1446,20 @@ bt_component_class_filter *bt_bt2_component_class_filter_create( PyObject *py_cls, const char *name, const char *description, const char *help) { + bt_component_class_filter *component_class_filter = NULL; + bt_message_iterator_class *message_iterator_class; bt_component_class *component_class; - bt_component_class_filter *component_class_filter; int ret; BT_ASSERT(py_cls); + + message_iterator_class = create_message_iterator_class(); + if (!message_iterator_class) { + goto end; + } + component_class_filter = bt_component_class_filter_create(name, - component_class_message_iterator_next); + message_iterator_class); if (!component_class_filter) { BT_LOGE_STR("Cannot create filter component class."); goto end; @@ -1470,12 +1475,6 @@ bt_component_class_filter *bt_bt2_component_class_filter_create( BT_ASSERT(ret == 0); ret = bt_component_class_filter_set_finalize_method (component_class_filter, component_class_filter_finalize); BT_ASSERT(ret == 0); - ret = bt_component_class_filter_set_message_iterator_seek_beginning_methods(component_class_filter, - component_class_seek_beginning, component_class_can_seek_beginning); - BT_ASSERT(ret == 0); - ret = bt_component_class_filter_set_message_iterator_seek_ns_from_origin_methods( - component_class_filter, component_class_seek_ns_from_origin, - component_class_can_seek_ns_from_origin); ret = bt_component_class_filter_set_input_port_connected_method(component_class_filter, component_class_filter_input_port_connected); BT_ASSERT(ret == 0); @@ -1486,15 +1485,10 @@ bt_component_class_filter *bt_bt2_component_class_filter_create( BT_ASSERT(ret == 0); ret = bt_component_class_filter_set_get_supported_mip_versions_method(component_class_filter, component_class_filter_get_supported_mip_versions); BT_ASSERT(ret == 0); - ret = bt_component_class_filter_set_message_iterator_initialize_method( - component_class_filter, component_class_filter_message_iterator_init); - BT_ASSERT(ret == 0); - ret = bt_component_class_filter_set_message_iterator_finalize_method( - component_class_filter, component_class_message_iterator_finalize); - BT_ASSERT(ret == 0); register_cc_ptr_to_py_cls(component_class, py_cls); end: + bt_message_iterator_class_put_ref(message_iterator_class); return component_class_filter; } diff --git a/src/lib/graph/Makefile.am b/src/lib/graph/Makefile.am index 7a9d63ee..6a24d597 100644 --- a/src/lib/graph/Makefile.am +++ b/src/lib/graph/Makefile.am @@ -25,6 +25,8 @@ libgraph_la_SOURCES = \ interrupter.c \ interrupter.h \ iterator.c \ + message-iterator-class.c \ + message-iterator-class.h \ mip.c \ port.c \ port.h \ diff --git a/src/lib/graph/component-class.c b/src/lib/graph/component-class.c index 5f01158a..ea90b5ce 100644 --- a/src/lib/graph/component-class.c +++ b/src/lib/graph/component-class.c @@ -40,6 +40,7 @@ #include "component-class.h" #include "lib/func-status.h" +#include "lib/graph/message-iterator-class.h" #define BT_ASSERT_PRE_DEV_COMP_CLS_HOT(_cc) \ BT_ASSERT_PRE_DEV_HOT(((const struct bt_component_class *) (_cc)), \ @@ -93,6 +94,24 @@ void destroy_component_class(struct bt_object *obj) class->destroy_listeners = NULL; } + if (class->type == BT_COMPONENT_CLASS_TYPE_SOURCE) { + struct bt_component_class_source *class_src + = container_of(class, struct bt_component_class_source, + parent); + + BT_ASSERT(class_src->msg_iter_cls); + bt_message_iterator_class_put_ref(class_src->msg_iter_cls); + class_src->msg_iter_cls = NULL; + } else if (class->type == BT_COMPONENT_CLASS_TYPE_FILTER) { + struct bt_component_class_filter *class_flt + = container_of(class, struct bt_component_class_filter, + parent); + + BT_ASSERT(class_flt->msg_iter_cls); + bt_message_iterator_class_put_ref(class_flt->msg_iter_cls); + class_flt->msg_iter_cls = NULL; + } + g_free(class); } @@ -147,17 +166,17 @@ end: struct bt_component_class_source *bt_component_class_source_create( const char *name, - bt_component_class_source_message_iterator_next_method method) + struct bt_message_iterator_class *message_iterator_class) { struct bt_component_class_source *source_class = NULL; int ret; BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(name, "Name"); - BT_ASSERT_PRE_NON_NULL(method, "Message iterator next method"); - BT_LOGI("Creating source component class: " - "name=\"%s\", msg-iter-next-method-addr=%p", - name, method); + BT_ASSERT_PRE_NON_NULL(message_iterator_class, "Message iterator class"); + BT_LIB_LOGI("Creating source component class: " + "name=\"%s\", %![msg-iter-cls-]+I", + name, message_iterator_class); source_class = g_new0(struct bt_component_class_source, 1); if (!source_class) { BT_LIB_LOGE_APPEND_CAUSE( @@ -178,7 +197,10 @@ struct bt_component_class_source *bt_component_class_source_create( goto end; } - source_class->methods.msg_iter_next = method; + source_class->msg_iter_cls = message_iterator_class; + bt_message_iterator_class_get_ref(source_class->msg_iter_cls); + bt_message_iterator_class_freeze(source_class->msg_iter_cls); + BT_LIB_LOGI("Created source component class: %!+C", source_class); end: @@ -187,17 +209,17 @@ end: struct bt_component_class_filter *bt_component_class_filter_create( const char *name, - bt_component_class_filter_message_iterator_next_method method) + struct bt_message_iterator_class *message_iterator_class) { struct bt_component_class_filter *filter_class = NULL; int ret; BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(name, "Name"); - BT_ASSERT_PRE_NON_NULL(method, "Message iterator next method"); - BT_LOGI("Creating filter component class: " - "name=\"%s\", msg-iter-next-method-addr=%p", - name, method); + BT_ASSERT_PRE_NON_NULL(message_iterator_class, "Message iterator class"); + BT_LIB_LOGI("Creating filter component class: " + "name=\"%s\", %![msg-iter-cls-]+I", + name, message_iterator_class); filter_class = g_new0(struct bt_component_class_filter, 1); if (!filter_class) { BT_LIB_LOGE_APPEND_CAUSE( @@ -218,7 +240,10 @@ struct bt_component_class_filter *bt_component_class_filter_create( goto end; } - filter_class->methods.msg_iter_next = method; + filter_class->msg_iter_cls = message_iterator_class; + bt_message_iterator_class_get_ref(filter_class->msg_iter_cls); + bt_message_iterator_class_freeze(filter_class->msg_iter_cls); + BT_LIB_LOGI("Created filter component class: %!+C", filter_class); end: @@ -519,134 +544,6 @@ bt_component_class_sink_set_graph_is_configured_method( return BT_FUNC_STATUS_OK; } -enum bt_component_class_set_method_status -bt_component_class_source_set_message_iterator_initialize_method( - struct bt_component_class_source *comp_cls, - bt_component_class_source_message_iterator_initialize_method method) -{ - BT_ASSERT_PRE_NO_ERROR(); - BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class"); - BT_ASSERT_PRE_NON_NULL(method, "Method"); - BT_ASSERT_PRE_DEV_COMP_CLS_HOT(comp_cls); - comp_cls->methods.msg_iter_initialize = method; - BT_LIB_LOGD("Set source component class's message iterator initialization method" - ": %!+C", comp_cls); - return BT_FUNC_STATUS_OK; -} - -enum bt_component_class_set_method_status -bt_component_class_filter_set_message_iterator_initialize_method( - struct bt_component_class_filter *comp_cls, - bt_component_class_filter_message_iterator_initialize_method method) -{ - BT_ASSERT_PRE_NO_ERROR(); - BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class"); - BT_ASSERT_PRE_NON_NULL(method, "Method"); - BT_ASSERT_PRE_DEV_COMP_CLS_HOT(comp_cls); - comp_cls->methods.msg_iter_initialize = method; - BT_LIB_LOGD("Set filter component class's message iterator initialization method" - ": %!+C", comp_cls); - return BT_FUNC_STATUS_OK; -} - -enum bt_component_class_set_method_status -bt_component_class_source_set_message_iterator_finalize_method( - struct bt_component_class_source *comp_cls, - bt_component_class_source_message_iterator_finalize_method method) -{ - BT_ASSERT_PRE_NO_ERROR(); - BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class"); - BT_ASSERT_PRE_NON_NULL(method, "Method"); - BT_ASSERT_PRE_DEV_COMP_CLS_HOT(comp_cls); - comp_cls->methods.msg_iter_finalize = method; - BT_LIB_LOGD("Set source component class's message iterator finalization method" - ": %!+C", comp_cls); - return BT_FUNC_STATUS_OK; -} - -enum bt_component_class_set_method_status -bt_component_class_filter_set_message_iterator_finalize_method( - struct bt_component_class_filter *comp_cls, - bt_component_class_filter_message_iterator_finalize_method method) -{ - BT_ASSERT_PRE_NO_ERROR(); - BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class"); - BT_ASSERT_PRE_NON_NULL(method, "Method"); - BT_ASSERT_PRE_DEV_COMP_CLS_HOT(comp_cls); - comp_cls->methods.msg_iter_finalize = method; - BT_LIB_LOGD("Set filter component class's message iterator finalization method" - ": %!+C", comp_cls); - return BT_FUNC_STATUS_OK; -} - -enum bt_component_class_set_method_status -bt_component_class_filter_set_message_iterator_seek_ns_from_origin_methods( - struct bt_component_class_filter *comp_cls, - bt_component_class_filter_message_iterator_seek_ns_from_origin_method seek_method, - bt_component_class_filter_message_iterator_can_seek_ns_from_origin_method can_seek_method) -{ - BT_ASSERT_PRE_NO_ERROR(); - BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class"); - BT_ASSERT_PRE_NON_NULL(seek_method, "Seek method"); - BT_ASSERT_PRE_DEV_COMP_CLS_HOT(comp_cls); - comp_cls->methods.msg_iter_seek_ns_from_origin = seek_method; - comp_cls->methods.msg_iter_can_seek_ns_from_origin = can_seek_method; - BT_LIB_LOGD("Set filter component class's message iterator \"seek nanoseconds from origin\" method" - ": %!+C", comp_cls); - return BT_FUNC_STATUS_OK; -} - -enum bt_component_class_set_method_status -bt_component_class_source_set_message_iterator_seek_ns_from_origin_methods( - struct bt_component_class_source *comp_cls, - bt_component_class_source_message_iterator_seek_ns_from_origin_method seek_method, - bt_component_class_source_message_iterator_can_seek_ns_from_origin_method can_seek_method) -{ - BT_ASSERT_PRE_NO_ERROR(); - BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class"); - BT_ASSERT_PRE_NON_NULL(seek_method, "Seek method"); - BT_ASSERT_PRE_DEV_COMP_CLS_HOT(comp_cls); - comp_cls->methods.msg_iter_seek_ns_from_origin = seek_method; - comp_cls->methods.msg_iter_can_seek_ns_from_origin = can_seek_method; - BT_LIB_LOGD("Set source component class's message iterator \"seek nanoseconds from origin\" methods" - ": %!+C", comp_cls); - return BT_FUNC_STATUS_OK; -} - -enum bt_component_class_set_method_status -bt_component_class_filter_set_message_iterator_seek_beginning_methods( - struct bt_component_class_filter *comp_cls, - bt_component_class_filter_message_iterator_seek_beginning_method seek_method, - bt_component_class_filter_message_iterator_can_seek_beginning_method can_seek_method) -{ - BT_ASSERT_PRE_NO_ERROR(); - BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class"); - BT_ASSERT_PRE_NON_NULL(seek_method, "Seek method"); - BT_ASSERT_PRE_DEV_COMP_CLS_HOT(comp_cls); - comp_cls->methods.msg_iter_seek_beginning = seek_method; - comp_cls->methods.msg_iter_can_seek_beginning = can_seek_method; - BT_LIB_LOGD("Set filter component class's message iterator \"seek beginning\" methods" - ": %!+C", comp_cls); - return BT_FUNC_STATUS_OK; -} - -enum bt_component_class_set_method_status -bt_component_class_source_set_message_iterator_seek_beginning_methods( - struct bt_component_class_source *comp_cls, - bt_component_class_source_message_iterator_seek_beginning_method seek_method, - bt_component_class_source_message_iterator_can_seek_beginning_method can_seek_method) -{ - BT_ASSERT_PRE_NO_ERROR(); - BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class"); - BT_ASSERT_PRE_NON_NULL(seek_method, "Seek method"); - BT_ASSERT_PRE_DEV_COMP_CLS_HOT(comp_cls); - comp_cls->methods.msg_iter_seek_beginning = seek_method; - comp_cls->methods.msg_iter_can_seek_beginning = can_seek_method; - BT_LIB_LOGD("Set source component class's message iterator \"seek beginning\" methods" - ": %!+C", comp_cls); - return BT_FUNC_STATUS_OK; -} - enum bt_component_class_set_description_status bt_component_class_set_description( struct bt_component_class *comp_cls, diff --git a/src/lib/graph/component-class.h b/src/lib/graph/component-class.h index 359d8595..2b4b9454 100644 --- a/src/lib/graph/component-class.h +++ b/src/lib/graph/component-class.h @@ -70,16 +70,10 @@ struct bt_component_class_source { bt_component_class_source_get_supported_mip_versions_method get_supported_mip_versions; bt_component_class_source_initialize_method init; bt_component_class_source_finalize_method finalize; - bt_component_class_source_message_iterator_initialize_method msg_iter_initialize; - bt_component_class_source_message_iterator_finalize_method msg_iter_finalize; - bt_component_class_source_message_iterator_next_method msg_iter_next; - bt_component_class_source_message_iterator_seek_ns_from_origin_method msg_iter_seek_ns_from_origin; - bt_component_class_source_message_iterator_seek_beginning_method msg_iter_seek_beginning; - bt_component_class_source_message_iterator_can_seek_ns_from_origin_method msg_iter_can_seek_ns_from_origin; - bt_component_class_source_message_iterator_can_seek_beginning_method msg_iter_can_seek_beginning; bt_component_class_source_query_method query; bt_component_class_source_output_port_connected_method output_port_connected; } methods; + bt_message_iterator_class *msg_iter_cls; }; struct bt_component_class_sink { @@ -101,17 +95,11 @@ struct bt_component_class_filter { bt_component_class_filter_get_supported_mip_versions_method get_supported_mip_versions; bt_component_class_filter_initialize_method init; bt_component_class_filter_finalize_method finalize; - bt_component_class_filter_message_iterator_initialize_method msg_iter_initialize; - bt_component_class_filter_message_iterator_finalize_method msg_iter_finalize; - bt_component_class_filter_message_iterator_next_method msg_iter_next; - bt_component_class_filter_message_iterator_seek_ns_from_origin_method msg_iter_seek_ns_from_origin; - bt_component_class_filter_message_iterator_seek_beginning_method msg_iter_seek_beginning; - bt_component_class_filter_message_iterator_can_seek_ns_from_origin_method msg_iter_can_seek_ns_from_origin; - bt_component_class_filter_message_iterator_can_seek_beginning_method msg_iter_can_seek_beginning; bt_component_class_filter_query_method query; bt_component_class_filter_input_port_connected_method input_port_connected; bt_component_class_filter_output_port_connected_method output_port_connected; } methods; + bt_message_iterator_class *msg_iter_cls; }; BT_HIDDEN diff --git a/src/lib/graph/iterator.c b/src/lib/graph/iterator.c index 3ef5fd57..4dd69c6a 100644 --- a/src/lib/graph/iterator.c +++ b/src/lib/graph/iterator.c @@ -69,6 +69,7 @@ #include "component-source.h" #include "connection.h" #include "graph.h" +#include "message-iterator-class.h" #include "message/discarded-items.h" #include "message/event.h" #include "message/iterator.h" @@ -169,7 +170,6 @@ void bt_self_component_port_input_message_iterator_try_finalize( struct bt_self_component_port_input_message_iterator *iterator) { uint64_t i; - typedef void (*method_t)(void *); bool call_user_finalize = true; BT_ASSERT(iterator); @@ -209,6 +209,7 @@ void bt_self_component_port_input_message_iterator_try_finalize( /* Call user-defined destroy method */ if (call_user_finalize) { + typedef void (*method_t)(void *); method_t method = NULL; struct bt_component_class *comp_class = iterator->upstream_component->class; @@ -219,7 +220,7 @@ void bt_self_component_port_input_message_iterator_try_finalize( struct bt_component_class_source *src_comp_cls = (void *) comp_class; - method = (method_t) src_comp_cls->methods.msg_iter_finalize; + method = (method_t) src_comp_cls->msg_iter_cls->methods.finalize; break; } case BT_COMPONENT_CLASS_TYPE_FILTER: @@ -227,7 +228,7 @@ void bt_self_component_port_input_message_iterator_try_finalize( struct bt_component_class_filter *flt_comp_cls = (void *) comp_class; - method = (method_t) flt_comp_cls->methods.msg_iter_finalize; + method = (method_t) flt_comp_cls->msg_iter_cls->methods.finalize; break; } default: @@ -318,10 +319,7 @@ int create_self_component_input_port_message_iterator( struct bt_self_component_port_input *self_port, struct bt_self_component_port_input_message_iterator **message_iterator) { - typedef enum bt_component_class_message_iterator_initialize_method_status (*init_method_t)( - void *, void *, void *, void *); - - init_method_t init_method = NULL; + bt_message_iterator_class_initialize_method init_method = NULL; struct bt_self_component_port_input_message_iterator *iterator = NULL; struct bt_self_component_port_input_message_iterator *downstream_msg_iter = @@ -409,19 +407,19 @@ int create_self_component_input_port_message_iterator( iterator->methods.next = (bt_self_component_port_input_message_iterator_next_method) - src_comp_cls->methods.msg_iter_next; + src_comp_cls->msg_iter_cls->methods.next; iterator->methods.seek_ns_from_origin = (bt_self_component_port_input_message_iterator_seek_ns_from_origin_method) - src_comp_cls->methods.msg_iter_seek_ns_from_origin; + src_comp_cls->msg_iter_cls->methods.seek_ns_from_origin; iterator->methods.seek_beginning = (bt_self_component_port_input_message_iterator_seek_beginning_method) - src_comp_cls->methods.msg_iter_seek_beginning; + src_comp_cls->msg_iter_cls->methods.seek_beginning; iterator->methods.can_seek_ns_from_origin = (bt_self_component_port_input_message_iterator_can_seek_ns_from_origin_method) - src_comp_cls->methods.msg_iter_can_seek_ns_from_origin; + src_comp_cls->msg_iter_cls->methods.can_seek_ns_from_origin; iterator->methods.can_seek_beginning = (bt_self_component_port_input_message_iterator_can_seek_beginning_method) - src_comp_cls->methods.msg_iter_can_seek_beginning; + src_comp_cls->msg_iter_cls->methods.can_seek_beginning; break; } case BT_COMPONENT_CLASS_TYPE_FILTER: @@ -431,19 +429,19 @@ int create_self_component_input_port_message_iterator( iterator->methods.next = (bt_self_component_port_input_message_iterator_next_method) - flt_comp_cls->methods.msg_iter_next; + flt_comp_cls->msg_iter_cls->methods.next; iterator->methods.seek_ns_from_origin = (bt_self_component_port_input_message_iterator_seek_ns_from_origin_method) - flt_comp_cls->methods.msg_iter_seek_ns_from_origin; + flt_comp_cls->msg_iter_cls->methods.seek_ns_from_origin; iterator->methods.seek_beginning = (bt_self_component_port_input_message_iterator_seek_beginning_method) - flt_comp_cls->methods.msg_iter_seek_beginning; + flt_comp_cls->msg_iter_cls->methods.seek_beginning; iterator->methods.can_seek_ns_from_origin = (bt_self_component_port_input_message_iterator_can_seek_ns_from_origin_method) - flt_comp_cls->methods.msg_iter_can_seek_ns_from_origin; + flt_comp_cls->msg_iter_cls->methods.can_seek_ns_from_origin; iterator->methods.can_seek_beginning = (bt_self_component_port_input_message_iterator_can_seek_beginning_method) - flt_comp_cls->methods.msg_iter_can_seek_beginning; + flt_comp_cls->msg_iter_cls->methods.can_seek_beginning; break; } default: @@ -470,8 +468,7 @@ int create_self_component_input_port_message_iterator( struct bt_component_class_source *src_comp_cls = (void *) upstream_comp_cls; - init_method = - (init_method_t) src_comp_cls->methods.msg_iter_initialize; + init_method = src_comp_cls->msg_iter_cls->methods.initialize; break; } case BT_COMPONENT_CLASS_TYPE_FILTER: @@ -479,8 +476,7 @@ int create_self_component_input_port_message_iterator( struct bt_component_class_filter *flt_comp_cls = (void *) upstream_comp_cls; - init_method = - (init_method_t) flt_comp_cls->methods.msg_iter_initialize; + init_method = flt_comp_cls->msg_iter_cls->methods.initialize; break; } default: @@ -489,11 +485,14 @@ int create_self_component_input_port_message_iterator( } if (init_method) { - enum bt_component_class_message_iterator_initialize_method_status iter_status; + enum bt_message_iterator_class_initialize_method_status iter_status; BT_LIB_LOGD("Calling user's initialization method: %!+i", iterator); - iter_status = init_method(iterator, &iterator->config, upstream_comp, - upstream_port); + iter_status = init_method( + (struct bt_self_message_iterator *) iterator, + &iterator->config, + (struct bt_self_component *) upstream_comp, + (struct bt_self_component_port_output *) upstream_port); BT_LOGD("User method returned: status=%s", bt_common_func_status_string(iter_status)); BT_ASSERT_POST_NO_ERROR_IF_NO_ERROR_STATUS(iter_status); @@ -871,12 +870,12 @@ end: */ static -enum bt_component_class_message_iterator_next_method_status +enum bt_message_iterator_class_next_method_status call_iterator_next_method( struct bt_self_component_port_input_message_iterator *iterator, bt_message_array_const msgs, uint64_t capacity, uint64_t *user_count) { - enum bt_component_class_message_iterator_next_method_status status; + enum bt_message_iterator_class_next_method_status status; BT_ASSERT_DBG(iterator->methods.next); BT_LOGD_STR("Calling user's \"next\" method."); @@ -1670,7 +1669,7 @@ end: */ static -enum bt_component_class_message_iterator_next_method_status post_auto_seek_next( +enum bt_message_iterator_class_next_method_status post_auto_seek_next( struct bt_self_component_port_input_message_iterator *iterator, bt_message_array_const msgs, uint64_t capacity, uint64_t *count) @@ -1763,7 +1762,7 @@ bt_self_component_port_input_message_iterator_seek_ns_from_origin( /* Check if the iterator can seek by itself. If not we'll use autoseek. */ if (iterator->methods.can_seek_ns_from_origin) { - bt_component_class_message_iterator_can_seek_ns_from_origin_method_status + bt_message_iterator_class_can_seek_ns_from_origin_method_status can_seek_status; can_seek_status = @@ -1805,8 +1804,7 @@ bt_self_component_port_input_message_iterator_seek_ns_from_origin( * particular time. We will seek to the beginning and fast * forward to the right place. */ - enum bt_component_class_message_iterator_can_seek_beginning_method_status - can_seek_status; + enum bt_message_iterator_class_can_seek_beginning_method_status can_seek_status; bt_bool can_seek_beginning; can_seek_status = iterator->methods.can_seek_beginning(iterator, diff --git a/src/lib/graph/message-iterator-class.c b/src/lib/graph/message-iterator-class.c new file mode 100644 index 00000000..054d4a4a --- /dev/null +++ b/src/lib/graph/message-iterator-class.c @@ -0,0 +1,157 @@ +/* + * Copyright 2019 EfficiOS, Inc. + * + * 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/MESSAGE-ITERATOR-CLASS" +#include "lib/logging.h" + +#include "message-iterator-class.h" + +#include "compat/compiler.h" +#include "lib/assert-pre.h" +#include "lib/func-status.h" + +#define BT_ASSERT_PRE_DEV_MSG_ITER_CLS_HOT(_msg_iter_cls) \ + BT_ASSERT_PRE_DEV_HOT((_msg_iter_cls), \ + "Message iterator class", ": %!+I", (_msg_iter_cls)) + +BT_HIDDEN +void _bt_message_iterator_class_freeze( + const struct bt_message_iterator_class *msg_iter_cls) +{ + BT_ASSERT(msg_iter_cls); + BT_LIB_LOGD("Freezing message iterator class: %!+I", msg_iter_cls); + ((struct bt_message_iterator_class *) msg_iter_cls)->frozen = true; +} + +void bt_message_iterator_class_get_ref( + const bt_message_iterator_class *message_iterator_class) +{ + bt_object_get_ref(message_iterator_class); +} + +void bt_message_iterator_class_put_ref( + const bt_message_iterator_class *message_iterator_class) +{ + bt_object_put_ref(message_iterator_class); +} + +static +void destroy_iterator_class(struct bt_object *obj) +{ + struct bt_message_iterator_class *class; + + BT_ASSERT(obj); + class = container_of(obj, struct bt_message_iterator_class, base); + + BT_LIB_LOGI("Destroying message iterator class: %!+I", class); + + g_free(class); +} + +struct bt_message_iterator_class *bt_message_iterator_class_create( + bt_message_iterator_class_next_method next_method) +{ + struct bt_message_iterator_class *message_iterator_class; + + BT_ASSERT_PRE_NO_ERROR(); + BT_ASSERT_PRE_NON_NULL(next_method, "Next method"); + BT_LOGI("Creating message iterator class: next-method-addr=%p", + next_method); + + message_iterator_class = g_new0(struct bt_message_iterator_class, 1); + if (!message_iterator_class) { + BT_LIB_LOGE_APPEND_CAUSE( + "Failed to allocate one message iterator class."); + goto end; + } + + bt_object_init_shared(&message_iterator_class->base, destroy_iterator_class); + + message_iterator_class->methods.next = next_method; + +end: + return message_iterator_class; +} + +bt_message_iterator_class_set_method_status +bt_message_iterator_class_set_initialize_method( + bt_message_iterator_class *message_iterator_class, + bt_message_iterator_class_initialize_method method) +{ + BT_ASSERT_PRE_NO_ERROR(); + BT_ASSERT_PRE_NON_NULL(message_iterator_class, "Message iterator class"); + BT_ASSERT_PRE_NON_NULL(method, "Method"); + BT_ASSERT_PRE_DEV_MSG_ITER_CLS_HOT(message_iterator_class); + message_iterator_class->methods.initialize = method; + BT_LIB_LOGD("Set message iterator class's iterator initialization method" + ": %!+I", message_iterator_class); + return BT_FUNC_STATUS_OK; +} + +bt_message_iterator_class_set_method_status +bt_message_iterator_class_set_finalize_method( + bt_message_iterator_class *message_iterator_class, + bt_message_iterator_class_finalize_method method) +{ + BT_ASSERT_PRE_NO_ERROR(); + BT_ASSERT_PRE_NON_NULL(message_iterator_class, "Message iterator class"); + BT_ASSERT_PRE_NON_NULL(method, "Method"); + BT_ASSERT_PRE_DEV_MSG_ITER_CLS_HOT(message_iterator_class); + message_iterator_class->methods.finalize = method; + BT_LIB_LOGD("Set message iterator class's finalization method" + ": %!+I", message_iterator_class); + return BT_FUNC_STATUS_OK; +} + +bt_message_iterator_class_set_method_status +bt_message_iterator_class_set_seek_ns_from_origin_methods( + bt_message_iterator_class *message_iterator_class, + bt_message_iterator_class_seek_ns_from_origin_method seek_method, + bt_message_iterator_class_can_seek_ns_from_origin_method can_seek_method) +{ + BT_ASSERT_PRE_NO_ERROR(); + BT_ASSERT_PRE_NON_NULL(message_iterator_class, "Message iterator class"); + BT_ASSERT_PRE_NON_NULL(seek_method, "Seek method"); + BT_ASSERT_PRE_DEV_MSG_ITER_CLS_HOT(message_iterator_class); + message_iterator_class->methods.seek_ns_from_origin = seek_method; + message_iterator_class->methods.can_seek_ns_from_origin = can_seek_method; + BT_LIB_LOGD("Set message iterator class's \"seek nanoseconds from origin\" method" + ": %!+I", message_iterator_class); + return BT_FUNC_STATUS_OK; +} + +bt_message_iterator_class_set_method_status +bt_message_iterator_class_set_seek_beginning_methods( + bt_message_iterator_class *message_iterator_class, + bt_message_iterator_class_seek_beginning_method seek_method, + bt_message_iterator_class_can_seek_beginning_method can_seek_method) +{ + BT_ASSERT_PRE_NO_ERROR(); + BT_ASSERT_PRE_NON_NULL(message_iterator_class, "Message iterator class"); + BT_ASSERT_PRE_NON_NULL(seek_method, "Seek method"); + BT_ASSERT_PRE_DEV_MSG_ITER_CLS_HOT(message_iterator_class); + message_iterator_class->methods.seek_beginning = seek_method; + message_iterator_class->methods.can_seek_beginning = can_seek_method; + BT_LIB_LOGD("Set message iterator class's \"seek beginning\" methods" + ": %!+C", message_iterator_class); + return BT_FUNC_STATUS_OK; +} diff --git a/src/lib/graph/message-iterator-class.h b/src/lib/graph/message-iterator-class.h new file mode 100644 index 00000000..198f2fa6 --- /dev/null +++ b/src/lib/graph/message-iterator-class.h @@ -0,0 +1,61 @@ +#ifndef BABELTRACE_GRAPH_MESSAGE_ITERATOR_CLASS_INTERNAL_H +#define BABELTRACE_GRAPH_MESSAGE_ITERATOR_CLASS_INTERNAL_H + +/* + * Copyright 2017-2018 Philippe Proulx + * Copyright 2015 Jérémie Galarneau + * + * Author: Jérémie Galarneau + * + * 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 "common/macros.h" +#include "lib/object.h" +#include +#include + +struct bt_message_iterator_class { + struct bt_object base; + bool frozen; + + struct { + bt_message_iterator_class_initialize_method initialize; + bt_message_iterator_class_finalize_method finalize; + bt_message_iterator_class_next_method next; + bt_message_iterator_class_seek_ns_from_origin_method seek_ns_from_origin; + bt_message_iterator_class_seek_beginning_method seek_beginning; + bt_message_iterator_class_can_seek_ns_from_origin_method can_seek_ns_from_origin; + bt_message_iterator_class_can_seek_beginning_method can_seek_beginning; + } methods; +}; + +BT_HIDDEN +void _bt_message_iterator_class_freeze( + const struct bt_message_iterator_class *message_iterator_class); + +#ifdef BT_DEV_MODE +# define bt_message_iterator_class_freeze _bt_message_iterator_class_freeze +#else +# define bt_message_iterator_class_freeze(_cls) +#endif + +#endif /* BABELTRACE_GRAPH_MESSAGE_ITERATOR_CLASS_INTERNAL_H */ diff --git a/src/lib/graph/message/iterator.h b/src/lib/graph/message/iterator.h index 52a1c046..894a914c 100644 --- a/src/lib/graph/message/iterator.h +++ b/src/lib/graph/message/iterator.h @@ -65,23 +65,23 @@ enum bt_self_component_port_input_message_iterator_state { BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_LAST_SEEKING_RETURNED_ERROR, }; -typedef enum bt_component_class_message_iterator_next_method_status +typedef enum bt_message_iterator_class_next_method_status (*bt_self_component_port_input_message_iterator_next_method)( void *, bt_message_array_const, uint64_t, uint64_t *); -typedef enum bt_component_class_message_iterator_seek_ns_from_origin_method_status +typedef enum bt_message_iterator_class_seek_ns_from_origin_method_status (*bt_self_component_port_input_message_iterator_seek_ns_from_origin_method)( void *, int64_t); -typedef enum bt_component_class_message_iterator_seek_beginning_method_status +typedef enum bt_message_iterator_class_seek_beginning_method_status (*bt_self_component_port_input_message_iterator_seek_beginning_method)( void *); -typedef enum bt_component_class_message_iterator_can_seek_ns_from_origin_method_status +typedef enum bt_message_iterator_class_can_seek_ns_from_origin_method_status (*bt_self_component_port_input_message_iterator_can_seek_ns_from_origin_method)( void *, int64_t, bt_bool *); -typedef enum bt_component_class_message_iterator_can_seek_beginning_method_status +typedef enum bt_message_iterator_class_can_seek_beginning_method_status (*bt_self_component_port_input_message_iterator_can_seek_beginning_method)( void *, bt_bool *); diff --git a/src/lib/lib-logging.c b/src/lib/lib-logging.c index 242f88d6..02f18ed5 100644 --- a/src/lib/lib-logging.c +++ b/src/lib/lib-logging.c @@ -1198,6 +1198,13 @@ static inline void format_graph(char **buf_ch, bool extended, &graph->packet_end_msg_pool); } +static inline void format_message_iterator_class(char **buf_ch, + bool extended, const char *prefix, + const struct bt_message_iterator_class *iterator_class) +{ + /* Empty, the address is automatically printed. */ +} + static inline void format_message_iterator(char **buf_ch, bool extended, const char *prefix, const struct bt_message_iterator *iterator) @@ -1447,6 +1454,9 @@ static inline void handle_conversion_specifier_bt(void *priv_data, case 'n': format_message(buf_ch, extended, prefix, obj); break; + case 'I': + format_message_iterator_class(buf_ch, extended, prefix, obj); + break; case 'i': format_message_iterator(buf_ch, extended, prefix, obj); break; diff --git a/src/lib/plugin/plugin-so.c b/src/lib/plugin/plugin-so.c index 60f3e4da..ebdbf823 100644 --- a/src/lib/plugin/plugin-so.c +++ b/src/lib/plugin/plugin-so.c @@ -294,12 +294,12 @@ int bt_plugin_so_init(struct bt_plugin *plugin, bt_component_class_source_finalize_method finalize; bt_component_class_source_query_method query; bt_component_class_source_output_port_connected_method output_port_connected; - bt_component_class_source_message_iterator_initialize_method msg_iter_initialize; - bt_component_class_source_message_iterator_finalize_method msg_iter_finalize; - bt_component_class_source_message_iterator_seek_ns_from_origin_method msg_iter_seek_ns_from_origin; - bt_component_class_source_message_iterator_seek_beginning_method msg_iter_seek_beginning; - bt_component_class_source_message_iterator_can_seek_ns_from_origin_method msg_iter_can_seek_ns_from_origin; - bt_component_class_source_message_iterator_can_seek_beginning_method msg_iter_can_seek_beginning; + bt_message_iterator_class_initialize_method msg_iter_initialize; + bt_message_iterator_class_finalize_method msg_iter_finalize; + bt_message_iterator_class_seek_ns_from_origin_method msg_iter_seek_ns_from_origin; + bt_message_iterator_class_seek_beginning_method msg_iter_seek_beginning; + bt_message_iterator_class_can_seek_ns_from_origin_method msg_iter_can_seek_ns_from_origin; + bt_message_iterator_class_can_seek_beginning_method msg_iter_can_seek_beginning; } source; struct { @@ -309,12 +309,12 @@ int bt_plugin_so_init(struct bt_plugin *plugin, bt_component_class_filter_query_method query; bt_component_class_filter_input_port_connected_method input_port_connected; bt_component_class_filter_output_port_connected_method output_port_connected; - bt_component_class_filter_message_iterator_initialize_method msg_iter_initialize; - bt_component_class_filter_message_iterator_finalize_method msg_iter_finalize; - bt_component_class_filter_message_iterator_seek_ns_from_origin_method msg_iter_seek_ns_from_origin; - bt_component_class_filter_message_iterator_seek_beginning_method msg_iter_seek_beginning; - bt_component_class_filter_message_iterator_can_seek_ns_from_origin_method msg_iter_can_seek_ns_from_origin; - bt_component_class_filter_message_iterator_can_seek_beginning_method msg_iter_can_seek_beginning; + bt_message_iterator_class_initialize_method msg_iter_initialize; + bt_message_iterator_class_finalize_method msg_iter_finalize; + bt_message_iterator_class_seek_ns_from_origin_method msg_iter_seek_ns_from_origin; + bt_message_iterator_class_seek_beginning_method msg_iter_seek_beginning; + bt_message_iterator_class_can_seek_ns_from_origin_method msg_iter_can_seek_ns_from_origin; + bt_message_iterator_class_can_seek_beginning_method msg_iter_can_seek_beginning; } filter; struct { @@ -336,6 +336,7 @@ int bt_plugin_so_init(struct bt_plugin *plugin, GArray *comp_class_full_descriptors; size_t i; int ret; + struct bt_message_iterator_class *msg_iter_class = NULL; BT_LOGI("Initializing plugin object from descriptors found in sections: " "plugin-addr=%p, plugin-path=\"%s\", " @@ -606,11 +607,11 @@ int bt_plugin_so_init(struct bt_plugin *plugin, switch (cc_type) { case BT_COMPONENT_CLASS_TYPE_SOURCE: cc_full_descr->methods.source.msg_iter_initialize = - cur_cc_descr_attr->value.source_msg_iter_initialize_method; + cur_cc_descr_attr->value.msg_iter_initialize_method; break; case BT_COMPONENT_CLASS_TYPE_FILTER: cc_full_descr->methods.filter.msg_iter_initialize = - cur_cc_descr_attr->value.filter_msg_iter_initialize_method; + cur_cc_descr_attr->value.msg_iter_initialize_method; break; default: bt_common_abort(); @@ -620,11 +621,11 @@ int bt_plugin_so_init(struct bt_plugin *plugin, switch (cc_type) { case BT_COMPONENT_CLASS_TYPE_SOURCE: cc_full_descr->methods.source.msg_iter_finalize = - cur_cc_descr_attr->value.source_msg_iter_finalize_method; + cur_cc_descr_attr->value.msg_iter_finalize_method; break; case BT_COMPONENT_CLASS_TYPE_FILTER: cc_full_descr->methods.filter.msg_iter_finalize = - cur_cc_descr_attr->value.filter_msg_iter_finalize_method; + cur_cc_descr_attr->value.msg_iter_finalize_method; break; default: bt_common_abort(); @@ -634,11 +635,11 @@ int bt_plugin_so_init(struct bt_plugin *plugin, switch (cc_type) { case BT_COMPONENT_CLASS_TYPE_SOURCE: cc_full_descr->methods.source.msg_iter_seek_ns_from_origin = - cur_cc_descr_attr->value.source_msg_iter_seek_ns_from_origin_method; + cur_cc_descr_attr->value.msg_iter_seek_ns_from_origin_method; break; case BT_COMPONENT_CLASS_TYPE_FILTER: cc_full_descr->methods.filter.msg_iter_seek_ns_from_origin = - cur_cc_descr_attr->value.filter_msg_iter_seek_ns_from_origin_method; + cur_cc_descr_attr->value.msg_iter_seek_ns_from_origin_method; break; default: bt_common_abort(); @@ -648,11 +649,11 @@ int bt_plugin_so_init(struct bt_plugin *plugin, switch (cc_type) { case BT_COMPONENT_CLASS_TYPE_SOURCE: cc_full_descr->methods.source.msg_iter_seek_beginning = - cur_cc_descr_attr->value.source_msg_iter_seek_beginning_method; + cur_cc_descr_attr->value.msg_iter_seek_beginning_method; break; case BT_COMPONENT_CLASS_TYPE_FILTER: cc_full_descr->methods.filter.msg_iter_seek_beginning = - cur_cc_descr_attr->value.filter_msg_iter_seek_beginning_method; + cur_cc_descr_attr->value.msg_iter_seek_beginning_method; break; default: bt_common_abort(); @@ -662,11 +663,11 @@ int bt_plugin_so_init(struct bt_plugin *plugin, switch (cc_type) { case BT_COMPONENT_CLASS_TYPE_SOURCE: cc_full_descr->methods.source.msg_iter_can_seek_ns_from_origin = - cur_cc_descr_attr->value.source_msg_iter_can_seek_ns_from_origin_method; + cur_cc_descr_attr->value.msg_iter_can_seek_ns_from_origin_method; break; case BT_COMPONENT_CLASS_TYPE_FILTER: cc_full_descr->methods.filter.msg_iter_can_seek_ns_from_origin = - cur_cc_descr_attr->value.filter_msg_iter_can_seek_ns_from_origin_method; + cur_cc_descr_attr->value.msg_iter_can_seek_ns_from_origin_method; break; default: bt_common_abort(); @@ -676,11 +677,11 @@ int bt_plugin_so_init(struct bt_plugin *plugin, switch (cc_type) { case BT_COMPONENT_CLASS_TYPE_SOURCE: cc_full_descr->methods.source.msg_iter_can_seek_beginning = - cur_cc_descr_attr->value.source_msg_iter_can_seek_beginning_method; + cur_cc_descr_attr->value.msg_iter_can_seek_beginning_method; break; case BT_COMPONENT_CLASS_TYPE_FILTER: cc_full_descr->methods.filter.msg_iter_can_seek_beginning = - cur_cc_descr_attr->value.filter_msg_iter_can_seek_beginning_method; + cur_cc_descr_attr->value.msg_iter_can_seek_beginning_method; break; default: bt_common_abort(); @@ -784,22 +785,111 @@ int bt_plugin_so_init(struct bt_plugin *plugin, bt_component_class_type_string( cc_full_descr->descriptor->type)); + if (cc_full_descr->descriptor->type == BT_COMPONENT_CLASS_TYPE_SOURCE || + cc_full_descr->descriptor->type == BT_COMPONENT_CLASS_TYPE_FILTER) { + bt_message_iterator_class_next_method next_method; + bt_message_iterator_class_initialize_method init_method; + bt_message_iterator_class_finalize_method fini_method; + bt_message_iterator_class_seek_ns_from_origin_method seek_ns_from_origin_method; + bt_message_iterator_class_seek_beginning_method seek_beginning_method; + bt_message_iterator_class_can_seek_ns_from_origin_method can_seek_ns_from_origin_method; + bt_message_iterator_class_can_seek_beginning_method can_seek_beginning_method; + + if (cc_full_descr->descriptor->type == BT_COMPONENT_CLASS_TYPE_SOURCE) { + next_method = cc_full_descr->descriptor->methods.source.msg_iter_next; + init_method = cc_full_descr->methods.source.msg_iter_initialize; + fini_method = cc_full_descr->methods.source.msg_iter_finalize; + seek_ns_from_origin_method = cc_full_descr->methods.source.msg_iter_seek_ns_from_origin; + can_seek_ns_from_origin_method = cc_full_descr->methods.source.msg_iter_can_seek_ns_from_origin; + seek_beginning_method = cc_full_descr->methods.source.msg_iter_seek_beginning; + can_seek_beginning_method = cc_full_descr->methods.source.msg_iter_can_seek_beginning; + } else { + next_method = cc_full_descr->descriptor->methods.filter.msg_iter_next; + init_method = cc_full_descr->methods.filter.msg_iter_initialize; + fini_method = cc_full_descr->methods.filter.msg_iter_finalize; + seek_ns_from_origin_method = cc_full_descr->methods.filter.msg_iter_seek_ns_from_origin; + can_seek_ns_from_origin_method = cc_full_descr->methods.filter.msg_iter_can_seek_ns_from_origin; + seek_beginning_method = cc_full_descr->methods.filter.msg_iter_seek_beginning; + can_seek_beginning_method = cc_full_descr->methods.filter.msg_iter_can_seek_beginning; + } + + msg_iter_class = bt_message_iterator_class_create(next_method); + if (!msg_iter_class) { + BT_LIB_LOGE_APPEND_CAUSE( + "Cannot create message iterator class."); + status = BT_FUNC_STATUS_MEMORY_ERROR; + goto end; + } + + if (init_method) { + ret = bt_message_iterator_class_set_initialize_method( + msg_iter_class, init_method); + if (ret) { + BT_LIB_LOGE_APPEND_CAUSE( + "Cannot set message iterator initialization method."); + status = BT_FUNC_STATUS_MEMORY_ERROR; + goto end; + } + } + + if (fini_method) { + ret = bt_message_iterator_class_set_finalize_method( + msg_iter_class, fini_method); + if (ret) { + BT_LIB_LOGE_APPEND_CAUSE( + "Cannot set message iterator finalization method."); + status = BT_FUNC_STATUS_MEMORY_ERROR; + goto end; + } + } + + if (seek_ns_from_origin_method) { + ret = bt_message_iterator_class_set_seek_ns_from_origin_methods( + msg_iter_class, + seek_ns_from_origin_method, + can_seek_ns_from_origin_method); + if (ret) { + BT_LIB_LOGE_APPEND_CAUSE( + "Cannot set message iterator \"seek nanoseconds from origin\" methods."); + status = BT_FUNC_STATUS_MEMORY_ERROR; + goto end; + } + } + + if (seek_beginning_method) { + ret = bt_message_iterator_class_set_seek_beginning_methods( + msg_iter_class, + seek_beginning_method, + can_seek_beginning_method); + if (ret) { + BT_LIB_LOGE_APPEND_CAUSE( + "Cannot set message iterator \"seek beginning\" methods."); + status = BT_FUNC_STATUS_MEMORY_ERROR; + goto end; + } + } + } + switch (cc_full_descr->descriptor->type) { case BT_COMPONENT_CLASS_TYPE_SOURCE: + BT_ASSERT(msg_iter_class); + src_comp_class = bt_component_class_source_create( - cc_full_descr->descriptor->name, - cc_full_descr->descriptor->methods.source.msg_iter_next); + cc_full_descr->descriptor->name, msg_iter_class); comp_class = bt_component_class_source_as_component_class( src_comp_class); break; case BT_COMPONENT_CLASS_TYPE_FILTER: + BT_ASSERT(msg_iter_class); + flt_comp_class = bt_component_class_filter_create( - cc_full_descr->descriptor->name, - cc_full_descr->descriptor->methods.source.msg_iter_next); + cc_full_descr->descriptor->name, msg_iter_class); comp_class = bt_component_class_filter_as_component_class( flt_comp_class); break; case BT_COMPONENT_CLASS_TYPE_SINK: + BT_ASSERT(!msg_iter_class); + sink_comp_class = bt_component_class_sink_create( cc_full_descr->descriptor->name, cc_full_descr->descriptor->methods.sink.consume); @@ -842,6 +932,15 @@ int bt_plugin_so_init(struct bt_plugin *plugin, goto end; } + /* + * The component class has taken a reference on the message + * iterator class, so we can drop ours. The message iterator + * class will get destroyed at the same time as the component + * class. + */ + bt_message_iterator_class_put_ref(msg_iter_class); + msg_iter_class = NULL; + if (cc_full_descr->description) { ret = bt_component_class_set_description( comp_class, cc_full_descr->description); @@ -933,60 +1032,6 @@ int bt_plugin_so_init(struct bt_plugin *plugin, } } - if (cc_full_descr->methods.source.msg_iter_initialize) { - ret = bt_component_class_source_set_message_iterator_initialize_method( - src_comp_class, - cc_full_descr->methods.source.msg_iter_initialize); - if (ret) { - BT_LIB_LOGE_APPEND_CAUSE( - "Cannot set source component class's message iterator initialization method."); - status = BT_FUNC_STATUS_MEMORY_ERROR; - BT_OBJECT_PUT_REF_AND_RESET(src_comp_class); - goto end; - } - } - - if (cc_full_descr->methods.source.msg_iter_finalize) { - ret = bt_component_class_source_set_message_iterator_finalize_method( - src_comp_class, - cc_full_descr->methods.source.msg_iter_finalize); - if (ret) { - BT_LIB_LOGE_APPEND_CAUSE( - "Cannot set source component class's message iterator finalization method."); - status = BT_FUNC_STATUS_MEMORY_ERROR; - BT_OBJECT_PUT_REF_AND_RESET(src_comp_class); - goto end; - } - } - - if (cc_full_descr->methods.source.msg_iter_seek_ns_from_origin) { - ret = bt_component_class_source_set_message_iterator_seek_ns_from_origin_methods( - src_comp_class, - cc_full_descr->methods.source.msg_iter_seek_ns_from_origin, - cc_full_descr->methods.source.msg_iter_can_seek_ns_from_origin); - if (ret) { - BT_LIB_LOGE_APPEND_CAUSE( - "Cannot set source component class's message iterator \"seek nanoseconds from origin\" methods."); - status = BT_FUNC_STATUS_MEMORY_ERROR; - BT_OBJECT_PUT_REF_AND_RESET(src_comp_class); - goto end; - } - } - - if (cc_full_descr->methods.source.msg_iter_seek_beginning) { - ret = bt_component_class_source_set_message_iterator_seek_beginning_methods( - src_comp_class, - cc_full_descr->methods.source.msg_iter_seek_beginning, - cc_full_descr->methods.source.msg_iter_can_seek_beginning); - if (ret) { - BT_LIB_LOGE_APPEND_CAUSE( - "Cannot set source component class's message iterator \"seek beginning\" methods."); - status = BT_FUNC_STATUS_MEMORY_ERROR; - BT_OBJECT_PUT_REF_AND_RESET(src_comp_class); - goto end; - } - } - break; case BT_COMPONENT_CLASS_TYPE_FILTER: if (cc_full_descr->methods.filter.get_supported_mip_versions) { @@ -1067,60 +1112,6 @@ int bt_plugin_so_init(struct bt_plugin *plugin, } } - if (cc_full_descr->methods.filter.msg_iter_initialize) { - ret = bt_component_class_filter_set_message_iterator_initialize_method( - flt_comp_class, - cc_full_descr->methods.filter.msg_iter_initialize); - if (ret) { - BT_LIB_LOGE_APPEND_CAUSE( - "Cannot set filter component class's message iterator initialization method."); - status = BT_FUNC_STATUS_MEMORY_ERROR; - BT_OBJECT_PUT_REF_AND_RESET(flt_comp_class); - goto end; - } - } - - if (cc_full_descr->methods.filter.msg_iter_finalize) { - ret = bt_component_class_filter_set_message_iterator_finalize_method( - flt_comp_class, - cc_full_descr->methods.filter.msg_iter_finalize); - if (ret) { - BT_LIB_LOGE_APPEND_CAUSE( - "Cannot set filter component class's message iterator finalization method."); - status = BT_FUNC_STATUS_MEMORY_ERROR; - BT_OBJECT_PUT_REF_AND_RESET(flt_comp_class); - goto end; - } - } - - if (cc_full_descr->methods.filter.msg_iter_seek_ns_from_origin) { - ret = bt_component_class_filter_set_message_iterator_seek_ns_from_origin_methods( - flt_comp_class, - cc_full_descr->methods.filter.msg_iter_seek_ns_from_origin, - cc_full_descr->methods.filter.msg_iter_can_seek_ns_from_origin); - if (ret) { - BT_LIB_LOGE_APPEND_CAUSE( - "Cannot set filter component class's message iterator \"seek nanoseconds from origin\" methods."); - status = BT_FUNC_STATUS_MEMORY_ERROR; - BT_OBJECT_PUT_REF_AND_RESET(flt_comp_class); - goto end; - } - } - - if (cc_full_descr->methods.filter.msg_iter_seek_beginning) { - ret = bt_component_class_filter_set_message_iterator_seek_beginning_methods( - flt_comp_class, - cc_full_descr->methods.filter.msg_iter_seek_beginning, - cc_full_descr->methods.filter.msg_iter_can_seek_beginning); - if (ret) { - BT_LIB_LOGE_APPEND_CAUSE( - "Cannot set filter component class's message iterator \"seek beginning\" methods."); - status = BT_FUNC_STATUS_MEMORY_ERROR; - BT_OBJECT_PUT_REF_AND_RESET(flt_comp_class); - goto end; - } - } - break; case BT_COMPONENT_CLASS_TYPE_SINK: if (cc_full_descr->methods.sink.get_supported_mip_versions) { @@ -1225,6 +1216,7 @@ int bt_plugin_so_init(struct bt_plugin *plugin, } end: + bt_message_iterator_class_put_ref(msg_iter_class); g_array_free(comp_class_full_descriptors, TRUE); return status; } diff --git a/src/plugins/ctf/fs-src/fs.c b/src/plugins/ctf/fs-src/fs.c index e8121140..a6712cb7 100644 --- a/src/plugins/ctf/fs-src/fs.c +++ b/src/plugins/ctf/fs-src/fs.c @@ -75,11 +75,11 @@ void ctf_fs_msg_iter_data_destroy( } static -bt_component_class_message_iterator_next_method_status ctf_fs_iterator_next_one( +bt_message_iterator_class_next_method_status ctf_fs_iterator_next_one( struct ctf_fs_msg_iter_data *msg_iter_data, const bt_message **out_msg) { - bt_component_class_message_iterator_next_method_status status; + bt_message_iterator_class_next_method_status status; enum ctf_msg_iter_status msg_iter_status; bt_logging_level log_level = msg_iter_data->log_level; @@ -89,11 +89,11 @@ bt_component_class_message_iterator_next_method_status ctf_fs_iterator_next_one( switch (msg_iter_status) { case CTF_MSG_ITER_STATUS_OK: /* Cool, message has been written to *out_msg. */ - status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK; + status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK; break; case CTF_MSG_ITER_STATUS_EOF: - status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_END; + status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_END; break; case CTF_MSG_ITER_STATUS_AGAIN: @@ -107,13 +107,13 @@ bt_component_class_message_iterator_next_method_status ctf_fs_iterator_next_one( case CTF_MSG_ITER_MEDIUM_STATUS_ERROR: BT_MSG_ITER_LOGE_APPEND_CAUSE(msg_iter_data->self_msg_iter, "Failed to get next message from CTF message iterator."); - status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_ERROR; + status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_ERROR; break; case CTF_MSG_ITER_MEDIUM_STATUS_MEMORY_ERROR: BT_MSG_ITER_LOGE_APPEND_CAUSE(msg_iter_data->self_msg_iter, "Failed to get next message from CTF message iterator."); - status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_MEMORY_ERROR; + status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_MEMORY_ERROR; break; default: @@ -124,12 +124,12 @@ bt_component_class_message_iterator_next_method_status ctf_fs_iterator_next_one( } BT_HIDDEN -bt_component_class_message_iterator_next_method_status ctf_fs_iterator_next( +bt_message_iterator_class_next_method_status ctf_fs_iterator_next( bt_self_message_iterator *iterator, bt_message_array_const msgs, uint64_t capacity, uint64_t *count) { - bt_component_class_message_iterator_next_method_status status; + bt_message_iterator_class_next_method_status status; struct ctf_fs_msg_iter_data *msg_iter_data = bt_self_message_iterator_get_data(iterator); uint64_t i = 0; @@ -147,19 +147,19 @@ bt_component_class_message_iterator_next_method_status ctf_fs_iterator_next( do { status = ctf_fs_iterator_next_one(msg_iter_data, &msgs[i]); - if (status == BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK) { + if (status == BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK) { i++; } } while (i < capacity && - status == BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK); + status == BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK); if (i > 0) { /* * Even if ctf_fs_iterator_next_one() returned something - * else than BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK, we + * else than BT_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK, we * accumulated message objects in the output * message array, so we need to return - * BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK so that they are + * BT_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK so that they are * transfered to downstream. This other status occurs * again the next time muxer_msg_iter_do_next() is * called, possibly without any accumulated @@ -178,7 +178,7 @@ bt_component_class_message_iterator_next_method_status ctf_fs_iterator_next( } *count = i; - status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK; + status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK; } end: @@ -186,7 +186,7 @@ end: } BT_HIDDEN -bt_component_class_message_iterator_seek_beginning_method_status +bt_message_iterator_class_seek_beginning_method_status ctf_fs_iterator_seek_beginning(bt_self_message_iterator *it) { struct ctf_fs_msg_iter_data *msg_iter_data = @@ -197,7 +197,7 @@ ctf_fs_iterator_seek_beginning(bt_self_message_iterator *it) ctf_msg_iter_reset(msg_iter_data->msg_iter); ctf_fs_ds_group_medops_data_reset(msg_iter_data->msg_iter_medops_data); - return BT_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_BEGINNING_METHOD_STATUS_OK; + return BT_MESSAGE_ITERATOR_CLASS_SEEK_BEGINNING_METHOD_STATUS_OK; } BT_HIDDEN @@ -208,18 +208,16 @@ void ctf_fs_iterator_finalize(bt_self_message_iterator *it) } BT_HIDDEN -bt_component_class_message_iterator_initialize_method_status ctf_fs_iterator_init( +bt_message_iterator_class_initialize_method_status ctf_fs_iterator_init( bt_self_message_iterator *self_msg_iter, bt_self_message_iterator_configuration *config, - bt_self_component_source *self_comp_src, + bt_self_component *self_comp, bt_self_component_port_output *self_port) { struct ctf_fs_port_data *port_data; struct ctf_fs_msg_iter_data *msg_iter_data = NULL; - bt_component_class_message_iterator_initialize_method_status status; + bt_message_iterator_class_initialize_method_status status; bt_logging_level log_level; - bt_self_component *self_comp = - bt_self_component_source_as_self_component(self_comp_src); enum ctf_msg_iter_medium_status medium_status; port_data = bt_self_component_port_get_data( @@ -229,7 +227,7 @@ bt_component_class_message_iterator_initialize_method_status ctf_fs_iterator_ini log_level = port_data->ctf_fs->log_level; msg_iter_data = g_new0(struct ctf_fs_msg_iter_data, 1); if (!msg_iter_data) { - status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INITIALIZE_METHOD_STATUS_MEMORY_ERROR; + status = BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_MEMORY_ERROR; goto error; } @@ -261,7 +259,7 @@ bt_component_class_message_iterator_initialize_method_status ctf_fs_iterator_ini self_comp, self_msg_iter); if (!msg_iter_data->msg_iter) { BT_COMP_LOGE_APPEND_CAUSE(self_comp, "Cannot create a CTF message iterator."); - status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INITIALIZE_METHOD_STATUS_MEMORY_ERROR; + status = BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_MEMORY_ERROR; goto error; } @@ -278,7 +276,7 @@ bt_component_class_message_iterator_initialize_method_status ctf_fs_iterator_ini msg_iter_data); msg_iter_data = NULL; - status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INITIALIZE_METHOD_STATUS_OK; + status = BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_OK; goto end; error: diff --git a/src/plugins/ctf/fs-src/fs.h b/src/plugins/ctf/fs-src/fs.h index 446e84e5..763136af 100644 --- a/src/plugins/ctf/fs-src/fs.h +++ b/src/plugins/ctf/fs-src/fs.h @@ -199,7 +199,7 @@ struct ctf_fs_msg_iter_data { * messages ready to return, we save the error here and return it on * the next _next call. */ - bt_component_class_message_iterator_next_method_status next_saved_status; + bt_message_iterator_class_next_method_status next_saved_status; const struct bt_error *next_saved_error; struct ctf_fs_ds_group_medops_data *msg_iter_medops_data; @@ -222,23 +222,23 @@ bt_component_class_query_method_status ctf_fs_query( void *method_data, const bt_value **result); BT_HIDDEN -bt_component_class_message_iterator_initialize_method_status ctf_fs_iterator_init( +bt_message_iterator_class_initialize_method_status ctf_fs_iterator_init( bt_self_message_iterator *self_msg_iter, bt_self_message_iterator_configuration *config, - bt_self_component_source *self_comp, + bt_self_component *self_comp, bt_self_component_port_output *self_port); BT_HIDDEN void ctf_fs_iterator_finalize(bt_self_message_iterator *it); BT_HIDDEN -bt_component_class_message_iterator_next_method_status ctf_fs_iterator_next( +bt_message_iterator_class_next_method_status ctf_fs_iterator_next( bt_self_message_iterator *iterator, bt_message_array_const msgs, uint64_t capacity, uint64_t *count); BT_HIDDEN -bt_component_class_message_iterator_seek_beginning_method_status ctf_fs_iterator_seek_beginning( +bt_message_iterator_class_seek_beginning_method_status ctf_fs_iterator_seek_beginning( bt_self_message_iterator *message_iterator); /* Create and initialize a new, empty ctf_fs_component. */ diff --git a/src/plugins/ctf/lttng-live/lttng-live.c b/src/plugins/ctf/lttng-live/lttng-live.c index 2376d440..6d77035b 100644 --- a/src/plugins/ctf/lttng-live/lttng-live.c +++ b/src/plugins/ctf/lttng-live/lttng-live.c @@ -1279,12 +1279,12 @@ void put_messages(bt_message_array_const msgs, uint64_t count) } BT_HIDDEN -bt_component_class_message_iterator_next_method_status lttng_live_msg_iter_next( +bt_message_iterator_class_next_method_status lttng_live_msg_iter_next( bt_self_message_iterator *self_msg_it, bt_message_array_const msgs, uint64_t capacity, uint64_t *count) { - bt_component_class_message_iterator_next_method_status status; + bt_message_iterator_class_next_method_status status; enum lttng_live_viewer_status viewer_status; struct lttng_live_msg_iter *lttng_live_msg_iter = bt_self_message_iterator_get_data(self_msg_it); @@ -1308,7 +1308,7 @@ bt_component_class_message_iterator_next_method_status lttng_live_msg_iter_next( * is to prevent other graph users from using this live * iterator in an messed up internal state. */ - status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_ERROR; + status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_ERROR; BT_COMP_LOGE_APPEND_CAUSE(self_comp, "Message iterator was interrupted during a previous call to the `next()` and currently does not support continuing after such event."); goto end; @@ -1328,7 +1328,7 @@ bt_component_class_message_iterator_next_method_status lttng_live_msg_iter_next( if (lttng_live_msg_iter->sessions->len == 0) { if (lttng_live->params.sess_not_found_act != SESSION_NOT_FOUND_ACTION_CONTINUE) { - status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_END; + status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_END; goto end; } else { /* @@ -1339,11 +1339,11 @@ bt_component_class_message_iterator_next_method_status lttng_live_msg_iter_next( viewer_status = lttng_live_create_viewer_session(lttng_live_msg_iter); if (viewer_status != LTTNG_LIVE_VIEWER_STATUS_OK) { if (viewer_status == LTTNG_LIVE_VIEWER_STATUS_ERROR) { - status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_ERROR; + status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_ERROR; BT_COMP_LOGE_APPEND_CAUSE(self_comp, "Error creating LTTng live viewer session"); } else if (viewer_status == LTTNG_LIVE_VIEWER_STATUS_INTERRUPTED) { - status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_AGAIN; + status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_AGAIN; } else { bt_common_abort(); } @@ -1494,20 +1494,20 @@ return_status: * doesn't support restarting after an interruption. */ if (*count > 0) { - status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK; + status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK; } else { - status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_AGAIN; + status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_AGAIN; } break; case LTTNG_LIVE_ITERATOR_STATUS_END: - status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_END; + status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_END; break; case LTTNG_LIVE_ITERATOR_STATUS_NOMEM: BT_COMP_LOGE_APPEND_CAUSE(self_comp, "Memory error preparing the next batch of messages: " "live-iter-status=%s", lttng_live_iterator_status_string(stream_iter_status)); - status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_MEMORY_ERROR; + status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_MEMORY_ERROR; break; case LTTNG_LIVE_ITERATOR_STATUS_ERROR: case LTTNG_LIVE_ITERATOR_STATUS_INVAL: @@ -1517,7 +1517,7 @@ return_status: "live-iter-status=%s", lttng_live_iterator_status_string(stream_iter_status)); - status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_ERROR; + status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_ERROR; /* Put all existing messages on error. */ put_messages(msgs, *count); break; @@ -1564,15 +1564,13 @@ end: } BT_HIDDEN -bt_component_class_message_iterator_initialize_method_status lttng_live_msg_iter_init( +bt_message_iterator_class_initialize_method_status lttng_live_msg_iter_init( bt_self_message_iterator *self_msg_it, bt_self_message_iterator_configuration *config, - bt_self_component_source *self_comp_src, + bt_self_component *self_comp, bt_self_component_port_output *self_port) { - bt_component_class_message_iterator_initialize_method_status status; - bt_self_component *self_comp = - bt_self_component_source_as_self_component(self_comp_src); + bt_message_iterator_class_initialize_method_status status; struct lttng_live_component *lttng_live; struct lttng_live_msg_iter *lttng_live_msg_iter; enum lttng_live_viewer_status viewer_status; @@ -1592,7 +1590,7 @@ bt_component_class_message_iterator_initialize_method_status lttng_live_msg_iter lttng_live_msg_iter = lttng_live_msg_iter_create(lttng_live, self_msg_it); if (!lttng_live_msg_iter) { - status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INITIALIZE_METHOD_STATUS_MEMORY_ERROR; + status = BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_MEMORY_ERROR; BT_COMP_LOGE_APPEND_CAUSE(self_comp, "Failed to create lttng_live_msg_iter"); goto error; @@ -1662,11 +1660,11 @@ bt_component_class_message_iterator_initialize_method_status lttng_live_msg_iter } bt_self_message_iterator_set_data(self_msg_it, lttng_live_msg_iter); - status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INITIALIZE_METHOD_STATUS_OK; + status = BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_OK; goto end; error: - status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INITIALIZE_METHOD_STATUS_ERROR; + status = BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_ERROR; lttng_live_msg_iter_destroy(lttng_live_msg_iter); end: return status; diff --git a/src/plugins/ctf/lttng-live/lttng-live.h b/src/plugins/ctf/lttng-live/lttng-live.h index a6e1590d..39bc5abc 100644 --- a/src/plugins/ctf/lttng-live/lttng-live.h +++ b/src/plugins/ctf/lttng-live/lttng-live.h @@ -293,15 +293,15 @@ bt_component_class_query_method_status lttng_live_query( void lttng_live_component_finalize(bt_self_component_source *component); -bt_component_class_message_iterator_next_method_status lttng_live_msg_iter_next( +bt_message_iterator_class_next_method_status lttng_live_msg_iter_next( bt_self_message_iterator *iterator, bt_message_array_const msgs, uint64_t capacity, uint64_t *count); -bt_component_class_message_iterator_initialize_method_status lttng_live_msg_iter_init( +bt_message_iterator_class_initialize_method_status lttng_live_msg_iter_init( bt_self_message_iterator *self_msg_it, bt_self_message_iterator_configuration *config, - bt_self_component_source *self_comp, + bt_self_component *self_comp, bt_self_component_port_output *self_port); void lttng_live_msg_iter_finalize(bt_self_message_iterator *it); diff --git a/src/plugins/lttng-utils/debug-info/debug-info.c b/src/plugins/lttng-utils/debug-info/debug-info.c index c98cf604..fe342414 100644 --- a/src/plugins/lttng-utils/debug-info/debug-info.c +++ b/src/plugins/lttng-utils/debug-info/debug-info.c @@ -62,6 +62,7 @@ struct debug_info_component { bt_logging_level log_level; bt_self_component *self_comp; + bt_self_component_filter *self_comp_filter; gchar *arg_debug_dir; gchar *arg_debug_info_field_name; gchar *arg_target_prefix; @@ -1807,6 +1808,7 @@ bt_component_class_initialize_method_status debug_info_comp_init( debug_info_comp->log_level = log_level; debug_info_comp->self_comp = self_comp; + debug_info_comp->self_comp_filter = self_comp_flt; bt_self_component_set_data(self_comp, debug_info_comp); add_port_status = bt_self_component_filter_add_input_port( @@ -1862,7 +1864,7 @@ void debug_info_comp_finalize(bt_self_component_filter *self_comp_flt) } BT_HIDDEN -bt_component_class_message_iterator_next_method_status debug_info_msg_iter_next( +bt_message_iterator_class_next_method_status debug_info_msg_iter_next( bt_self_message_iterator *self_msg_iter, const bt_message_array_const msgs, uint64_t capacity, uint64_t *count) @@ -1871,13 +1873,13 @@ bt_component_class_message_iterator_next_method_status debug_info_msg_iter_next( bt_message_iterator_next_status upstream_iterator_ret_status; struct debug_info_msg_iter *debug_info_msg_iter; struct debug_info_component *debug_info = NULL; - bt_component_class_message_iterator_next_method_status status; + bt_message_iterator_class_next_method_status status; bt_self_component *self_comp = NULL; bt_message_array_const input_msgs; const bt_message *out_message; uint64_t curr_msg_idx, i; - status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK; + status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK; self_comp = bt_self_message_iterator_borrow_component(self_msg_iter); BT_ASSERT_DBG(self_comp); @@ -1945,7 +1947,7 @@ handle_msg_error: bt_message_put_ref(input_msgs[i]); } - status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_MEMORY_ERROR; + status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_MEMORY_ERROR; end: return status; @@ -1979,13 +1981,13 @@ end: } BT_HIDDEN -bt_component_class_message_iterator_initialize_method_status debug_info_msg_iter_init( +bt_message_iterator_class_initialize_method_status debug_info_msg_iter_init( bt_self_message_iterator *self_msg_iter, bt_self_message_iterator_configuration *config, - bt_self_component_filter *self_comp_flt, + bt_self_component *self_comp, bt_self_component_port_output *self_port) { - bt_component_class_message_iterator_initialize_method_status status; + bt_message_iterator_class_initialize_method_status status; bt_self_component_port_input_message_iterator_create_from_message_iterator_status msg_iter_status; struct bt_self_component_port_input *input_port = NULL; @@ -1993,28 +1995,30 @@ bt_component_class_message_iterator_initialize_method_status debug_info_msg_iter struct debug_info_msg_iter *debug_info_msg_iter = NULL; gchar *debug_info_field_name; int ret; - bt_self_component *self_comp = - bt_self_component_filter_as_self_component(self_comp_flt); bt_logging_level log_level = bt_component_get_logging_level( bt_self_component_as_component(self_comp)); - /* Borrow the upstream input port. */ - input_port = bt_self_component_filter_borrow_input_port_by_name( - self_comp_flt, "in"); - if (!input_port) { - status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INITIALIZE_METHOD_STATUS_ERROR; - goto error; - } - debug_info_msg_iter = g_new0(struct debug_info_msg_iter, 1); if (!debug_info_msg_iter) { - status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INITIALIZE_METHOD_STATUS_MEMORY_ERROR; + status = BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_MEMORY_ERROR; goto error; } debug_info_msg_iter->log_level = log_level; debug_info_msg_iter->self_comp = self_comp; + debug_info_msg_iter->debug_info_component = + bt_self_component_get_data(self_comp); + + /* Borrow the upstream input port. */ + input_port = bt_self_component_filter_borrow_input_port_by_name( + debug_info_msg_iter->debug_info_component->self_comp_filter, + "in"); + if (!input_port) { + status = BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_ERROR; + goto error; + } + /* Create an iterator on the upstream component. */ msg_iter_status = bt_self_component_port_input_message_iterator_create_from_message_iterator( self_msg_iter, input_port, &upstream_iterator); @@ -2031,26 +2035,23 @@ bt_component_class_message_iterator_initialize_method_status debug_info_msg_iter g_direct_hash, g_direct_equal, (GDestroyNotify) NULL, (GDestroyNotify) debug_info_destroy); if (!debug_info_msg_iter->debug_info_map) { - status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INITIALIZE_METHOD_STATUS_MEMORY_ERROR; + status = BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_MEMORY_ERROR; goto error; } - debug_info_msg_iter->debug_info_component = - bt_self_component_get_data(self_comp); - debug_info_field_name = debug_info_msg_iter->debug_info_component->arg_debug_info_field_name; debug_info_msg_iter->ir_maps = trace_ir_maps_create(self_comp, debug_info_field_name, log_level); if (!debug_info_msg_iter->ir_maps) { - status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INITIALIZE_METHOD_STATUS_MEMORY_ERROR; + status = BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_MEMORY_ERROR; goto error; } ret = bt_fd_cache_init(&debug_info_msg_iter->fd_cache, log_level); if (ret) { - status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INITIALIZE_METHOD_STATUS_MEMORY_ERROR; + status = BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_MEMORY_ERROR; goto error; } @@ -2061,7 +2062,7 @@ bt_component_class_message_iterator_initialize_method_status debug_info_msg_iter bt_self_message_iterator_set_data(self_msg_iter, debug_info_msg_iter); debug_info_msg_iter->input_iterator = self_msg_iter; - status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INITIALIZE_METHOD_STATUS_OK; + status = BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_OK; goto end; error: @@ -2072,7 +2073,7 @@ end: } BT_HIDDEN -bt_component_class_message_iterator_can_seek_beginning_method_status +bt_message_iterator_class_can_seek_beginning_method_status debug_info_msg_iter_can_seek_beginning(bt_self_message_iterator *self_msg_iter, bt_bool *can_seek) { @@ -2085,13 +2086,13 @@ debug_info_msg_iter_can_seek_beginning(bt_self_message_iterator *self_msg_iter, } BT_HIDDEN -bt_component_class_message_iterator_seek_beginning_method_status +bt_message_iterator_class_seek_beginning_method_status debug_info_msg_iter_seek_beginning(bt_self_message_iterator *self_msg_iter) { struct debug_info_msg_iter *debug_info_msg_iter = bt_self_message_iterator_get_data(self_msg_iter); - bt_component_class_message_iterator_seek_beginning_method_status status = - BT_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_BEGINNING_METHOD_STATUS_OK; + bt_message_iterator_class_seek_beginning_method_status status = + BT_MESSAGE_ITERATOR_CLASS_SEEK_BEGINNING_METHOD_STATUS_OK; bt_message_iterator_seek_beginning_status seek_beg_status; BT_ASSERT(debug_info_msg_iter); diff --git a/src/plugins/lttng-utils/debug-info/debug-info.h b/src/plugins/lttng-utils/debug-info/debug-info.h index 6be8bd0e..13fc0ff8 100644 --- a/src/plugins/lttng-utils/debug-info/debug-info.h +++ b/src/plugins/lttng-utils/debug-info/debug-info.h @@ -47,26 +47,26 @@ BT_HIDDEN void debug_info_comp_finalize(bt_self_component_filter *self_comp); BT_HIDDEN -bt_component_class_message_iterator_initialize_method_status debug_info_msg_iter_init( +bt_message_iterator_class_initialize_method_status debug_info_msg_iter_init( bt_self_message_iterator *self_msg_iter, bt_self_message_iterator_configuration *config, - bt_self_component_filter *self_comp, + bt_self_component *self_comp, bt_self_component_port_output *self_port); BT_HIDDEN -bt_component_class_message_iterator_next_method_status debug_info_msg_iter_next( +bt_message_iterator_class_next_method_status debug_info_msg_iter_next( bt_self_message_iterator *self_msg_iter, const bt_message_array_const msgs, uint64_t capacity, uint64_t *count); BT_HIDDEN -bt_component_class_message_iterator_can_seek_beginning_method_status +bt_message_iterator_class_can_seek_beginning_method_status debug_info_msg_iter_can_seek_beginning( bt_self_message_iterator *message_iterator, bt_bool *can_seek); BT_HIDDEN -bt_component_class_message_iterator_seek_beginning_method_status debug_info_msg_iter_seek_beginning( +bt_message_iterator_class_seek_beginning_method_status debug_info_msg_iter_seek_beginning( bt_self_message_iterator *message_iterator); BT_HIDDEN diff --git a/src/plugins/text/dmesg/dmesg.c b/src/plugins/text/dmesg/dmesg.c index da21f69e..65718d32 100644 --- a/src/plugins/text/dmesg/dmesg.c +++ b/src/plugins/text/dmesg/dmesg.c @@ -662,18 +662,17 @@ void destroy_dmesg_msg_iter(struct dmesg_msg_iter *dmesg_msg_iter) BT_HIDDEN -bt_component_class_message_iterator_initialize_method_status dmesg_msg_iter_init( +bt_message_iterator_class_initialize_method_status dmesg_msg_iter_init( bt_self_message_iterator *self_msg_iter, bt_self_message_iterator_configuration *config, - bt_self_component_source *self_comp, + bt_self_component *self_comp, bt_self_component_port_output *self_port) { - struct dmesg_component *dmesg_comp = bt_self_component_get_data( - bt_self_component_source_as_self_component(self_comp)); + struct dmesg_component *dmesg_comp = bt_self_component_get_data(self_comp); struct dmesg_msg_iter *dmesg_msg_iter = g_new0(struct dmesg_msg_iter, 1); - bt_component_class_message_iterator_initialize_method_status status = - BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INITIALIZE_METHOD_STATUS_OK; + bt_message_iterator_class_initialize_method_status status = + BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_OK; if (!dmesg_msg_iter) { BT_COMP_LOGE_STR("Failed to allocate on dmesg message iterator structure."); @@ -703,7 +702,7 @@ error: destroy_dmesg_msg_iter(dmesg_msg_iter); bt_self_message_iterator_set_data(self_msg_iter, NULL); if (status >= 0) { - status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INITIALIZE_METHOD_STATUS_ERROR; + status = BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_ERROR; } end: @@ -719,21 +718,21 @@ void dmesg_msg_iter_finalize( } static -bt_component_class_message_iterator_next_method_status dmesg_msg_iter_next_one( +bt_message_iterator_class_next_method_status dmesg_msg_iter_next_one( struct dmesg_msg_iter *dmesg_msg_iter, bt_message **msg) { ssize_t len; struct dmesg_component *dmesg_comp; - bt_component_class_message_iterator_next_method_status status = - BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK; + bt_message_iterator_class_next_method_status status = + BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK; BT_ASSERT_DBG(dmesg_msg_iter); dmesg_comp = dmesg_msg_iter->dmesg_comp; BT_ASSERT_DBG(dmesg_comp); if (dmesg_msg_iter->state == STATE_DONE) { - status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_END; + status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_END; goto end; } @@ -750,13 +749,13 @@ bt_component_class_message_iterator_next_method_status dmesg_msg_iter_next_one( &dmesg_msg_iter->linebuf_len, dmesg_msg_iter->fp); if (len < 0) { if (errno == EINVAL) { - status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_ERROR; + status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_ERROR; } else if (errno == ENOMEM) { - status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_MEMORY_ERROR; + status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_MEMORY_ERROR; } else { if (dmesg_msg_iter->state == STATE_EMIT_STREAM_BEGINNING) { /* Stream did not even begin */ - status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_END; + status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_END; goto end; } else { /* End stream now */ @@ -820,7 +819,7 @@ handle_state: if (!*msg) { BT_COMP_LOGE("Cannot create message: dmesg-comp-addr=%p", dmesg_comp); - status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_ERROR; + status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_ERROR; } end: @@ -828,7 +827,7 @@ end: } BT_HIDDEN -bt_component_class_message_iterator_next_method_status dmesg_msg_iter_next( +bt_message_iterator_class_next_method_status dmesg_msg_iter_next( bt_self_message_iterator *self_msg_iter, bt_message_array_const msgs, uint64_t capacity, uint64_t *count) @@ -836,18 +835,18 @@ bt_component_class_message_iterator_next_method_status dmesg_msg_iter_next( struct dmesg_msg_iter *dmesg_msg_iter = bt_self_message_iterator_get_data( self_msg_iter); - bt_component_class_message_iterator_next_method_status status = - BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK; + bt_message_iterator_class_next_method_status status = + BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK; uint64_t i = 0; while (i < capacity && - status == BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK) { + status == BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK) { bt_message *priv_msg = NULL; status = dmesg_msg_iter_next_one(dmesg_msg_iter, &priv_msg); msgs[i] = priv_msg; - if (status == BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK) { + if (status == BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK) { i++; } } @@ -866,14 +865,14 @@ bt_component_class_message_iterator_next_method_status dmesg_msg_iter_next( * message, in which case we'll return it. */ *count = i; - status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK; + status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK; } return status; } BT_HIDDEN -bt_component_class_message_iterator_can_seek_beginning_method_status +bt_message_iterator_class_can_seek_beginning_method_status dmesg_msg_iter_can_seek_beginning( bt_self_message_iterator *self_msg_iter, bt_bool *can_seek) { @@ -883,11 +882,11 @@ dmesg_msg_iter_can_seek_beginning( /* Can't seek the beginning of the standard input stream */ *can_seek = !dmesg_msg_iter->dmesg_comp->params.read_from_stdin; - return BT_COMPONENT_CLASS_MESSAGE_ITERATOR_CAN_SEEK_BEGINNING_METHOD_STATUS_OK; + return BT_MESSAGE_ITERATOR_CLASS_CAN_SEEK_BEGINNING_METHOD_STATUS_OK; } BT_HIDDEN -bt_component_class_message_iterator_seek_beginning_method_status +bt_message_iterator_class_seek_beginning_method_status dmesg_msg_iter_seek_beginning( bt_self_message_iterator *self_msg_iter) { @@ -899,5 +898,5 @@ dmesg_msg_iter_seek_beginning( BT_MESSAGE_PUT_REF_AND_RESET(dmesg_msg_iter->tmp_event_msg); dmesg_msg_iter->last_clock_value = 0; dmesg_msg_iter->state = STATE_EMIT_STREAM_BEGINNING; - return BT_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_BEGINNING_METHOD_STATUS_OK; + return BT_MESSAGE_ITERATOR_CLASS_SEEK_BEGINNING_METHOD_STATUS_OK; } diff --git a/src/plugins/text/dmesg/dmesg.h b/src/plugins/text/dmesg/dmesg.h index 178460a0..c73999ed 100644 --- a/src/plugins/text/dmesg/dmesg.h +++ b/src/plugins/text/dmesg/dmesg.h @@ -37,10 +37,10 @@ BT_HIDDEN void dmesg_finalize(bt_self_component_source *self_comp); BT_HIDDEN -bt_component_class_message_iterator_initialize_method_status dmesg_msg_iter_init( +bt_message_iterator_class_initialize_method_status dmesg_msg_iter_init( bt_self_message_iterator *self_msg_iter, bt_self_message_iterator_configuration *config, - bt_self_component_source *self_comp, + bt_self_component *self_comp, bt_self_component_port_output *self_port); BT_HIDDEN @@ -48,18 +48,18 @@ void dmesg_msg_iter_finalize( bt_self_message_iterator *self_msg_iter); BT_HIDDEN -bt_component_class_message_iterator_next_method_status dmesg_msg_iter_next( +bt_message_iterator_class_next_method_status dmesg_msg_iter_next( bt_self_message_iterator *self_msg_iter, bt_message_array_const msgs, uint64_t capacity, uint64_t *count); BT_HIDDEN -bt_component_class_message_iterator_can_seek_beginning_method_status +bt_message_iterator_class_can_seek_beginning_method_status dmesg_msg_iter_can_seek_beginning( bt_self_message_iterator *message_iterator, bt_bool *can_seek); BT_HIDDEN -bt_component_class_message_iterator_seek_beginning_method_status dmesg_msg_iter_seek_beginning( +bt_message_iterator_class_seek_beginning_method_status dmesg_msg_iter_seek_beginning( bt_self_message_iterator *message_iterator); #endif /* BABELTRACE_PLUGIN_TEXT_DMESG_DMESG_H */ diff --git a/src/plugins/text/pretty/pretty.c b/src/plugins/text/pretty/pretty.c index b05622bd..1e248644 100644 --- a/src/plugins/text/pretty/pretty.c +++ b/src/plugins/text/pretty/pretty.c @@ -109,25 +109,25 @@ void pretty_finalize(bt_self_component_sink *comp) } static -bt_component_class_message_iterator_next_method_status handle_message( +bt_message_iterator_class_next_method_status handle_message( struct pretty_component *pretty, const bt_message *message) { - bt_component_class_message_iterator_next_method_status ret = - BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK; + bt_message_iterator_class_next_method_status ret = + BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK; BT_ASSERT_DBG(pretty); switch (bt_message_get_type(message)) { case BT_MESSAGE_TYPE_EVENT: if (pretty_print_event(pretty, message)) { - ret = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_ERROR; + ret = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_ERROR; } break; case BT_MESSAGE_TYPE_DISCARDED_EVENTS: case BT_MESSAGE_TYPE_DISCARDED_PACKETS: if (pretty_print_discarded_items(pretty, message)) { - ret = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_ERROR; + ret = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_ERROR; } break; default: diff --git a/src/plugins/utils/muxer/muxer.c b/src/plugins/utils/muxer/muxer.c index f4af51c8..0c08f828 100644 --- a/src/plugins/utils/muxer/muxer.c +++ b/src/plugins/utils/muxer/muxer.c @@ -113,7 +113,7 @@ struct muxer_msg_iter { * messages ready to return, we save the error here and return it on * the next _next call. */ - bt_component_class_message_iterator_next_method_status next_saved_status; + bt_message_iterator_class_next_method_status next_saved_status; const struct bt_error *next_saved_error; }; @@ -387,12 +387,12 @@ end: } static -bt_component_class_message_iterator_next_method_status muxer_upstream_msg_iter_next( +bt_message_iterator_class_next_method_status muxer_upstream_msg_iter_next( struct muxer_upstream_msg_iter *muxer_upstream_msg_iter, bool *is_ended) { struct muxer_comp *muxer_comp = muxer_upstream_msg_iter->muxer_comp; - bt_component_class_message_iterator_next_method_status status; + bt_message_iterator_class_next_method_status status; bt_message_iterator_next_status input_port_iter_status; bt_message_array_const msgs; uint64_t i; @@ -427,7 +427,7 @@ bt_component_class_message_iterator_next_method_status muxer_upstream_msg_iter_n g_queue_push_tail(muxer_upstream_msg_iter->msgs, (void *) msgs[i]); } - status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK; + status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK; break; case BT_MESSAGE_ITERATOR_NEXT_STATUS_AGAIN: /* @@ -435,7 +435,7 @@ bt_component_class_message_iterator_next_method_status muxer_upstream_msg_iter_n * valid anymore. Return * BT_MESSAGE_ITERATOR_NEXT_STATUS_AGAIN immediately. */ - status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_AGAIN; + status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_AGAIN; break; case BT_MESSAGE_ITERATOR_NEXT_STATUS_END: /* Fall-through. */ /* @@ -444,7 +444,7 @@ bt_component_class_message_iterator_next_method_status muxer_upstream_msg_iter_n * message. */ *is_ended = true; - status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK; + status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK; break; case BT_MESSAGE_ITERATOR_NEXT_STATUS_ERROR: case BT_MESSAGE_ITERATOR_NEXT_STATUS_MEMORY_ERROR: @@ -459,7 +459,7 @@ bt_component_class_message_iterator_next_method_status muxer_upstream_msg_iter_n BT_COMP_LOGE_APPEND_CAUSE(muxer_comp->self_comp, "Unsupported status code: status=%s", bt_common_func_status_string(input_port_iter_status)); - status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_ERROR; + status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_ERROR; break; } @@ -795,7 +795,7 @@ end: * the youngest, and sets *ts_ns to its time. */ static -bt_component_class_message_iterator_next_method_status +bt_message_iterator_class_next_method_status muxer_msg_iter_youngest_upstream_msg_iter( struct muxer_comp *muxer_comp, struct muxer_msg_iter *muxer_msg_iter, @@ -805,8 +805,8 @@ muxer_msg_iter_youngest_upstream_msg_iter( size_t i; int ret; int64_t youngest_ts_ns = INT64_MAX; - bt_component_class_message_iterator_next_method_status status = - BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK; + bt_message_iterator_class_next_method_status status = + BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK; BT_ASSERT_DBG(muxer_comp); BT_ASSERT_DBG(muxer_msg_iter); @@ -845,7 +845,7 @@ muxer_msg_iter_youngest_upstream_msg_iter( * validate_new_stream_clock_class() logs * errors. */ - status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_ERROR; + status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_ERROR; goto end; } } else if (G_UNLIKELY(bt_message_get_type(msg) == @@ -858,7 +858,7 @@ muxer_msg_iter_youngest_upstream_msg_iter( bt_clock_snapshot_borrow_clock_class_const(cs)); if (ret) { /* validate_clock_class() logs errors */ - status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_ERROR; + status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_ERROR; goto end; } } @@ -868,7 +868,7 @@ muxer_msg_iter_youngest_upstream_msg_iter( if (ret) { /* get_msg_ts_ns() logs errors */ *muxer_upstream_msg_iter = NULL; - status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_ERROR; + status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_ERROR; goto end; } @@ -920,7 +920,7 @@ muxer_msg_iter_youngest_upstream_msg_iter( } if (!*muxer_upstream_msg_iter) { - status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_END; + status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_END; *ts_ns = INT64_MIN; } @@ -929,13 +929,13 @@ end: } static -bt_component_class_message_iterator_next_method_status +bt_message_iterator_class_next_method_status validate_muxer_upstream_msg_iter( struct muxer_upstream_msg_iter *muxer_upstream_msg_iter, bool *is_ended) { struct muxer_comp *muxer_comp = muxer_upstream_msg_iter->muxer_comp; - bt_component_class_message_iterator_next_method_status status; + bt_message_iterator_class_next_method_status status; BT_COMP_LOGD("Validating muxer's upstream message iterator wrapper: " "muxer-upstream-msg-iter-wrap-addr=%p", @@ -947,7 +947,7 @@ validate_muxer_upstream_msg_iter( "queue-len=%u, upstream-msg-iter-addr=%p", muxer_upstream_msg_iter->msgs->length, muxer_upstream_msg_iter->msg_iter); - status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK; + status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK; goto end; } @@ -960,12 +960,12 @@ end: } static -bt_component_class_message_iterator_next_method_status +bt_message_iterator_class_next_method_status validate_muxer_upstream_msg_iters( struct muxer_msg_iter *muxer_msg_iter) { struct muxer_comp *muxer_comp = muxer_msg_iter->muxer_comp; - bt_component_class_message_iterator_next_method_status status; + bt_message_iterator_class_next_method_status status; size_t i; BT_COMP_LOGD("Validating muxer's upstream message iterator wrappers: " @@ -981,7 +981,7 @@ validate_muxer_upstream_msg_iters( status = validate_muxer_upstream_msg_iter( muxer_upstream_msg_iter, &is_ended); - if (status != BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK) { + if (status != BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK) { if (status < 0) { BT_COMP_LOGE_APPEND_CAUSE(muxer_comp->self_comp, "Cannot validate muxer's upstream message iterator wrapper: " @@ -1025,24 +1025,24 @@ validate_muxer_upstream_msg_iters( } } - status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK; + status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK; end: return status; } static inline -bt_component_class_message_iterator_next_method_status muxer_msg_iter_do_next_one( +bt_message_iterator_class_next_method_status muxer_msg_iter_do_next_one( struct muxer_comp *muxer_comp, struct muxer_msg_iter *muxer_msg_iter, const bt_message **msg) { - bt_component_class_message_iterator_next_method_status status; + bt_message_iterator_class_next_method_status status; struct muxer_upstream_msg_iter *muxer_upstream_msg_iter = NULL; int64_t next_return_ts; status = validate_muxer_upstream_msg_iters(muxer_msg_iter); - if (status != BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK) { + if (status != BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK) { /* validate_muxer_upstream_msg_iters() logs details */ goto end; } @@ -1056,7 +1056,7 @@ bt_component_class_message_iterator_next_method_status muxer_msg_iter_do_next_on status = muxer_msg_iter_youngest_upstream_msg_iter(muxer_comp, muxer_msg_iter, &muxer_upstream_msg_iter, &next_return_ts); - if (status < 0 || status == BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_END) { + if (status < 0 || status == BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_END) { if (status < 0) { BT_COMP_LOGE_APPEND_CAUSE(muxer_comp->self_comp, "Cannot find the youngest upstream message iterator wrapper: " @@ -1078,7 +1078,7 @@ bt_component_class_message_iterator_next_method_status muxer_msg_iter_do_next_on "last-returned-ts=%" PRId64, muxer_msg_iter, next_return_ts, muxer_msg_iter->last_returned_ts_ns); - status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_ERROR; + status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_ERROR; goto end; } @@ -1088,7 +1088,7 @@ bt_component_class_message_iterator_next_method_status muxer_msg_iter_do_next_on "ts=%" PRId64, muxer_msg_iter, muxer_upstream_msg_iter, next_return_ts); BT_ASSERT_DBG(status == - BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK); + BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK); BT_ASSERT_DBG(muxer_upstream_msg_iter); /* @@ -1104,13 +1104,13 @@ end: } static -bt_component_class_message_iterator_next_method_status muxer_msg_iter_do_next( +bt_message_iterator_class_next_method_status muxer_msg_iter_do_next( struct muxer_comp *muxer_comp, struct muxer_msg_iter *muxer_msg_iter, bt_message_array_const msgs, uint64_t capacity, uint64_t *count) { - bt_component_class_message_iterator_next_method_status status; + bt_message_iterator_class_next_method_status status; uint64_t i = 0; if (G_UNLIKELY(muxer_msg_iter->next_saved_error)) { @@ -1127,10 +1127,10 @@ bt_component_class_message_iterator_next_method_status muxer_msg_iter_do_next( do { status = muxer_msg_iter_do_next_one(muxer_comp, muxer_msg_iter, &msgs[i]); - if (status == BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK) { + if (status == BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK) { i++; } - } while (i < capacity && status == BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK); + } while (i < capacity && status == BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK); if (i > 0) { /* @@ -1158,7 +1158,7 @@ bt_component_class_message_iterator_next_method_status muxer_msg_iter_do_next( } *count = i; - status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK; + status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK; } end: @@ -1194,14 +1194,14 @@ void destroy_muxer_msg_iter(struct muxer_msg_iter *muxer_msg_iter) } static -bt_component_class_message_iterator_initialize_method_status +bt_message_iterator_class_initialize_method_status muxer_msg_iter_init_upstream_iterators(struct muxer_comp *muxer_comp, struct muxer_msg_iter *muxer_msg_iter, struct bt_self_message_iterator_configuration *config) { int64_t count; int64_t i; - bt_component_class_message_iterator_initialize_method_status status; + bt_message_iterator_class_initialize_method_status status; bool can_seek_forward = true; count = bt_component_filter_get_input_port_count( @@ -1211,7 +1211,7 @@ muxer_msg_iter_init_upstream_iterators(struct muxer_comp *muxer_comp, BT_COMP_LOGD("No input port to initialize for muxer component's message iterator: " "muxer-comp-addr=%p, muxer-msg-iter-addr=%p", muxer_comp, muxer_msg_iter); - status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INITIALIZE_METHOD_STATUS_OK; + status = BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_OK; goto end; } @@ -1249,7 +1249,7 @@ muxer_msg_iter_init_upstream_iterators(struct muxer_comp *muxer_comp, bt_self_component_port_input_message_iterator_put_ref( upstream_msg_iter); if (int_status) { - status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INITIALIZE_METHOD_STATUS_ERROR; + status = BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_ERROR; /* muxer_msg_iter_add_upstream_msg_iter() logs errors */ goto end; } @@ -1266,25 +1266,24 @@ muxer_msg_iter_init_upstream_iterators(struct muxer_comp *muxer_comp, bt_self_message_iterator_configuration_set_can_seek_forward( config, can_seek_forward); - status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INITIALIZE_METHOD_STATUS_OK; + status = BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_OK; end: return status; } BT_HIDDEN -bt_component_class_message_iterator_initialize_method_status muxer_msg_iter_init( +bt_message_iterator_class_initialize_method_status muxer_msg_iter_init( bt_self_message_iterator *self_msg_iter, bt_self_message_iterator_configuration *config, - bt_self_component_filter *self_comp, + bt_self_component *self_comp, bt_self_component_port_output *port) { struct muxer_comp *muxer_comp = NULL; struct muxer_msg_iter *muxer_msg_iter = NULL; - bt_component_class_message_iterator_initialize_method_status status; + bt_message_iterator_class_initialize_method_status status; - muxer_comp = bt_self_component_get_data( - bt_self_component_filter_as_self_component(self_comp)); + muxer_comp = bt_self_component_get_data(self_comp); BT_ASSERT(muxer_comp); BT_COMP_LOGD("Initializing muxer component's message iterator: " "comp-addr=%p, muxer-comp-addr=%p, msg-iter-addr=%p", @@ -1299,7 +1298,7 @@ bt_component_class_message_iterator_initialize_method_status muxer_msg_iter_init BT_COMP_LOGE("Recursive initialization of muxer component's message iterator: " "comp-addr=%p, muxer-comp-addr=%p, msg-iter-addr=%p", self_comp, muxer_comp, self_msg_iter); - status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INITIALIZE_METHOD_STATUS_ERROR; + status = BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_ERROR; goto error; } @@ -1307,7 +1306,7 @@ bt_component_class_message_iterator_initialize_method_status muxer_msg_iter_init muxer_msg_iter = g_new0(struct muxer_msg_iter, 1); if (!muxer_msg_iter) { BT_COMP_LOGE_STR("Failed to allocate one muxer component's message iterator."); - status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INITIALIZE_METHOD_STATUS_MEMORY_ERROR; + status = BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_MEMORY_ERROR; goto error; } @@ -1319,7 +1318,7 @@ bt_component_class_message_iterator_initialize_method_status muxer_msg_iter_init (GDestroyNotify) destroy_muxer_upstream_msg_iter); if (!muxer_msg_iter->active_muxer_upstream_msg_iters) { BT_COMP_LOGE_STR("Failed to allocate a GPtrArray."); - status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INITIALIZE_METHOD_STATUS_MEMORY_ERROR; + status = BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_MEMORY_ERROR; goto error; } @@ -1328,7 +1327,7 @@ bt_component_class_message_iterator_initialize_method_status muxer_msg_iter_init (GDestroyNotify) destroy_muxer_upstream_msg_iter); if (!muxer_msg_iter->ended_muxer_upstream_msg_iters) { BT_COMP_LOGE_STR("Failed to allocate a GPtrArray."); - status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INITIALIZE_METHOD_STATUS_MEMORY_ERROR; + status = BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_MEMORY_ERROR; goto error; } @@ -1382,12 +1381,12 @@ void muxer_msg_iter_finalize(bt_self_message_iterator *self_msg_iter) } BT_HIDDEN -bt_component_class_message_iterator_next_method_status muxer_msg_iter_next( +bt_message_iterator_class_next_method_status muxer_msg_iter_next( bt_self_message_iterator *self_msg_iter, bt_message_array_const msgs, uint64_t capacity, uint64_t *count) { - bt_component_class_message_iterator_next_method_status status; + bt_message_iterator_class_next_method_status status; struct muxer_msg_iter *muxer_msg_iter = bt_self_message_iterator_get_data(self_msg_iter); bt_self_component *self_comp = NULL; @@ -1454,12 +1453,12 @@ end: } static inline -bt_component_class_message_iterator_can_seek_beginning_method_status +bt_message_iterator_class_can_seek_beginning_method_status muxer_upstream_msg_iters_can_all_seek_beginning( GPtrArray *muxer_upstream_msg_iters, bt_bool *can_seek) { - bt_component_class_message_iterator_can_seek_beginning_method_status status = - BT_COMPONENT_CLASS_MESSAGE_ITERATOR_CAN_SEEK_BEGINNING_METHOD_STATUS_OK; + bt_message_iterator_class_can_seek_beginning_method_status status = + BT_MESSAGE_ITERATOR_CLASS_CAN_SEEK_BEGINNING_METHOD_STATUS_OK; uint64_t i; for (i = 0; i < muxer_upstream_msg_iters->len; i++) { @@ -1467,7 +1466,7 @@ muxer_upstream_msg_iters_can_all_seek_beginning( muxer_upstream_msg_iters->pdata[i]; status = (int) bt_self_component_port_input_message_iterator_can_seek_beginning( upstream_msg_iter->msg_iter, can_seek); - if (status != BT_COMPONENT_CLASS_MESSAGE_ITERATOR_CAN_SEEK_BEGINNING_METHOD_STATUS_OK) { + if (status != BT_MESSAGE_ITERATOR_CLASS_CAN_SEEK_BEGINNING_METHOD_STATUS_OK) { goto end; } @@ -1483,17 +1482,17 @@ end: } BT_HIDDEN -bt_component_class_message_iterator_can_seek_beginning_method_status +bt_message_iterator_class_can_seek_beginning_method_status muxer_msg_iter_can_seek_beginning( bt_self_message_iterator *self_msg_iter, bt_bool *can_seek) { struct muxer_msg_iter *muxer_msg_iter = bt_self_message_iterator_get_data(self_msg_iter); - bt_component_class_message_iterator_can_seek_beginning_method_status status; + bt_message_iterator_class_can_seek_beginning_method_status status; status = muxer_upstream_msg_iters_can_all_seek_beginning( muxer_msg_iter->active_muxer_upstream_msg_iters, can_seek); - if (status != BT_COMPONENT_CLASS_MESSAGE_ITERATOR_CAN_SEEK_BEGINNING_METHOD_STATUS_OK) { + if (status != BT_MESSAGE_ITERATOR_CLASS_CAN_SEEK_BEGINNING_METHOD_STATUS_OK) { goto end; } @@ -1509,13 +1508,13 @@ end: } BT_HIDDEN -bt_component_class_message_iterator_seek_beginning_method_status muxer_msg_iter_seek_beginning( +bt_message_iterator_class_seek_beginning_method_status muxer_msg_iter_seek_beginning( bt_self_message_iterator *self_msg_iter) { struct muxer_msg_iter *muxer_msg_iter = bt_self_message_iterator_get_data(self_msg_iter); - bt_component_class_message_iterator_seek_beginning_method_status status = - BT_COMPONENT_CLASS_MESSAGE_ITERATOR_SEEK_BEGINNING_METHOD_STATUS_OK; + bt_message_iterator_class_seek_beginning_method_status status = + BT_MESSAGE_ITERATOR_CLASS_SEEK_BEGINNING_METHOD_STATUS_OK; bt_message_iterator_seek_beginning_status seek_beg_status; uint64_t i; diff --git a/src/plugins/utils/muxer/muxer.h b/src/plugins/utils/muxer/muxer.h index da5c0252..aa9a21dd 100644 --- a/src/plugins/utils/muxer/muxer.h +++ b/src/plugins/utils/muxer/muxer.h @@ -38,10 +38,10 @@ BT_HIDDEN void muxer_finalize(bt_self_component_filter *self_comp); BT_HIDDEN -bt_component_class_message_iterator_initialize_method_status muxer_msg_iter_init( +bt_message_iterator_class_initialize_method_status muxer_msg_iter_init( bt_self_message_iterator *self_msg_iter, bt_self_message_iterator_configuration *config, - bt_self_component_filter *self_comp, + bt_self_component *self_comp, bt_self_component_port_output *self_port); BT_HIDDEN @@ -49,7 +49,7 @@ void muxer_msg_iter_finalize( bt_self_message_iterator *self_msg_iter); BT_HIDDEN -bt_component_class_message_iterator_next_method_status muxer_msg_iter_next( +bt_message_iterator_class_next_method_status muxer_msg_iter_next( bt_self_message_iterator *self_msg_iter, bt_message_array_const msgs, uint64_t capacity, uint64_t *count); @@ -61,12 +61,12 @@ bt_component_class_port_connected_method_status muxer_input_port_connected( const bt_port_output *other_port); BT_HIDDEN -bt_component_class_message_iterator_can_seek_beginning_method_status +bt_message_iterator_class_can_seek_beginning_method_status muxer_msg_iter_can_seek_beginning( bt_self_message_iterator *message_iterator, bt_bool *can_seek); BT_HIDDEN -bt_component_class_message_iterator_seek_beginning_method_status muxer_msg_iter_seek_beginning( +bt_message_iterator_class_seek_beginning_method_status muxer_msg_iter_seek_beginning( bt_self_message_iterator *message_iterator); #endif /* BABELTRACE_PLUGINS_UTILS_MUXER_H */ diff --git a/src/plugins/utils/trimmer/trimmer.c b/src/plugins/utils/trimmer/trimmer.c index c156c0fe..d7f5576b 100644 --- a/src/plugins/utils/trimmer/trimmer.c +++ b/src/plugins/utils/trimmer/trimmer.c @@ -76,6 +76,7 @@ struct trimmer_comp { bool is_gmt; bt_logging_level log_level; bt_self_component *self_comp; + bt_self_component_filter *self_comp_filter; }; enum trimmer_iterator_state { @@ -627,6 +628,7 @@ bt_component_class_initialize_method_status trimmer_init( trimmer_comp->log_level = bt_component_get_logging_level( bt_self_component_as_component(self_comp)); trimmer_comp->self_comp = self_comp; + trimmer_comp->self_comp_filter = self_comp_flt; add_port_status = bt_self_component_filter_add_input_port( self_comp_flt, in_port_name, NULL, NULL); @@ -694,25 +696,24 @@ void destroy_trimmer_iterator_stream_state( } BT_HIDDEN -bt_component_class_message_iterator_initialize_method_status trimmer_msg_iter_init( +bt_message_iterator_class_initialize_method_status trimmer_msg_iter_init( bt_self_message_iterator *self_msg_iter, bt_self_message_iterator_configuration *config, - bt_self_component_filter *self_comp, + bt_self_component *self_comp, bt_self_component_port_output *port) { - bt_component_class_message_iterator_initialize_method_status status; + bt_message_iterator_class_initialize_method_status status; bt_self_component_port_input_message_iterator_create_from_message_iterator_status msg_iter_status; struct trimmer_iterator *trimmer_it; trimmer_it = g_new0(struct trimmer_iterator, 1); if (!trimmer_it) { - status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INITIALIZE_METHOD_STATUS_MEMORY_ERROR; + status = BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_MEMORY_ERROR; goto error; } - trimmer_it->trimmer_comp = bt_self_component_get_data( - bt_self_component_filter_as_self_component(self_comp)); + trimmer_it->trimmer_comp = bt_self_component_get_data(self_comp); BT_ASSERT(trimmer_it->trimmer_comp); if (trimmer_it->trimmer_comp->begin.is_set && @@ -732,7 +733,8 @@ bt_component_class_message_iterator_initialize_method_status trimmer_msg_iter_in bt_self_component_port_input_message_iterator_create_from_message_iterator( self_msg_iter, bt_self_component_filter_borrow_input_port_by_name( - self_comp, in_port_name), &trimmer_it->upstream_iter); + trimmer_it->trimmer_comp->self_comp_filter, in_port_name), + &trimmer_it->upstream_iter); if (msg_iter_status != BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_CREATE_FROM_MESSAGE_ITERATOR_STATUS_OK) { status = (int) msg_iter_status; goto error; @@ -740,7 +742,7 @@ bt_component_class_message_iterator_initialize_method_status trimmer_msg_iter_in trimmer_it->output_messages = g_queue_new(); if (!trimmer_it->output_messages) { - status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INITIALIZE_METHOD_STATUS_MEMORY_ERROR; + status = BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_MEMORY_ERROR; goto error; } @@ -748,7 +750,7 @@ bt_component_class_message_iterator_initialize_method_status trimmer_msg_iter_in g_direct_equal, NULL, (GDestroyNotify) destroy_trimmer_iterator_stream_state); if (!trimmer_it->stream_states) { - status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INITIALIZE_METHOD_STATUS_MEMORY_ERROR; + status = BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_MEMORY_ERROR; goto error; } @@ -762,7 +764,7 @@ bt_component_class_message_iterator_initialize_method_status trimmer_msg_iter_in trimmer_it->self_msg_iter = self_msg_iter; bt_self_message_iterator_set_data(self_msg_iter, trimmer_it); - status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INITIALIZE_METHOD_STATUS_OK; + status = BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_OK; goto end; error: @@ -951,7 +953,7 @@ end: } static -bt_component_class_message_iterator_next_method_status +bt_message_iterator_class_next_method_status state_set_trimmer_iterator_bounds( struct trimmer_iterator *trimmer_it) { @@ -1033,11 +1035,11 @@ end: } static -bt_component_class_message_iterator_next_method_status state_seek_initially( +bt_message_iterator_class_next_method_status state_seek_initially( struct trimmer_iterator *trimmer_it) { struct trimmer_comp *trimmer_comp = trimmer_it->trimmer_comp; - bt_component_class_message_iterator_next_method_status status; + bt_message_iterator_class_next_method_status status; BT_ASSERT(trimmer_it->begin.is_set); @@ -1046,7 +1048,7 @@ bt_component_class_message_iterator_next_method_status state_seek_initially( status = (int) bt_self_component_port_input_message_iterator_can_seek_beginning( trimmer_it->upstream_iter, &can_seek); - if (status != BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK) { + if (status != BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK) { if (status < 0) { BT_COMP_LOGE_APPEND_CAUSE(trimmer_comp->self_comp, "Cannot make upstream message iterator initially seek its beginning."); @@ -1058,7 +1060,7 @@ bt_component_class_message_iterator_next_method_status state_seek_initially( if (!can_seek) { BT_COMP_LOGE_APPEND_CAUSE(trimmer_comp->self_comp, "Cannot make upstream message iterator initially seek its beginning."); - status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_ERROR; + status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_ERROR; goto end; } @@ -1071,7 +1073,7 @@ bt_component_class_message_iterator_next_method_status state_seek_initially( trimmer_it->upstream_iter, trimmer_it->begin.ns_from_origin, &can_seek); - if (status != BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK) { + if (status != BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK) { if (status < 0) { BT_COMP_LOGE_APPEND_CAUSE(trimmer_comp->self_comp, "Cannot make upstream message iterator initially seek: seek-ns-from-origin=%" PRId64, @@ -1085,7 +1087,7 @@ bt_component_class_message_iterator_next_method_status state_seek_initially( BT_COMP_LOGE_APPEND_CAUSE(trimmer_comp->self_comp, "Cannot make upstream message iterator initially seek: seek-ns-from-origin=%" PRId64, trimmer_it->begin.ns_from_origin); - status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_ERROR; + status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_ERROR; goto end; } @@ -1093,7 +1095,7 @@ bt_component_class_message_iterator_next_method_status state_seek_initially( trimmer_it->upstream_iter, trimmer_it->begin.ns_from_origin); } - if (status == BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK) { + if (status == BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK) { trimmer_it->state = TRIMMER_ITERATOR_STATE_TRIM; } @@ -1129,12 +1131,12 @@ int clock_raw_value_from_ns_from_origin(const bt_clock_class *clock_class, } static inline -bt_component_class_message_iterator_next_method_status +bt_message_iterator_class_next_method_status end_stream(struct trimmer_iterator *trimmer_it, struct trimmer_iterator_stream_state *sstate) { - bt_component_class_message_iterator_next_method_status status = - BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK; + bt_message_iterator_class_next_method_status status = + BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK; /* Initialize to silence maybe-uninitialized warning. */ uint64_t raw_value = 0; bt_message *msg = NULL; @@ -1162,7 +1164,7 @@ end_stream(struct trimmer_iterator *trimmer_it, ret = clock_raw_value_from_ns_from_origin(clock_class, trimmer_it->end.ns_from_origin, &raw_value); if (ret) { - status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_ERROR; + status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_ERROR; goto end; } } @@ -1183,7 +1185,7 @@ end_stream(struct trimmer_iterator *trimmer_it, trimmer_it->self_msg_iter, sstate->cur_packet, raw_value); if (!msg) { - status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_MEMORY_ERROR; + status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_MEMORY_ERROR; goto end; } @@ -1196,7 +1198,7 @@ end_stream(struct trimmer_iterator *trimmer_it, msg = bt_message_stream_end_create(trimmer_it->self_msg_iter, sstate->stream); if (!msg) { - status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_MEMORY_ERROR; + status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_MEMORY_ERROR; goto end; } @@ -1219,11 +1221,11 @@ end: } static inline -bt_component_class_message_iterator_next_method_status end_iterator_streams( +bt_message_iterator_class_next_method_status end_iterator_streams( struct trimmer_iterator *trimmer_it) { - bt_component_class_message_iterator_next_method_status status = - BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK; + bt_message_iterator_class_next_method_status status = + BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK; GHashTableIter iter; gpointer key, sstate; @@ -1257,14 +1259,14 @@ end: } static -bt_component_class_message_iterator_next_method_status +bt_message_iterator_class_next_method_status create_stream_state_entry( struct trimmer_iterator *trimmer_it, const struct bt_stream *stream, struct trimmer_iterator_stream_state **stream_state) { struct trimmer_comp *trimmer_comp = trimmer_it->trimmer_comp; - bt_component_class_message_iterator_next_method_status status; + bt_message_iterator_class_next_method_status status; struct trimmer_iterator_stream_state *sstate; const bt_stream_class *sc; @@ -1290,7 +1292,7 @@ create_stream_state_entry( "stream-name=\"%s\"", stream, bt_stream_get_id(stream), bt_stream_get_name(stream)); - status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_ERROR; + status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_ERROR; goto end; } @@ -1310,7 +1312,7 @@ create_stream_state_entry( "stream-name=\"%s\"", stream, bt_stream_get_id(stream), bt_stream_get_name(stream)); - status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_ERROR; + status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_ERROR; goto end; } @@ -1323,7 +1325,7 @@ create_stream_state_entry( "stream-name=\"%s\"", stream, bt_stream_get_id(stream), bt_stream_get_name(stream)); - status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_ERROR; + status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_ERROR; goto end; } @@ -1336,7 +1338,7 @@ create_stream_state_entry( "stream-name=\"%s\"", stream, bt_stream_get_id(stream), bt_stream_get_name(stream)); - status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_ERROR; + status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_ERROR; goto end; } @@ -1350,13 +1352,13 @@ create_stream_state_entry( "stream-name=\"%s\"", stream, bt_stream_get_id(stream), bt_stream_get_name(stream)); - status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_ERROR; + status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_ERROR; goto end; } sstate = g_new0(struct trimmer_iterator_stream_state, 1); if (!sstate) { - status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_MEMORY_ERROR; + status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_MEMORY_ERROR; goto end; } @@ -1366,7 +1368,7 @@ create_stream_state_entry( *stream_state = sstate; - status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK; + status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK; end: return status; @@ -1403,14 +1405,14 @@ struct trimmer_iterator_stream_state *get_stream_state_entry( * `reached_end`. */ static -bt_component_class_message_iterator_next_method_status +bt_message_iterator_class_next_method_status handle_message_with_stream( struct trimmer_iterator *trimmer_it, const bt_message *msg, const struct bt_stream *stream, const int64_t *ns_from_origin, bool *reached_end) { - bt_component_class_message_iterator_next_method_status status = - BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK; + bt_message_iterator_class_next_method_status status = + BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK; bt_message_type msg_type = bt_message_get_type(msg); int ret; struct trimmer_iterator_stream_state *sstate = NULL; @@ -1530,7 +1532,7 @@ handle_message_with_stream( if (bt_clock_snapshot_get_ns_from_origin(end_cs, &end_ns_from_origin)) { - status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_ERROR; + status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_ERROR; goto end; } @@ -1560,7 +1562,7 @@ handle_message_with_stream( ret = clock_raw_value_from_ns_from_origin(clock_class, trimmer_it->end.ns_from_origin, &end_raw_value); if (ret) { - status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_ERROR; + status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_ERROR; goto end; } @@ -1583,7 +1585,7 @@ handle_message_with_stream( } if (!new_msg) { - status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_MEMORY_ERROR; + status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_MEMORY_ERROR; goto end; } @@ -1610,7 +1612,7 @@ handle_message_with_stream( /* Learn about this stream. */ status = create_stream_state_entry(trimmer_it, stream, &sstate); - if (status != BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK) { + if (status != BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK) { goto end; } @@ -1672,11 +1674,11 @@ end: * `reached_end`. */ static inline -bt_component_class_message_iterator_next_method_status handle_message( +bt_message_iterator_class_next_method_status handle_message( struct trimmer_iterator *trimmer_it, const bt_message *msg, bool *reached_end) { - bt_component_class_message_iterator_next_method_status status; + bt_message_iterator_class_next_method_status status; const bt_stream *stream = NULL; int64_t ns_from_origin = INT64_MIN; bool has_ns_from_origin = false; @@ -1715,7 +1717,7 @@ bt_component_class_message_iterator_next_method_status handle_message( /* Retrieve the message's time */ ret = get_msg_ns_from_origin(msg, &ns_from_origin, &has_ns_from_origin); if (G_UNLIKELY(ret)) { - status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_ERROR; + status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_ERROR; goto end; } @@ -1740,7 +1742,7 @@ bt_component_class_message_iterator_next_method_status handle_message( *reached_end = true; } else { push_message(trimmer_it, msg); - status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK; + status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK; msg = NULL; } } @@ -1772,17 +1774,17 @@ void fill_message_array_from_output_messages( } static inline -bt_component_class_message_iterator_next_method_status state_ending( +bt_message_iterator_class_next_method_status state_ending( struct trimmer_iterator *trimmer_it, bt_message_array_const msgs, uint64_t capacity, uint64_t *count) { - bt_component_class_message_iterator_next_method_status status = - BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK; + bt_message_iterator_class_next_method_status status = + BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK; if (g_queue_is_empty(trimmer_it->output_messages)) { trimmer_it->state = TRIMMER_ITERATOR_STATE_ENDED; - status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_END; + status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_END; goto end; } @@ -1794,13 +1796,13 @@ end: } static inline -bt_component_class_message_iterator_next_method_status +bt_message_iterator_class_next_method_status state_trim(struct trimmer_iterator *trimmer_it, bt_message_array_const msgs, uint64_t capacity, uint64_t *count) { - bt_component_class_message_iterator_next_method_status status = - BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK; + bt_message_iterator_class_next_method_status status = + BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK; bt_message_array_const my_msgs; uint64_t my_count; uint64_t i; @@ -1809,10 +1811,10 @@ state_trim(struct trimmer_iterator *trimmer_it, while (g_queue_is_empty(trimmer_it->output_messages)) { status = (int) bt_self_component_port_input_message_iterator_next( trimmer_it->upstream_iter, &my_msgs, &my_count); - if (G_UNLIKELY(status != BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK)) { - if (status == BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_END) { + if (G_UNLIKELY(status != BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK)) { + if (status == BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_END) { status = end_iterator_streams(trimmer_it); - if (status != BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK) { + if (status != BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK) { goto end; } @@ -1838,7 +1840,7 @@ state_trim(struct trimmer_iterator *trimmer_it, my_msgs[i] = NULL; if (G_UNLIKELY(status != - BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK)) { + BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK)) { put_messages(my_msgs, my_count); goto end; } @@ -1877,50 +1879,50 @@ end: } BT_HIDDEN -bt_component_class_message_iterator_next_method_status trimmer_msg_iter_next( +bt_message_iterator_class_next_method_status trimmer_msg_iter_next( bt_self_message_iterator *self_msg_iter, bt_message_array_const msgs, uint64_t capacity, uint64_t *count) { struct trimmer_iterator *trimmer_it = bt_self_message_iterator_get_data(self_msg_iter); - bt_component_class_message_iterator_next_method_status status = - BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK; + bt_message_iterator_class_next_method_status status = + BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK; BT_ASSERT_DBG(trimmer_it); if (G_LIKELY(trimmer_it->state == TRIMMER_ITERATOR_STATE_TRIM)) { status = state_trim(trimmer_it, msgs, capacity, count); - if (status != BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK) { + if (status != BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK) { goto end; } } else { switch (trimmer_it->state) { case TRIMMER_ITERATOR_STATE_SET_BOUNDS_NS_FROM_ORIGIN: status = state_set_trimmer_iterator_bounds(trimmer_it); - if (status != BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK) { + if (status != BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK) { goto end; } status = state_seek_initially(trimmer_it); - if (status != BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK) { + if (status != BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK) { goto end; } status = state_trim(trimmer_it, msgs, capacity, count); - if (status != BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK) { + if (status != BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK) { goto end; } break; case TRIMMER_ITERATOR_STATE_SEEK_INITIALLY: status = state_seek_initially(trimmer_it); - if (status != BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK) { + if (status != BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK) { goto end; } status = state_trim(trimmer_it, msgs, capacity, count); - if (status != BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK) { + if (status != BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK) { goto end; } @@ -1928,13 +1930,13 @@ bt_component_class_message_iterator_next_method_status trimmer_msg_iter_next( case TRIMMER_ITERATOR_STATE_ENDING: status = state_ending(trimmer_it, msgs, capacity, count); - if (status != BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK) { + if (status != BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK) { goto end; } break; case TRIMMER_ITERATOR_STATE_ENDED: - status = BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_END; + status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_END; break; default: bt_common_abort(); diff --git a/src/plugins/utils/trimmer/trimmer.h b/src/plugins/utils/trimmer/trimmer.h index f9b06701..678aca29 100644 --- a/src/plugins/utils/trimmer/trimmer.h +++ b/src/plugins/utils/trimmer/trimmer.h @@ -40,14 +40,14 @@ bt_component_class_initialize_method_status trimmer_init( const bt_value *params, void *init_data); BT_HIDDEN -bt_component_class_message_iterator_initialize_method_status trimmer_msg_iter_init( +bt_message_iterator_class_initialize_method_status trimmer_msg_iter_init( bt_self_message_iterator *self_msg_iter, bt_self_message_iterator_configuration *config, - bt_self_component_filter *self_comp, + bt_self_component *self_comp, bt_self_component_port_output *port); BT_HIDDEN -bt_component_class_message_iterator_next_method_status trimmer_msg_iter_next( +bt_message_iterator_class_next_method_status trimmer_msg_iter_next( bt_self_message_iterator *self_msg_iter, bt_message_array_const msgs, uint64_t capacity, uint64_t *count); diff --git a/tests/lib/test-plugin-plugins/sfs.c b/tests/lib/test-plugin-plugins/sfs.c index c08f4156..2a05f0f1 100644 --- a/tests/lib/test-plugin-plugins/sfs.c +++ b/tests/lib/test-plugin-plugins/sfs.c @@ -24,24 +24,24 @@ static bt_component_class_sink_consume_method_status sink_consume( return BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_OK; } -static bt_component_class_message_iterator_initialize_method_status +static bt_message_iterator_class_initialize_method_status src_dummy_iterator_init_method( bt_self_message_iterator *self_msg_iter, bt_self_message_iterator_configuration *config, - bt_self_component_source *self_comp, + bt_self_component *self_comp, bt_self_component_port_output *self_port) { - return BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INITIALIZE_METHOD_STATUS_OK; + return BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_OK; } -static bt_component_class_message_iterator_initialize_method_status +static bt_message_iterator_class_initialize_method_status flt_dummy_iterator_init_method( bt_self_message_iterator *self_msg_iter, bt_self_message_iterator_configuration *config, - bt_self_component_filter *self_comp, + bt_self_component *self_comp, bt_self_component_port_output *self_port) { - return BT_COMPONENT_CLASS_MESSAGE_ITERATOR_INITIALIZE_METHOD_STATUS_OK; + return BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_OK; } static void dummy_iterator_finalize_method( @@ -49,13 +49,13 @@ static void dummy_iterator_finalize_method( { } -static bt_component_class_message_iterator_next_method_status +static bt_message_iterator_class_next_method_status dummy_iterator_next_method( bt_self_message_iterator *self_msg_iter, bt_message_array_const msgs, uint64_t capacity, uint64_t *count) { - return BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK; + return BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK; } static bt_component_class_query_method_status flt_query_method( diff --git a/tests/lib/test_graph_topo.c b/tests/lib/test_graph_topo.c index 91e12760..d3d45818 100644 --- a/tests/lib/test_graph_topo.c +++ b/tests/lib/test_graph_topo.c @@ -72,6 +72,7 @@ struct event { }; static GArray *events; +static bt_message_iterator_class *msg_iter_class; static bt_component_class_source *src_comp_class; static bt_component_class_sink *sink_comp_class; static enum test current_test; @@ -190,12 +191,12 @@ size_t event_pos(struct event *event) } static -bt_component_class_message_iterator_next_method_status src_iter_next( +bt_message_iterator_class_next_method_status src_iter_next( bt_self_message_iterator *self_iterator, bt_message_array_const msgs, uint64_t capacity, uint64_t *count) { - return BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_ERROR; + return BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_ERROR; } static @@ -339,8 +340,11 @@ void init_test(void) { int ret; + msg_iter_class = bt_message_iterator_class_create(src_iter_next); + BT_ASSERT(msg_iter_class); + src_comp_class = bt_component_class_source_create( - "src", src_iter_next); + "src", msg_iter_class); BT_ASSERT(src_comp_class); ret = bt_component_class_source_set_initialize_method( src_comp_class, src_init); diff --git a/tests/lib/test_remove_destruction_listener_in_destruction_listener.c b/tests/lib/test_remove_destruction_listener_in_destruction_listener.c index 7bf47133..2cc1b76c 100644 --- a/tests/lib/test_remove_destruction_listener_in_destruction_listener.c +++ b/tests/lib/test_remove_destruction_listener_in_destruction_listener.c @@ -240,18 +240,19 @@ bt_component_class_initialize_method_status hello_init( } static -bt_component_class_message_iterator_next_method_status hello_iter_next( +bt_message_iterator_class_next_method_status hello_iter_next( bt_self_message_iterator *message_iterator, bt_message_array_const msgs, uint64_t capacity, uint64_t *count) { BT_ASSERT(false); - return BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK; + return BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK; } int main(int argc, char **argv) { bt_graph *graph; + bt_message_iterator_class *msg_iter_cls; bt_component_class_source *source_cc; bt_component_class_set_method_status set_method_status; bt_graph_add_component_status add_component_status; @@ -259,7 +260,10 @@ int main(int argc, char **argv) plan_tests(NR_TESTS); - source_cc = bt_component_class_source_create("Hello", hello_iter_next); + msg_iter_cls = bt_message_iterator_class_create(hello_iter_next); + BT_ASSERT(msg_iter_cls); + + source_cc = bt_component_class_source_create("Hello", msg_iter_cls); BT_ASSERT(source_cc); set_method_status = bt_component_class_source_set_initialize_method( @@ -276,6 +280,7 @@ int main(int argc, char **argv) bt_component_source_put_ref(source); bt_component_class_source_put_ref(source_cc); + bt_message_iterator_class_put_ref(msg_iter_cls); bt_graph_put_ref(graph); return exit_status(); diff --git a/tests/lib/test_simple_sink.c b/tests/lib/test_simple_sink.c index 87a13198..641aaed1 100644 --- a/tests/lib/test_simple_sink.c +++ b/tests/lib/test_simple_sink.c @@ -72,17 +72,18 @@ bt_component_class_initialize_method_status src_init( } static -bt_component_class_message_iterator_next_method_status src_iter_next( +bt_message_iterator_class_next_method_status src_iter_next( bt_self_message_iterator *message_iterator, bt_message_array_const msgs, uint64_t capacity, uint64_t *count) { - return BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_END; + return BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_END; } static bt_graph *create_graph_with_source(const bt_port_output **out_port) { + bt_message_iterator_class *msg_iter_cls; bt_component_class_source *src_comp_cls; bt_graph *graph; const bt_component_source *src_comp = NULL; @@ -90,7 +91,11 @@ bt_graph *create_graph_with_source(const bt_port_output **out_port) bt_component_class_set_method_status set_method_status; BT_ASSERT(out_port); - src_comp_cls = bt_component_class_source_create("src", src_iter_next); + + msg_iter_cls = bt_message_iterator_class_create(src_iter_next); + BT_ASSERT(msg_iter_cls); + + src_comp_cls = bt_component_class_source_create("src", msg_iter_cls); BT_ASSERT(src_comp_cls); set_method_status = bt_component_class_source_set_initialize_method( src_comp_cls, src_init); @@ -106,6 +111,7 @@ bt_graph *create_graph_with_source(const bt_port_output **out_port) BT_ASSERT(*out_port); bt_component_source_put_ref(src_comp); bt_component_class_source_put_ref(src_comp_cls); + bt_message_iterator_class_put_ref(msg_iter_cls); return graph; } diff --git a/tests/lib/test_trace_ir_ref.c b/tests/lib/test_trace_ir_ref.c index ab1b920e..8811cf90 100644 --- a/tests/lib/test_trace_ir_ref.c +++ b/tests/lib/test_trace_ir_ref.c @@ -419,21 +419,25 @@ bt_component_class_initialize_method_status src_init( } static -bt_component_class_message_iterator_next_method_status src_iter_next( +bt_message_iterator_class_next_method_status src_iter_next( bt_self_message_iterator *self_iterator, bt_message_array_const msgs, uint64_t capacity, uint64_t *count) { - return BT_COMPONENT_CLASS_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_ERROR; + return BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_ERROR; } static void test_example_scenario_in_graph(void) { + bt_message_iterator_class *msg_iter_cls; bt_component_class_source *comp_cls; bt_graph *graph; int ret; - comp_cls = bt_component_class_source_create("src", src_iter_next); + msg_iter_cls = bt_message_iterator_class_create(src_iter_next); + BT_ASSERT(msg_iter_cls); + + comp_cls = bt_component_class_source_create("src", msg_iter_cls); BT_ASSERT(comp_cls); ret = bt_component_class_source_set_initialize_method(comp_cls, src_init); BT_ASSERT(ret == 0); @@ -443,6 +447,7 @@ static void test_example_scenario_in_graph(void) BT_ASSERT(ret == 0); bt_graph_put_ref(graph); bt_component_class_source_put_ref(comp_cls); + bt_message_iterator_class_put_ref(msg_iter_cls); } static void create_writer_user_full(struct writer_user *user) -- 2.34.1