lib: introduce bt_message_iterator_class
authorSimon Marchi <simon.marchi@efficios.com>
Fri, 20 Dec 2019 22:20:55 +0000 (17:20 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Mon, 20 Jan 2020 20:15:24 +0000 (15:15 -0500)
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 <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2725
Tested-by: jenkins <jenkins@lttng.org>
36 files changed:
CONTRIBUTING.adoc
include/Makefile.am
include/babeltrace2/graph/component-class-filter.h
include/babeltrace2/graph/component-class-source.h
include/babeltrace2/graph/component-class.h
include/babeltrace2/graph/message-iterator-class.h [new file with mode: 0644]
include/babeltrace2/plugin/plugin-dev.h
include/babeltrace2/types.h
src/bindings/python/bt2/bt2/native_bt_component_class.i.h
src/lib/graph/Makefile.am
src/lib/graph/component-class.c
src/lib/graph/component-class.h
src/lib/graph/iterator.c
src/lib/graph/message-iterator-class.c [new file with mode: 0644]
src/lib/graph/message-iterator-class.h [new file with mode: 0644]
src/lib/graph/message/iterator.h
src/lib/lib-logging.c
src/lib/plugin/plugin-so.c
src/plugins/ctf/fs-src/fs.c
src/plugins/ctf/fs-src/fs.h
src/plugins/ctf/lttng-live/lttng-live.c
src/plugins/ctf/lttng-live/lttng-live.h
src/plugins/lttng-utils/debug-info/debug-info.c
src/plugins/lttng-utils/debug-info/debug-info.h
src/plugins/text/dmesg/dmesg.c
src/plugins/text/dmesg/dmesg.h
src/plugins/text/pretty/pretty.c
src/plugins/utils/muxer/muxer.c
src/plugins/utils/muxer/muxer.h
src/plugins/utils/trimmer/trimmer.c
src/plugins/utils/trimmer/trimmer.h
tests/lib/test-plugin-plugins/sfs.c
tests/lib/test_graph_topo.c
tests/lib/test_remove_destruction_listener_in_destruction_listener.c
tests/lib/test_simple_sink.c
tests/lib/test_trace_ir_ref.c

index 72434e89346dc4ef7dcd15e306ae095898a87794..0eeb43ecd4432c77dc8c7270473c6469eb470afa 100644 (file)
@@ -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 *`
index 1594d2ca5053cfd8a3a66571566147a7921135e8..a44ef6ee0c0b9741d47fb9e84054f09f3ddcdd94 100644 (file)
@@ -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 \
index a6a69bea49aa05772d505766bb986108f646ca3e..9aa7a9c59f9a1143007671f2ebdf58a3807052d6 100644 (file)
@@ -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
index bdc85180b4759113092489ee8a45900f5d908033..10942f88ab4f11b502ae0c10c7044fb3c1540f40 100644 (file)
@@ -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
index b68439e8604eb4dcebc2c3f354b313d50713faea..b8495d45d0b0bcae7437e0cd58d9ff4ae20c0936 100644 (file)
@@ -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 (file)
index 0000000..c52fcd7
--- /dev/null
@@ -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 <babeltrace2/babeltrace.h> 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 */
index 0db0f6bfa1e9ef779bd50683ea8bc4f4b1194edc..f2e7a079393a322d51c1bc58ba751c20e01a5438 100644 (file)
@@ -33,6 +33,7 @@
 #include <babeltrace2/graph/component-class-source.h>
 #include <babeltrace2/graph/component-class-filter.h>
 #include <babeltrace2/graph/component-class-sink.h>
+#include <babeltrace2/graph/message-iterator-class.h>
 #include <babeltrace2/types.h>
 
 /*
@@ -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.
index 585905f1c68a22eb40e488e8138fdf9cb83f1fab..e2b9854eade93b07ab274b984da72dbd30059ccd 100644 (file)
@@ -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;
index 6ea021dee6adf02fd86f2bb6bdc86e8adde9b795..1f193685d101d5152fa94592e03164494a0b95ff 100644 (file)
@@ -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;
 }
 
index 7a9d63ee15b810a3b48a3521b8aac1c36877a53a..6a24d597ae5c6961b6746e0559f04bb176f162a4 100644 (file)
@@ -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 \
index 5f01158a2d5b7e7e82fb636d37d4ac1bd264ad9c..ea90b5ce32ab8987be8064983aeefd6b747b5046 100644 (file)
@@ -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,
index 359d85959914f34c75628532221fe6b9d254ad67..2b4b9454f4cd9eb1ca64a03f8db86ee8596d935e 100644 (file)
@@ -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
index 3ef5fd57d226a6e17d7a69157dedf79a1831fec7..4dd69c6ae69477c26b54ac35e3c22b2033c79ef0 100644 (file)
@@ -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 (file)
index 0000000..054d4a4
--- /dev/null
@@ -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 (file)
index 0000000..198f2fa
--- /dev/null
@@ -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 <pproulx@efficios.com>
+ * Copyright 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * 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 <babeltrace2/graph/message-iterator-class.h>
+#include <babeltrace2/types.h>
+#include "common/macros.h"
+#include "lib/object.h"
+#include <stdbool.h>
+#include <glib.h>
+
+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 */
index 52a1c046530c3e018d23a44a5dae88c90b78f33e..894a914cb68613cde5eeba2792c46225374af0f9 100644 (file)
@@ -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 *);
 
index 242f88d645fdaa20e8408ba6004c22f77debf8c4..02f18ed5a9d94e500f522dbe22492af10160f72f 100644 (file)
@@ -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;
index 60f3e4da22a8a0ca147163652284ba40f1d4442b..ebdbf8239fa6b7d8112f9354c8d22c8a0010b066 100644 (file)
@@ -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;
 }
index e8121140e8251967b967e33b5d57e0328274071b..a6712cb74ab9ae2a419728cc4088f169c4a7b752 100644 (file)
@@ -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:
index 446e84e559a4d73d566d40a5975908c3f8b52ebb..763136afef7be989fe7b2861f523c2179bbf7ba0 100644 (file)
@@ -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. */
index 2376d440bb4c3be91bc7f8efb8353087a2549811..6d77035b3ecde36fedcfac32db8fb097bef84980 100644 (file)
@@ -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;
index a6e1590df8b58b7c0d59ddf1c2f22a01c15ea164..39bc5abc5a39b67dbcb8f3b5e869790725ec582f 100644 (file)
@@ -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);
index c98cf604175bd31fdce288f170ee614460ec24cd..fe3424146fe3b719a79ac7d2247d77c560cdb465 100644 (file)
@@ -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);
index 6be8bd0e65ad789dcb9f5d86ec2d22ce8803fb5f..13fc0ff8cc110ddfcf3efc241146b5296f10e127 100644 (file)
@@ -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
index da21f69eaf964a1248ec98bb76cd0d4401f7c38c..65718d326b0f5e75eb9dd13f72087bdecaad4cbc 100644 (file)
@@ -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;
 }
index 178460a07bf43f4626d996e7891d0c683ff27f78..c73999ed3716c76e34de5b623a6c2668b3809bd7 100644 (file)
@@ -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 */
index b05622bda44880572121c26c09d3e8851c24d052..1e248644398022c43b59e94173a15235ef0d25f6 100644 (file)
@@ -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:
index f4af51c8df083765e2242c1f80d39810fb355733..0c08f8289a298091542117c1aa33f137d4e2e292 100644 (file)
@@ -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;
 
index da5c0252f3dc6892b79e10b27d78550f02b55dcc..aa9a21dd6546a6bc053a99566cbdadcc222afbfe 100644 (file)
@@ -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 */
index c156c0fe7c2f432cb7308f0187677407a01050b5..d7f5576bdd6bb7719f2255d749095f881e49d338 100644 (file)
@@ -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();
index f9b067014c311cb3c621774c4cc6c3b55d3de7c1..678aca290d2f283c614d5732b5af572795439719 100644 (file)
@@ -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);
index c08f4156fb73b2609a2bb53472d9e65463f30fb4..2a05f0f1178f665f87d5cd4f234e08dd711986d4 100644 (file)
@@ -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(
index 91e12760f12b503b6c203c5ee88e8b50698366aa..d3d45818d224531517935b4318aa328549c6e9da 100644 (file)
@@ -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);
index 7bf4713365368fcdb8623cb6cde06072930ba8c8..2cc1b76c5de277d0f3799c84dd552e696da46bc0 100644 (file)
@@ -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();
index 87a1319850fcf32afbd0caa8d18db75749b509e4..641aaed13ae2420d057c8632eb8160824ad9eca9 100644 (file)
@@ -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;
 }
 
index ab1b920ee599af796934fde3d7542b92384781c3..8811cf90ab6cfb0b21e320ff1d4f3b41de26ae06 100644 (file)
@@ -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)
This page took 0.131919 seconds and 4 git commands to generate.