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)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 3 May 2019 22:19:39 +0000 (18:19 -0400)
commite24f271a30477f1b6eef0232fe1e744f66d7da15
tree98b7d298608fc92b57a6e6c7b19a48ccfb23cb70
parent85aa6d8f2b2ed4ecd4e059eb5bdbf27c9c74920a
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.025207 seconds and 4 git commands to generate.