Add missing C++ interface for the libbabeltrace2 trace IR API
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Thu, 14 Jan 2021 20:07:52 +0000 (15:07 -0500)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Fri, 28 Jan 2022 16:22:26 +0000 (11:22 -0500)
commit74fc764df204365c04acdff600bc6268fde5984a
tree80caba60036fc39f049382e7f6041607082e32fc
parenta1e3187822e3320ce83e37a0e30bc68e176112d4
Add missing C++ interface for the libbabeltrace2 trace IR API

This patch adds C++ wrappers for the following Babeltrace 2 objects:

* Event
* Packet
* Stream
* Trace
* Event class
* Stream class
* Trace class

Those are the missing wrappers to complete trace IR API wrapping
within `src/cpp-common/bt2`.

I used a single file (`src/cpp-common/bt2/trace-ir.hpp`) to implement
those wrappers as there are many interdependencies between them. For
example, you can borrow the parent stream class S of an event class E
while you can also borrow E from S. This means some methods need to be
implemented after the full definitions of classes on which they depend.
Doing this in dedicated files while also making sure that you can
include any header in any order is not straightforward. With this patch,
simply include `cpp-common/bt2/trace-ir.hpp` to get the whole trace IR
C++ API.

Implicitly convert from a mutable object to a constant field class
with converting constructors and assignment operators.

Those new template classes follow the approach of other wrappers in
`src/cpp-common/bt2`.

Many of the new common classes become friends of
`bt2::CommonFieldClass`, `bt2::CommonValue`, and
`bt2::CommonIntegerRangeSet` to access their _libObjPtr() method.

The new creation methods are:

* Create a packet with bt2::Stream::createPacket().

* Create a stream with bt2::StreamClass::instantiate().

* Create a trace with bt2::TraceClass::instantiate().

* Create an event class with bt2::StreamClass::createEventClass().

* Create a stream class with bt2::TraceClass::createStreamClass().

* Create a field class with one of the
  bt2::TraceClass::create*FieldClass() methods.

Access the class of an event/stream/trace object with its cls() method.

As of this patch, you cannot create a trace class. This will be possible
when we add a self component wrapper.

This patch doesn't wrap the trace and trace class destruction listener
APIs.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I1f2977b0c5d5eba35b468a9748216f2201f205dd
Reviewed-on: https://review.lttng.org/c/babeltrace/+/4688
src/cpp-common/bt2/field-class.hpp
src/cpp-common/bt2/integer-range-set.hpp
src/cpp-common/bt2/trace-ir.hpp [new file with mode: 0644]
src/cpp-common/bt2/value.hpp
This page took 0.026664 seconds and 4 git commands to generate.