| 1 | /* |
| 2 | * SPDX-License-Identifier: MIT |
| 3 | * |
| 4 | * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com> |
| 5 | * Copyright 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com> |
| 6 | */ |
| 7 | |
| 8 | #ifndef BABELTRACE_LIB_TRACE_IR_TRACE_H |
| 9 | #define BABELTRACE_LIB_TRACE_IR_TRACE_H |
| 10 | |
| 11 | #include <babeltrace2/trace-ir/trace.h> |
| 12 | #include <babeltrace2/trace-ir/field-class.h> |
| 13 | #include <babeltrace2/trace-ir/field.h> |
| 14 | #include "lib/object.h" |
| 15 | #include <babeltrace2/value.h> |
| 16 | #include <babeltrace2/types.h> |
| 17 | #include <glib.h> |
| 18 | #include <stdbool.h> |
| 19 | #include <sys/types.h> |
| 20 | #include "common/uuid.h" |
| 21 | |
| 22 | #include "stream-class.h" |
| 23 | #include "trace-class.h" |
| 24 | |
| 25 | struct bt_trace { |
| 26 | struct bt_object base; |
| 27 | |
| 28 | /* Owned by this */ |
| 29 | struct bt_value *user_attributes; |
| 30 | |
| 31 | /* Owned by this */ |
| 32 | struct bt_trace_class *class; |
| 33 | |
| 34 | gchar *ns; |
| 35 | gchar *name; |
| 36 | |
| 37 | union { |
| 38 | /* Used for MIP == 0 */ |
| 39 | struct { |
| 40 | bt_uuid_t uuid; |
| 41 | |
| 42 | /* NULL or `uuid` above */ |
| 43 | bt_uuid value; |
| 44 | } uuid; |
| 45 | |
| 46 | /* Used for MIP >= 1 */ |
| 47 | gchar *uid; |
| 48 | } uid_or_uuid; |
| 49 | |
| 50 | struct bt_value *environment; |
| 51 | |
| 52 | /* Array of `struct bt_stream *` */ |
| 53 | GPtrArray *streams; |
| 54 | |
| 55 | /* |
| 56 | * Stream class (weak, owned by owned trace class) to number of |
| 57 | * instantiated streams, used to automatically assign stream IDs |
| 58 | * per stream class within this trace. |
| 59 | */ |
| 60 | GHashTable *stream_classes_stream_count; |
| 61 | |
| 62 | GArray *destruction_listeners; |
| 63 | bool frozen; |
| 64 | }; |
| 65 | |
| 66 | void _bt_trace_freeze(const struct bt_trace *trace); |
| 67 | |
| 68 | #ifdef BT_DEV_MODE |
| 69 | # define bt_trace_freeze _bt_trace_freeze |
| 70 | #else |
| 71 | # define bt_trace_freeze(_trace) |
| 72 | #endif |
| 73 | |
| 74 | void bt_trace_add_stream(struct bt_trace *trace, struct bt_stream *stream); |
| 75 | |
| 76 | uint64_t bt_trace_get_automatic_stream_id(const struct bt_trace *trace, |
| 77 | const struct bt_stream_class *stream_class); |
| 78 | |
| 79 | #endif /* BABELTRACE_LIB_TRACE_IR_TRACE_H */ |