lib: add option field class and field types
This patch adds the option field class (FC) and field to the available
library types.
An option field can contain or not another field. It is very similar to
a variant field in that it's a choice between two things.
CTF 2 will very likely have such a type, so Babeltrace 2.0 will be
ready.
Like a variant FC, an option FC can have a selector which must be a
reachable boolean FC.
When you create an option with bt_field_class_option_create(), you pass
the optional FC, which becomes frozen on success.
You can borrow the optional FC of an option FC with
bt_field_class_option_borrow_field_class_const(). If the option FC has a
selector FC, you can borrow the computed selector field path with
bt_field_class_option_borrow_selector_field_path_const().
To set whether or not an option field contains a field, call
bt_field_option_set_has_field(). You must call this function even if the
option field contains no field (with `BT_FALSE`) because field objects
are pooled and not reset for each message in production mode (similar to
how you must initially call bt_field_string_clear() before you call
bt_field_string_append()). Once you have called
bt_field_option_set_has_field() with `BT_TRUE`, you can borrow the
optional field with bt_field_option_borrow_field() to fill it.
On the const side, you can borrow an option field's optional field with
bt_field_option_borrow_field_const(). This function returns `NULL` if
the option field does not contain a field.
This patch also adds the
`BT_FIELD_PATH_ITEM_TYPE_CURRENT_OPTION_CONTENT` field path item type.
Such a field path item means the current field of an option field.
This patch does not adapt existing plugins and the Python bindings to
use and wrap the new option FC and field; this work is reserved
for subsequent patches.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Ie76312a53affe8343dd058bd4c38cd9a6074c4d7
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1897
Tested-by: jenkins <jenkins@lttng.org>
This page took 0.025449 seconds and 4 git commands to generate.