lib: add option field class and field types
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Mon, 12 Aug 2019 21:09:38 +0000 (17:09 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Thu, 15 Aug 2019 15:41:44 +0000 (11:41 -0400)
commitb38aea749d62a3453343099231e0af48c3fd1460
tree5562f1eafc2a3fc654921357ce98fe37d354cd53
parentaae30e61f85f6654c37da7a5da3b22fbbe2dbd5c
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>
include/babeltrace2/trace-ir/field-class-const.h
include/babeltrace2/trace-ir/field-class.h
include/babeltrace2/trace-ir/field-const.h
include/babeltrace2/trace-ir/field-path-const.h
include/babeltrace2/trace-ir/field.h
src/lib/lib-logging.c
src/lib/trace-ir/field-class.c
src/lib/trace-ir/field-class.h
src/lib/trace-ir/field.c
src/lib/trace-ir/field.h
src/lib/trace-ir/resolve-field-path.c
This page took 0.02534 seconds and 4 git commands to generate.