lib: add structure FC member and variant FC option objects
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Wed, 10 Apr 2019 03:03:20 +0000 (23:03 -0400)
committerFrancis Deslauriers <francis.deslauriers@efficios.com>
Thu, 2 May 2019 20:50:15 +0000 (20:50 +0000)
commit1e6fd1d75be4ca9e6688f72e33658b58cd382af4
tree43d7925b10e422b4b21c4c109b4c6b037c65a417
parent22b7fdc661702dc38860510494c0f6c32850c7cb
lib: add structure FC member and variant FC option objects

This patch adds the structure field class member and variant field
class option objects to the field class API.

The purpose of those objects is to be able to operate at the structure
FC member or variant FC option level in the future, for example when we
add custom user attributes which you can attach to individual field
classes, but also to members/options themselves.

Behind the scenes, the `bt_field_class_structure_member *` and
`bt_field_class_structure_member *` types are just the existing
`struct bt_named_field_class *` type.

You cannot manually create a structure FC member or variant FC option
object: they are created when calling
bt_field_class_structure_append_member() or
bt_field_class_variant_append_option(). You can then borrow them with
bt_field_class_structure_borrow_member_by_index(),
bt_field_class_structure_borrow_member_by_name(),
bt_field_class_variant_borrow_option_by_index(),
bt_field_class_variant_borrow_option_by_name(), and their const
equivalents.

When you append a member to a structure FC or an option to a variant FC,
the function does not freeze the member/option itself, but only its
contained field class. The member/option object is frozen when the
container field class (structure/variant) is frozen itself. This means,
in the future, that you can borrow a structure FC member or a variant FC
option object and then modify it (set an optional property, for
example).

Structure FC member and variant FC option objects are unique (for the
moment): they are merely a proxy offering accessors to the properties of
a container field class's elements, like enumeration field class mapping
range objects.

The only drawback I can see is that you need three function calls to get
the name and borrow the field class of a structure FC member or variant
FC option instead of a single one, but we can reintroduce a single
accessor later if it's really an issue.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
include/babeltrace/trace-ir/field-class-const.h
include/babeltrace/trace-ir/field-class-internal.h
include/babeltrace/trace-ir/field-class.h
include/babeltrace/types.h
lib/trace-ir/field-class.c
plugins/lttng-utils/trace-ir-data-copy.c
plugins/lttng-utils/trace-ir-metadata-field-class-copy.c
plugins/lttng-utils/utils.c
plugins/text/pretty/print.c
This page took 0.026126 seconds and 4 git commands to generate.