cpp-common/bt2: add `bt2::BorrowedObjectProxy`
When bt2::Something::operator->() would need to return the address of
some `ObjT` instance, but none is available (because it only keeps the
libbabeltrace2 object pointer, not a built wrapper), then it can use
this new `bt2::BorrowedObjectProxy`.
This new class template accepts a library pointer at construction time,
constructs an internal `ObjT` instance, and its own operator->() method
returns the address of the latter.
Example:
class Something
{
// ...
public:
BorrowedObjectProxy<SomeObject> operator->() const noexcept
{
return BorrowedObjectProxy<SomeObject> {_mLibObjPtr};
}
private:
const bt_some_object *_mLibObjPtr;
};
Then, with a `Something` instance `something`:
something->methodOfSomeObject(...);
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I67d63591fb6593080a15e2ab6804a53bd2d2aba8
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11487
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
This page took 0.024992 seconds and 4 git commands to generate.