lib: add user attributes property to metadata, stream, and trace objects
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Wed, 14 Aug 2019 03:21:46 +0000 (23:21 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 4 Sep 2019 15:58:21 +0000 (11:58 -0400)
commitaf90138b9544aabfb18354c251f8c8094099972d
treeb1830f6f9f19eda2903619e4395fd0d31ec9942e
parentd693f28a4615b8497b1abedf56be431631ce1465
lib: add user attributes property to metadata, stream, and trace objects

This patch adds an optional user attributes property to the following
trace IR objects:

* Clock class
* Event class
* Field class
* Structure field class member
* Variant field class option
* Stream class
* Stream
* Trace class
* Trace

A user attributes object is a map value object which adds custom
information to any of the objects above. It is entirely up to the user
to set user attributes. At creation time, all the objects above contain
an initial, empty map value.

CTF 2 will very likely have such user attributes for metadata objects,
so Babeltrace 2.0 will be ready.

For CTF 2, it is intended that user attributes will be namespaced to
reduce or eliminate clashes, for example using URLs or domain names,
which are also typically used for Java packages and XML namespaces:

    {
        "https://lttng.org": {
            "some-attribute": true
        }
    }

CTF 2 will only have user attributes for metadata objects, but I decided
to also have user attributes for long-lived data objects: streams and
traces.

This is not enforced in Babeltrace however: the user is free to put
whatever she needs into this map value.

There's a bt_*_set_user_attributes() function to set the user attributes
of an object and
bt_*_borrow_user_attributes()/bt_*_borrow_user_attributes_const()
functions to borrow them from the object.

This patch changes when structure field class members and variant field
class options are frozen:

Before this patch:
    When you append to a structure/variant field class, the
    member/option is frozen, including its field class.

With this patch:
    When you append to a structure/variant field class, the
    member/option itself is not frozen, but its field class is.

    The member/option is frozen when its containing structure/variant
    field class is frozen.

This makes it possible to append a member/option to a structure/variant
field class, borrow that member/option, and then set its user attributes
before the whole structure/variant field class is frozen.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Ibb12de23fb2c4d752b13381769d2ac1841eb5dc9
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1922
Tested-by: jenkins <jenkins@lttng.org>
28 files changed:
include/babeltrace2/trace-ir/clock-class-const.h
include/babeltrace2/trace-ir/clock-class.h
include/babeltrace2/trace-ir/event-class-const.h
include/babeltrace2/trace-ir/event-class.h
include/babeltrace2/trace-ir/field-class-const.h
include/babeltrace2/trace-ir/field-class.h
include/babeltrace2/trace-ir/stream-class-const.h
include/babeltrace2/trace-ir/stream-class.h
include/babeltrace2/trace-ir/stream-const.h
include/babeltrace2/trace-ir/stream.h
include/babeltrace2/trace-ir/trace-class-const.h
include/babeltrace2/trace-ir/trace-class.h
include/babeltrace2/trace-ir/trace-const.h
include/babeltrace2/trace-ir/trace.h
src/lib/trace-ir/clock-class.c
src/lib/trace-ir/clock-class.h
src/lib/trace-ir/event-class.c
src/lib/trace-ir/event-class.h
src/lib/trace-ir/field-class.c
src/lib/trace-ir/field-class.h
src/lib/trace-ir/stream-class.c
src/lib/trace-ir/stream-class.h
src/lib/trace-ir/stream.c
src/lib/trace-ir/stream.h
src/lib/trace-ir/trace-class.c
src/lib/trace-ir/trace-class.h
src/lib/trace-ir/trace.c
src/lib/trace-ir/trace.h
This page took 0.028907 seconds and 4 git commands to generate.