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:
This page took 0.030515 seconds and 4 git commands to generate.