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)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Fri, 12 Apr 2019 21:26:17 +0000 (17:26 -0400)
commit8b1931eeee08e1b7d6d00635a30c98d6bab5dc19
tree2a7b330ffdb00f4e6b3d20dc7eaff8eb1a966426
parent5ce3aff3ca30b1cf491c9d68d1c8361754824db9
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.026047 seconds and 5 git commands to generate.