lib: introduce bt_message_iterator_class
authorSimon Marchi <simon.marchi@efficios.com>
Fri, 20 Dec 2019 22:20:55 +0000 (17:20 -0500)
committerSimon Marchi <simon.marchi@efficios.com>
Wed, 8 Jan 2020 21:49:55 +0000 (21:49 +0000)
commita3f0c7db90f4cfc81090a83a7442b7bc624d5789
tree0c55c725922ab75f57878bdb9b30d7790b8c3e56
parentfca28f7526e7f67c7314df3a113470e7bd109062
lib: introduce bt_message_iterator_class

Today, when defining a source or filter component class, the user sets
the message iterator methods directly on the class.  The `next`
methods is mandatory, so it is passed to
bt_component_class_{source,filter}_create, and the rest are optional, so
they are set by dedicated setters.  All these setters are therefore
duplicated for source and filter, for example:

  - bt_component_class_source_set_message_iterator_initialize_method
  - bt_component_class_filter_set_message_iterator_initialize_method

This patch factorizes everything related to message iterator methods and
introduces the concept of "message iterator class".  Instead of setting
the message iterator methods on a component class, the user will now
prepare a message iterator class, and pass a reference to this class
when creating a source or filter component class.  So, what used to be
this:

    src_cls = bt_component_class_source_create(my_iter_next_method);
    bt_component_class_source_set_message_iterator_initialize_method(my_iter_init_method);

would now become:

    iter_cls = bt_message_iterator_class_create(my_iter_next_method);
    bt_message_iterator_class_set_initialize_method(my_iter_init_method);
    src_cls = bt_component_class_source_create(iter_cls);

The message iterator class is a ref-counted object, and
bt_component_class_{source,filter}_create take their own references, so
a user would typically call bt_message_iterator_class_put_ref just after
that, as they would likely have no more use for the iterator class.  It
would be possible, in theory, to share an iterator class between
multiple component classes, but to this day no practical usage has been
found.  The search continues.

The macros to define a component class in a plugin remain the same,
where the message iterator methods are attached to the component class.
For example

    BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_INITIALIZE_METHOD_WITH_ID

In other words, the message iterator class concept is not exposed in
this area.

There is a small change on the message iterator `initialize` methods
impacting existing components: the `initialize` method of
`bt_message_iterator_class` accepts a `bt_self_component` instead of a
specialized `bt_self_component_source` or `bt_self_component_filter`.
If the `initialize` method requires the specialized version, the
user should pass it through the user data attached to the component.
This had to be changed in the debug info component, for example.

Change-Id: Idf8666d028eadae34589cc0460dc1da19ca75765
Signed-off-by: Simon Marchi <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
This page took 0.030111 seconds and 4 git commands to generate.