bt2: add option field class and field support
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Tue, 13 Aug 2019 15:58:10 +0000 (11:58 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Thu, 15 Aug 2019 15:41:44 +0000 (11:41 -0400)
commitcec0261d56a42e810f56b39fcefbe33987c8aab8
tree50345061331e7f81107f5706ede4f70f665a3df3
parentc25f8e53dc25a23d21d3e54a171b4c2dee0bd7eb
bt2: add option field class and field support

This patch adds option field class and field support to the Python
bindings.

You can create an option field class with
_TraceClass.create_option_field_class(). This method requires the
optional field class and also accepts an optional selector field class
(just like the library's equivalent bt_field_class_option_create()
function).

An option field class only has the `field_class` (the optional field
class) and `selector_field_path` (can be `None`) properties.

An option field is similar to a variant field:

* You can use the `has_field` property to set whether or not the option
  field has an optional field.

* You can access the optional field with the `field` property, which
  returns `None` when the option field has no field.

* The __bool__() operator of an option field is the equivalent of the
  `has_field` property.

* You can use the `value` property (write only, like
  `_VariantField.value`) to assign a value to the optional field. This
  property also sets `has_field` to `True` so it's always safe to use.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I90aa9ef2dbcb7422ee25aaeb191a18fd9fa4998b
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1902
Tested-by: jenkins <jenkins@lttng.org>
src/bindings/python/bt2/bt2/__init__.py
src/bindings/python/bt2/bt2/field.py
src/bindings/python/bt2/bt2/field_class.py
src/bindings/python/bt2/bt2/field_path.py
src/bindings/python/bt2/bt2/trace_class.py
src/lib/trace-ir/resolve-field-path.c
tests/bindings/python/bt2/test_field.py
tests/bindings/python/bt2/test_field_class.py
tests/bindings/python/bt2/test_package.py
This page took 0.024947 seconds and 4 git commands to generate.