cpp-common/bt2: make setters return `*this`
authorSimon Marchi <simon.marchi@efficios.com>
Thu, 29 Feb 2024 18:50:00 +0000 (13:50 -0500)
committerSimon Marchi <simon.marchi@efficios.com>
Tue, 26 Mar 2024 18:56:36 +0000 (14:56 -0400)
commit2a24eba8b45ab4bd62dfb2cd95f31e4c2a7a91a8
treef7ca1edfe36c1c7fc7e545cf442ba990027dab94
parent6133c94191474e358f8c0688c8f9d3f5cc323836
cpp-common/bt2: make setters return `*this`

Change setters (and other methods currently returning `void`) to return
`*this`.

This allows writing more compact code and avoid intermediate variables,
like:

    return graph->addComponent(
        *dummySinkCompCls, "the-sink",
        bt2::MapValue::create()->insert("key1", "val1").insert("key2", "val2"));

It doesn't always produce super readable code, but it's nice to have the
option.

In sub-classes of `BorrowedObject`, the methods return by value.
`ConstMessageArray::append` returns by reference.

Change-Id: I5af80c96b4c947dc217f4dff4b0bcb31885005e8
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11951
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
13 files changed:
src/cpp-common/bt2/clock-class.hpp
src/cpp-common/bt2/field-class.hpp
src/cpp-common/bt2/field.hpp
src/cpp-common/bt2/graph.hpp
src/cpp-common/bt2/integer-range-set.hpp
src/cpp-common/bt2/message-array.hpp
src/cpp-common/bt2/message-iterator.hpp
src/cpp-common/bt2/message.hpp
src/cpp-common/bt2/self-component-port.hpp
src/cpp-common/bt2/self-message-iterator-configuration.hpp
src/cpp-common/bt2/self-message-iterator.hpp
src/cpp-common/bt2/trace-ir.hpp
src/cpp-common/bt2/value.hpp
This page took 0.025138 seconds and 4 git commands to generate.