lib: remove unused includes
[babeltrace.git] / src / lib / trace-ir / field-class.h
... / ...
CommitLineData
1/*
2 * SPDX-License-Identifier: MIT
3 *
4 * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
5 * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 */
7
8#ifndef BABELTRACE_TRACE_IR_FIELD_CLASSES_INTERNAL_H
9#define BABELTRACE_TRACE_IR_FIELD_CLASSES_INTERNAL_H
10
11#include <babeltrace2/trace-ir/clock-class.h>
12#include <babeltrace2/trace-ir/field-class.h>
13#include "common/macros.h"
14#include "lib/object.h"
15#include <babeltrace2/types.h>
16#include <stdbool.h>
17#include <stdint.h>
18#include <glib.h>
19
20#define BT_FIELD_CLASS_ENUM_MAPPING_AT_INDEX(_fc, _index) \
21 (&bt_g_array_index(((struct bt_field_class_enumeration *) (_fc))->mappings, \
22 struct bt_field_class_enumeration_mapping, (_index)))
23
24#define BT_FIELD_CLASS_ENUM_MAPPING_RANGE_AT_INDEX(_mapping, _index) \
25 (&bt_g_array_index((_mapping)->ranges, \
26 struct bt_field_class_enumeration_mapping_range, (_index)))
27
28struct bt_field_class {
29 struct bt_object base;
30 enum bt_field_class_type type;
31 bool frozen;
32
33 /* Owned by this */
34 struct bt_value *user_attributes;
35
36 /*
37 * This flag indicates whether or not this field class is part
38 * of a trace class.
39 */
40 bool part_of_trace_class;
41};
42
43struct bt_field_class_bool {
44 struct bt_field_class common;
45};
46
47struct bt_field_class_bit_array {
48 struct bt_field_class common;
49 uint64_t length;
50};
51
52struct bt_field_class_integer {
53 struct bt_field_class common;
54
55 /*
56 * Value range of fields built from this integer field class:
57 * this is an equivalent integer size in bits. More formally,
58 * `range` is `n` in:
59 *
60 * Unsigned range: [0, 2^n - 1]
61 * Signed range: [-2^(n - 1), 2^(n - 1) - 1]
62 */
63 uint64_t range;
64
65 enum bt_field_class_integer_preferred_display_base base;
66};
67
68struct bt_field_class_enumeration_mapping {
69 GString *label;
70
71 /* Owner by this */
72 const struct bt_integer_range_set *range_set;
73};
74
75struct bt_field_class_enumeration_unsigned_mapping;
76struct bt_field_class_enumeration_signed_mapping;
77
78struct bt_field_class_enumeration {
79 struct bt_field_class_integer common;
80
81 /* Array of `struct bt_field_class_enumeration_mapping *` */
82 GArray *mappings;
83
84 /*
85 * This is an array of `const char *` which acts as a temporary
86 * (potentially growing) buffer for
87 * bt_field_class_enumeration_unsigned_get_mapping_labels_for_value()
88 * and
89 * bt_field_class_enumeration_signed_get_mapping_labels_for_value().
90 *
91 * The actual strings are owned by the mappings above.
92 */
93 GPtrArray *label_buf;
94};
95
96struct bt_field_class_real {
97 struct bt_field_class common;
98};
99
100struct bt_field_class_string {
101 struct bt_field_class common;
102};
103
104/* A named field class is a (name, field class) pair */
105struct bt_named_field_class {
106 GString *name;
107
108 /* Owned by this */
109 struct bt_value *user_attributes;
110
111 /* Owned by this */
112 struct bt_field_class *fc;
113
114 bool frozen;
115};
116
117struct bt_field_class_structure_member;
118struct bt_field_class_variant_option;
119struct bt_field_class_variant_with_selector_field_integer_unsigned_option;
120struct bt_field_class_variant_with_selector_field_integer_signed_option;
121
122struct bt_field_class_named_field_class_container {
123 struct bt_field_class common;
124
125 /*
126 * Key: `const char *`, not owned by this (owned by named field
127 * class objects contained in `named_fcs` below).
128 */
129 GHashTable *name_to_index;
130
131 /* Array of `struct bt_named_field_class *` */
132 GPtrArray *named_fcs;
133};
134
135struct bt_field_class_structure {
136 struct bt_field_class_named_field_class_container common;
137};
138
139struct bt_field_class_array {
140 struct bt_field_class common;
141
142 /* Owned by this */
143 struct bt_field_class *element_fc;
144};
145
146struct bt_field_class_array_static {
147 struct bt_field_class_array common;
148 uint64_t length;
149};
150
151struct bt_field_class_array_dynamic {
152 struct bt_field_class_array common;
153
154 /* Owned by this */
155 struct bt_field_class *length_fc;
156
157 /* Owned by this */
158 struct bt_field_path *length_field_path;
159};
160
161struct bt_field_class_option {
162 struct bt_field_class common;
163
164 /* Owned by this */
165 struct bt_field_class *content_fc;
166};
167
168struct bt_field_class_option_with_selector_field {
169 struct bt_field_class_option common;
170
171 /* Owned by this */
172 struct bt_field_class *selector_fc;
173
174 /* Owned by this */
175 struct bt_field_path *selector_field_path;
176};
177
178struct bt_field_class_option_with_selector_field_bool {
179 struct bt_field_class_option_with_selector_field common;
180
181 /* Owned by this */
182 bool sel_is_reversed;
183};
184
185struct bt_field_class_option_with_selector_field_integer {
186 struct bt_field_class_option_with_selector_field common;
187
188 /* Owned by this */
189 const struct bt_integer_range_set *range_set;
190};
191
192/* Variant FC (with selector) option: named field class + range set */
193struct bt_field_class_variant_with_selector_field_option {
194 struct bt_named_field_class common;
195
196 /* Owned by this */
197 const struct bt_integer_range_set *range_set;
198};
199
200struct bt_field_class_variant {
201 /*
202 * Depending on the variant field class type, the contained
203 * named field classes are of type
204 * `struct bt_named_field_class *` if the variant field class
205 * doesn't have a selector, or
206 * `struct bt_field_class_variant_with_selector_field_option *`
207 * if it has.
208 */
209 struct bt_field_class_named_field_class_container common;
210};
211
212struct bt_field_class_variant_with_selector_field {
213 struct bt_field_class_variant common;
214
215 /*
216 * Owned by this, but never dereferenced: only use to find it
217 * elsewhere.
218 */
219 const struct bt_field_class *selector_fc;
220
221 /* Owned by this */
222 struct bt_field_path *selector_field_path;
223};
224
225void _bt_field_class_freeze(const struct bt_field_class *field_class);
226
227#ifdef BT_DEV_MODE
228# define bt_field_class_freeze _bt_field_class_freeze
229#else
230# define bt_field_class_freeze(_fc) ((void) _fc)
231#endif
232
233void _bt_named_field_class_freeze(const struct bt_named_field_class *named_fc);
234
235#ifdef BT_DEV_MODE
236# define bt_named_field_class_freeze _bt_named_field_class_freeze
237#else
238# define bt_named_field_class_freeze(_named_fc) ((void) _named_fc)
239#endif
240
241/*
242 * This function recursively marks `field_class` and its children as
243 * being part of a trace. This is used to validate that all field classes
244 * are used at a single location within trace objects even if they are
245 * shared objects for other purposes.
246 */
247void bt_field_class_make_part_of_trace_class(
248 const struct bt_field_class *field_class);
249
250#endif /* BABELTRACE_TRACE_IR_FIELD_CLASSES_INTERNAL_H */
This page took 0.023005 seconds and 4 git commands to generate.