cpp-common/bt2: use raw value proxy for scalar value classes
This patch adds the `bt2::RawValueProxy` class of which an instance
contains a wrapper object `_mObj` and:
* Its `=` operator calls `_mObj.value()` to assign a value.
* Its raw value type operator returns what `_mObj.value()` returns.
Then, in scalar value wrapper classes of `value.hpp`:
* Remove the `=` operator which assigns a raw value.
* Add a value() method to assign a raw value.
* Add a `*` operator to return a raw value proxy containing this.
The goal of this patch is to avoid using the `=` operator on some value
object to both wrap another library object (pseudo copy assignment
operator) and assign a raw value. Now, to assign a raw value, you need
to "dereference" the wrapper object:
void f(const bt2::UnsignedIntegerValue val) {
*val = 23;
std::cout << *val << std::endl;
}
There's also `bt2::RawStringValueProxy` which adds the `=` operator to
`bt2::RawValueProxy` to assign a `const std::string&`.
`bt2::CommonStringValue` uses it.
Additionally, remove all the `=` operators to assign a raw value on
`bt2::CommonValue` and create a "master" raw value proxy class
(`CommonValueRawValueProxy`) to have all the `=` operators and raw value
type operators:
void f(const bt2::Value val) {
// We know it's a boolean value
*val = true;
}
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Ia8559de36baba3021169b3d097ec83b914407f63
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11362
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
This page took 0.026313 seconds and 4 git commands to generate.