plugins/common/muxing: C++ify
authorSimon Marchi <simon.marchi@efficios.com>
Thu, 9 May 2024 21:11:49 +0000 (17:11 -0400)
committerSimon Marchi <simon.marchi@efficios.com>
Wed, 9 Oct 2024 02:56:57 +0000 (22:56 -0400)
commit7376c71d813475dad8cfd0c4cfd67e0dd69fa38a
treee16eac9ca40a955c6a2dd0f57a71e3c1ad50b679
parent949ec8f9461542c199ff720d0e8268c8dc0385cb
plugins/common/muxing: C++ify

Change the code to be more idiomatic C++.  I tried to keep the overall
logic identical.

The pattern where we look for the presence of both objects to compare
(when we compare things that are optional) comes back often, so factor
this out in a `_compareOptional` function.

Similarly, comparing strings that can be null comes back often, factor
this out in a `_compareStrings` function.

The existing code isn't consistent about how to order things, when
comparing one empty/null and one non-empty/non-null object.  Sometimes,
the empty object goes first, sometimes the non-empty object goes first.
By factoring out these two functions, the message ordering changes
slightly in some cases.  I found two test cases that needed to be updated:

 - flt.utils.muxer/succeed/diff-stream-class-no-name.expect
 - flt.utils.muxer/succeed/diff-stream-no-name.expect

It happens often that we want to compare and order scalar value.  Factor
this out in a `_compareLt` templated function.  The starship operator
from C++20 could probably replace this, in a distant future.

Otherwise the rest should be pretty straightforward it's the same logic
as before.

Change-Id: If372de51ff5584d17705a0aed5597cea750597fa
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12565
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
src/plugins/common/muxing/muxing.cpp
src/plugins/common/muxing/muxing.hpp
src/plugins/ctf/lttng-live/lttng-live.cpp
src/plugins/ctf/lttng-live/lttng-live.hpp
src/plugins/utils/muxer/msg-iter.cpp
src/plugins/utils/muxer/msg-iter.hpp
tests/data/plugins/flt.utils.muxer/succeed/diff-stream-class-no-name.expect
tests/data/plugins/flt.utils.muxer/succeed/diff-stream-no-name.expect
This page took 0.025178 seconds and 4 git commands to generate.