Commit | Line | Data |
---|---|---|
5cd6d0e5 | 1 | /* |
0235b0db MJ |
2 | * SPDX-License-Identifier: MIT |
3 | * | |
e2f7325d | 4 | * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com> |
5cd6d0e5 | 5 | * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com> |
5cd6d0e5 PP |
6 | */ |
7 | ||
0235b0db MJ |
8 | #ifndef BABELTRACE_TRACE_IR_FIELD_CLASSES_INTERNAL_H |
9 | #define BABELTRACE_TRACE_IR_FIELD_CLASSES_INTERNAL_H | |
10 | ||
578e048b | 11 | #include "lib/assert-pre.h" |
3fadfbc0 MJ |
12 | #include <babeltrace2/trace-ir/clock-class.h> |
13 | #include <babeltrace2/trace-ir/field-class.h> | |
91d81473 | 14 | #include "common/macros.h" |
45c51519 | 15 | #include "common/common.h" |
578e048b | 16 | #include "lib/object.h" |
3fadfbc0 | 17 | #include <babeltrace2/types.h> |
c4f23e30 | 18 | #include <stdbool.h> |
5cd6d0e5 PP |
19 | #include <stdint.h> |
20 | #include <glib.h> | |
21 | ||
bdb288b3 PP |
22 | #define _BT_ASSERT_PRE_FC_IS_INT_COND(_fc) \ |
23 | (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER || \ | |
24 | ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_SIGNED_INTEGER || \ | |
25 | ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION || \ | |
26 | ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION) | |
27 | ||
28 | #define _BT_ASSERT_PRE_FC_IS_INT_FMT(_name) \ | |
29 | _name " is not an integer field class: %![fc-]+F" | |
30 | ||
31 | #define _BT_ASSERT_PRE_FC_IS_UNSIGNED_INT_COND(_fc) \ | |
32 | (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER || \ | |
33 | ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION) | |
34 | ||
35 | #define _BT_ASSERT_PRE_FC_IS_UNSIGNED_INT_FMT(_name) \ | |
36 | _name " is not an unsigned integer field class: %![fc-]+F" | |
37 | ||
45c51519 PP |
38 | |
39 | #define _BT_ASSERT_PRE_FC_IS_SIGNED_INT_COND(_fc) \ | |
40 | (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_SIGNED_INTEGER || \ | |
41 | ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION) | |
42 | ||
43 | #define _BT_ASSERT_PRE_FC_IS_SIGNED_INT_FMT(_name) \ | |
44 | _name " is not a signed integer field class: %![fc-]+F" | |
45 | ||
bdb288b3 PP |
46 | #define _BT_ASSERT_PRE_FC_IS_ENUM_COND(_fc) \ |
47 | (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION || \ | |
48 | ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION) | |
49 | ||
50 | #define _BT_ASSERT_PRE_FC_IS_ENUM_FMT(_name) \ | |
51 | _name " is not an enumeration field class: %![fc-]+F" | |
52 | ||
53 | #define _BT_ASSERT_PRE_FC_IS_ARRAY_COND(_fc) \ | |
54 | (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_STATIC_ARRAY || \ | |
81b8fa44 PP |
55 | ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD || \ |
56 | ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD) | |
bdb288b3 PP |
57 | |
58 | #define _BT_ASSERT_PRE_FC_IS_ARRAY_FMT(_name) \ | |
59 | _name " is not an array field class: %![fc-]+F" | |
60 | ||
0aa006b7 | 61 | #define _BT_ASSERT_PRE_FC_IS_OPTION_COND(_fc) \ |
de821fe5 PP |
62 | (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITHOUT_SELECTOR_FIELD || \ |
63 | ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR_FIELD || \ | |
64 | ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD || \ | |
65 | ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_SIGNED_INTEGER_SELECTOR_FIELD) | |
0aa006b7 PP |
66 | |
67 | #define _BT_ASSERT_PRE_FC_IS_OPTION_FMT(_name) \ | |
68 | _name " is not an option field class: %![fc-]+F" | |
69 | ||
70 | #define _BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL_COND(_fc) \ | |
de821fe5 PP |
71 | (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR_FIELD || \ |
72 | ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD || \ | |
73 | ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_SIGNED_INTEGER_SELECTOR_FIELD) | |
0aa006b7 PP |
74 | |
75 | #define _BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL_FMT(_name) \ | |
76 | _name " is not an option field class with a selector: %![fc-]+F" | |
77 | ||
78 | #define _BT_ASSERT_PRE_FC_IS_OPTION_WITH_INT_SEL_COND(_fc) \ | |
de821fe5 PP |
79 | (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD || \ |
80 | ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_SIGNED_INTEGER_SELECTOR_FIELD) | |
0aa006b7 PP |
81 | |
82 | #define _BT_ASSERT_PRE_FC_IS_OPTION_WITH_INT_SEL_FMT(_name) \ | |
83 | _name " is not an option field class with an integer selector: %![fc-]+F" | |
84 | ||
45c51519 | 85 | #define _BT_ASSERT_PRE_FC_IS_VARIANT_COND(_fc) \ |
de821fe5 PP |
86 | (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_VARIANT_WITHOUT_SELECTOR_FIELD || \ |
87 | ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD || \ | |
88 | ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_INTEGER_SELECTOR_FIELD) | |
45c51519 PP |
89 | |
90 | #define _BT_ASSERT_PRE_FC_IS_VARIANT_FMT(_name) \ | |
91 | _name " is not a variant field class: %![fc-]+F" | |
92 | ||
93 | #define _BT_ASSERT_PRE_FC_IS_VARIANT_WITH_SEL_COND(_fc) \ | |
de821fe5 PP |
94 | (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD || \ |
95 | ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_INTEGER_SELECTOR_FIELD) | |
45c51519 PP |
96 | |
97 | #define _BT_ASSERT_PRE_FC_IS_VARIANT_WITH_SEL_FMT(_name) \ | |
98 | _name " is not a variant field class with a selector: %![fc-]+F" | |
99 | ||
bdb288b3 PP |
100 | #define _BT_ASSERT_PRE_FC_HAS_ID_COND(_fc, _type) \ |
101 | (((const struct bt_field_class *) (_fc))->type == (_type)) | |
102 | ||
103 | #define _BT_ASSERT_PRE_FC_HAS_ID_FMT(_name) \ | |
104 | _name " has the wrong type: expected-type=%s, %![fc-]+F" | |
105 | ||
5cd6d0e5 | 106 | #define BT_ASSERT_PRE_FC_IS_INT(_fc, _name) \ |
bdb288b3 | 107 | BT_ASSERT_PRE(_BT_ASSERT_PRE_FC_IS_INT_COND(_fc), \ |
45c51519 | 108 | _BT_ASSERT_PRE_FC_IS_INT_FMT(_name), (_fc)) |
5cd6d0e5 PP |
109 | |
110 | #define BT_ASSERT_PRE_FC_IS_UNSIGNED_INT(_fc, _name) \ | |
bdb288b3 | 111 | BT_ASSERT_PRE(_BT_ASSERT_PRE_FC_IS_UNSIGNED_INT_COND(_fc), \ |
45c51519 PP |
112 | _BT_ASSERT_PRE_FC_IS_UNSIGNED_INT_FMT(_name), (_fc)) |
113 | ||
114 | #define BT_ASSERT_PRE_FC_IS_SIGNED_INT(_fc, _name) \ | |
115 | BT_ASSERT_PRE(_BT_ASSERT_PRE_FC_IS_SIGNED_INT_COND(_fc), \ | |
116 | _BT_ASSERT_PRE_FC_IS_SIGNED_INT_FMT(_name), (_fc)) | |
5cd6d0e5 PP |
117 | |
118 | #define BT_ASSERT_PRE_FC_IS_ENUM(_fc, _name) \ | |
bdb288b3 | 119 | BT_ASSERT_PRE(_BT_ASSERT_PRE_FC_IS_ENUM_COND(_fc), \ |
45c51519 | 120 | _BT_ASSERT_PRE_FC_IS_ENUM_FMT(_name), (_fc)) |
5cd6d0e5 PP |
121 | |
122 | #define BT_ASSERT_PRE_FC_IS_ARRAY(_fc, _name) \ | |
bdb288b3 | 123 | BT_ASSERT_PRE(_BT_ASSERT_PRE_FC_IS_ARRAY_COND(_fc), \ |
45c51519 PP |
124 | _BT_ASSERT_PRE_FC_IS_ARRAY_FMT(_name), (_fc)) |
125 | ||
0aa006b7 PP |
126 | #define BT_ASSERT_PRE_FC_IS_OPTION(_fc, _name) \ |
127 | BT_ASSERT_PRE(_BT_ASSERT_PRE_FC_IS_OPTION_COND(_fc), \ | |
128 | _BT_ASSERT_PRE_FC_IS_OPTION_FMT(_name), (_fc)) | |
129 | ||
130 | #define BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL(_fc, _name) \ | |
131 | BT_ASSERT_PRE(_BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL_COND(_fc), \ | |
132 | _BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL_FMT(_name), (_fc)) | |
133 | ||
134 | #define BT_ASSERT_PRE_FC_IS_OPTION_WITH_INT_SEL(_fc, _name) \ | |
135 | BT_ASSERT_PRE(_BT_ASSERT_PRE_FC_IS_OPTION_WITH_INT_SEL_COND(_fc), \ | |
136 | _BT_ASSERT_PRE_FC_IS_OPTION_WITH_INT_SEL_FMT(_name), (_fc)) | |
137 | ||
45c51519 PP |
138 | #define BT_ASSERT_PRE_FC_IS_VARIANT(_fc, _name) \ |
139 | BT_ASSERT_PRE(_BT_ASSERT_PRE_FC_IS_VARIANT_COND(_fc), \ | |
140 | _BT_ASSERT_PRE_FC_IS_VARIANT_FMT(_name), (_fc)) | |
141 | ||
142 | #define BT_ASSERT_PRE_FC_IS_VARIANT_WITH_SEL(_fc, _name) \ | |
143 | BT_ASSERT_PRE(_BT_ASSERT_PRE_FC_IS_VARIANT_WITH_SEL_COND(_fc), \ | |
144 | _BT_ASSERT_PRE_FC_IS_VARIANT_WITH_SEL_FMT(_name), (_fc)) | |
5cd6d0e5 | 145 | |
864cad70 | 146 | #define BT_ASSERT_PRE_FC_HAS_ID(_fc, _type, _name) \ |
bdb288b3 | 147 | BT_ASSERT_PRE(_BT_ASSERT_PRE_FC_HAS_ID_COND((_fc), (_type)), \ |
45c51519 PP |
148 | _BT_ASSERT_PRE_FC_HAS_ID_FMT(_name), \ |
149 | bt_common_field_class_type_string(_type), (_fc)) | |
5cd6d0e5 | 150 | |
bdb288b3 PP |
151 | #define BT_ASSERT_PRE_DEV_FC_IS_INT(_fc, _name) \ |
152 | BT_ASSERT_PRE_DEV(_BT_ASSERT_PRE_FC_IS_INT_COND(_fc), \ | |
45c51519 | 153 | _BT_ASSERT_PRE_FC_IS_INT_FMT(_name), (_fc)) |
bdb288b3 PP |
154 | |
155 | #define BT_ASSERT_PRE_DEV_FC_IS_UNSIGNED_INT(_fc, _name) \ | |
156 | BT_ASSERT_PRE_DEV(_BT_ASSERT_PRE_FC_IS_UNSIGNED_INT_COND(_fc), \ | |
45c51519 PP |
157 | _BT_ASSERT_PRE_FC_IS_UNSIGNED_INT_FMT(_name), (_fc)) |
158 | ||
159 | #define BT_ASSERT_PRE_DEV_FC_IS_SIGNED_INT(_fc, _name) \ | |
160 | BT_ASSERT_PRE_DEV(_BT_ASSERT_PRE_FC_IS_SIGNED_INT_COND(_fc), \ | |
161 | _BT_ASSERT_PRE_FC_IS_SIGNED_INT_FMT(_name), (_fc)) | |
bdb288b3 PP |
162 | |
163 | #define BT_ASSERT_PRE_DEV_FC_IS_ENUM(_fc, _name) \ | |
164 | BT_ASSERT_PRE_DEV(_BT_ASSERT_PRE_FC_IS_ENUM_COND(_fc), \ | |
45c51519 | 165 | _BT_ASSERT_PRE_FC_IS_ENUM_FMT(_name), (_fc)) |
bdb288b3 PP |
166 | |
167 | #define BT_ASSERT_PRE_DEV_FC_IS_ARRAY(_fc, _name) \ | |
168 | BT_ASSERT_PRE_DEV(_BT_ASSERT_PRE_FC_IS_ARRAY_COND(_fc), \ | |
45c51519 PP |
169 | _BT_ASSERT_PRE_FC_IS_ARRAY_FMT(_name), (_fc)) |
170 | ||
0aa006b7 PP |
171 | #define BT_ASSERT_PRE_DEV_FC_IS_OPTION(_fc, _name) \ |
172 | BT_ASSERT_PRE_DEV(_BT_ASSERT_PRE_FC_IS_OPTION_COND(_fc), \ | |
173 | _BT_ASSERT_PRE_FC_IS_OPTION_FMT(_name), (_fc)) | |
174 | ||
175 | #define BT_ASSERT_PRE_DEV_FC_IS_OPTION_WITH_SEL(_fc, _name) \ | |
176 | BT_ASSERT_PRE_DEV(_BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL_COND(_fc), \ | |
177 | _BT_ASSERT_PRE_FC_IS_OPTION_WITH_SEL_FMT(_name), (_fc)) | |
178 | ||
179 | #define BT_ASSERT_PRE_DEV_FC_IS_OPTION_WITH_INT_SEL(_fc, _name) \ | |
180 | BT_ASSERT_PRE_DEV(_BT_ASSERT_PRE_FC_IS_OPTION_WITH_INT_SEL_COND(_fc), \ | |
181 | _BT_ASSERT_PRE_FC_IS_OPTION_WITH_INT_SEL_FMT(_name), (_fc)) | |
182 | ||
45c51519 PP |
183 | #define BT_ASSERT_PRE_DEV_FC_IS_VARIANT(_fc, _name) \ |
184 | BT_ASSERT_PRE_DEV(_BT_ASSERT_PRE_FC_IS_VARIANT_COND(_fc), \ | |
185 | _BT_ASSERT_PRE_FC_IS_VARIANT_FMT(_name), (_fc)) | |
186 | ||
187 | #define BT_ASSERT_PRE_DEV_FC_IS_VARIANT_WITH_SEL(_fc, _name) \ | |
188 | BT_ASSERT_PRE_DEV(_BT_ASSERT_PRE_FC_IS_VARIANT_WITH_SEL_COND(_fc), \ | |
189 | _BT_ASSERT_PRE_FC_IS_VARIANT_WITH_SEL_FMT(_name), (_fc)) | |
bdb288b3 PP |
190 | |
191 | #define BT_ASSERT_PRE_DEV_FC_HAS_ID(_fc, _type, _name) \ | |
192 | BT_ASSERT_PRE_DEV(_BT_ASSERT_PRE_FC_HAS_ID_COND((_fc), (_type)), \ | |
45c51519 PP |
193 | _BT_ASSERT_PRE_FC_HAS_ID_FMT(_name), \ |
194 | bt_common_field_class_type_string(_type), (_fc)) | |
bdb288b3 PP |
195 | |
196 | #define BT_ASSERT_PRE_DEV_FC_HOT(_fc, _name) \ | |
197 | BT_ASSERT_PRE_DEV_HOT((const struct bt_field_class *) (_fc), \ | |
5cd6d0e5 PP |
198 | (_name), ": %!+F", (_fc)) |
199 | ||
5cd6d0e5 PP |
200 | #define BT_FIELD_CLASS_ENUM_MAPPING_AT_INDEX(_fc, _index) \ |
201 | (&g_array_index(((struct bt_field_class_enumeration *) (_fc))->mappings, \ | |
202 | struct bt_field_class_enumeration_mapping, (_index))) | |
203 | ||
204 | #define BT_FIELD_CLASS_ENUM_MAPPING_RANGE_AT_INDEX(_mapping, _index) \ | |
205 | (&g_array_index((_mapping)->ranges, \ | |
206 | struct bt_field_class_enumeration_mapping_range, (_index))) | |
207 | ||
208 | struct bt_field; | |
209 | struct bt_field_class; | |
210 | ||
211 | struct bt_field_class { | |
212 | struct bt_object base; | |
864cad70 | 213 | enum bt_field_class_type type; |
5cd6d0e5 PP |
214 | bool frozen; |
215 | ||
c6962c96 PP |
216 | /* Owned by this */ |
217 | struct bt_value *user_attributes; | |
218 | ||
5cd6d0e5 | 219 | /* |
bdb288b3 PP |
220 | * This flag indicates whether or not this field class is part |
221 | * of a trace class. | |
5cd6d0e5 | 222 | */ |
862ca4ed | 223 | bool part_of_trace_class; |
5cd6d0e5 PP |
224 | }; |
225 | ||
5cebbe7f PP |
226 | struct bt_field_class_bool { |
227 | struct bt_field_class common; | |
228 | }; | |
229 | ||
1094efa4 PP |
230 | struct bt_field_class_bit_array { |
231 | struct bt_field_class common; | |
232 | uint64_t length; | |
233 | }; | |
234 | ||
5cd6d0e5 PP |
235 | struct bt_field_class_integer { |
236 | struct bt_field_class common; | |
237 | ||
238 | /* | |
239 | * Value range of fields built from this integer field class: | |
240 | * this is an equivalent integer size in bits. More formally, | |
241 | * `range` is `n` in: | |
242 | * | |
243 | * Unsigned range: [0, 2^n - 1] | |
244 | * Signed range: [-2^(n - 1), 2^(n - 1) - 1] | |
245 | */ | |
246 | uint64_t range; | |
247 | ||
248 | enum bt_field_class_integer_preferred_display_base base; | |
249 | }; | |
250 | ||
5cd6d0e5 PP |
251 | struct bt_field_class_enumeration_mapping { |
252 | GString *label; | |
253 | ||
45c51519 PP |
254 | /* Owner by this */ |
255 | const struct bt_integer_range_set *range_set; | |
5cd6d0e5 PP |
256 | }; |
257 | ||
9c08c816 PP |
258 | struct bt_field_class_enumeration_unsigned_mapping; |
259 | struct bt_field_class_enumeration_signed_mapping; | |
8f3ccfbc | 260 | |
5cd6d0e5 PP |
261 | struct bt_field_class_enumeration { |
262 | struct bt_field_class_integer common; | |
263 | ||
264 | /* Array of `struct bt_field_class_enumeration_mapping *` */ | |
265 | GArray *mappings; | |
266 | ||
267 | /* | |
268 | * This is an array of `const char *` which acts as a temporary | |
269 | * (potentially growing) buffer for | |
9c08c816 | 270 | * bt_field_class_enumeration_unsigned_get_mapping_labels_for_value() |
5cd6d0e5 | 271 | * and |
9c08c816 | 272 | * bt_field_class_enumeration_signed_get_mapping_labels_for_value(). |
5cd6d0e5 PP |
273 | * |
274 | * The actual strings are owned by the mappings above. | |
275 | */ | |
276 | GPtrArray *label_buf; | |
277 | }; | |
278 | ||
279 | struct bt_field_class_real { | |
280 | struct bt_field_class common; | |
5cd6d0e5 PP |
281 | }; |
282 | ||
283 | struct bt_field_class_string { | |
284 | struct bt_field_class common; | |
285 | }; | |
286 | ||
287 | /* A named field class is a (name, field class) pair */ | |
288 | struct bt_named_field_class { | |
289 | GString *name; | |
290 | ||
c6962c96 PP |
291 | /* Owned by this */ |
292 | struct bt_value *user_attributes; | |
293 | ||
5cd6d0e5 PP |
294 | /* Owned by this */ |
295 | struct bt_field_class *fc; | |
1e6fd1d7 PP |
296 | |
297 | bool frozen; | |
5cd6d0e5 PP |
298 | }; |
299 | ||
1e6fd1d7 PP |
300 | struct bt_field_class_structure_member; |
301 | struct bt_field_class_variant_option; | |
de821fe5 PP |
302 | struct bt_field_class_variant_with_selector_field_integer_unsigned_option; |
303 | struct bt_field_class_variant_with_selector_field_integer_signed_option; | |
1e6fd1d7 | 304 | |
5cd6d0e5 PP |
305 | struct bt_field_class_named_field_class_container { |
306 | struct bt_field_class common; | |
307 | ||
308 | /* | |
309 | * Key: `const char *`, not owned by this (owned by named field | |
45c51519 | 310 | * class objects contained in `named_fcs` below). |
5cd6d0e5 PP |
311 | */ |
312 | GHashTable *name_to_index; | |
313 | ||
45c51519 PP |
314 | /* Array of `struct bt_named_field_class *` */ |
315 | GPtrArray *named_fcs; | |
5cd6d0e5 PP |
316 | }; |
317 | ||
318 | struct bt_field_class_structure { | |
319 | struct bt_field_class_named_field_class_container common; | |
320 | }; | |
321 | ||
322 | struct bt_field_class_array { | |
323 | struct bt_field_class common; | |
324 | ||
325 | /* Owned by this */ | |
326 | struct bt_field_class *element_fc; | |
327 | }; | |
328 | ||
9c08c816 | 329 | struct bt_field_class_array_static { |
5cd6d0e5 PP |
330 | struct bt_field_class_array common; |
331 | uint64_t length; | |
332 | }; | |
333 | ||
9c08c816 | 334 | struct bt_field_class_array_dynamic { |
5cd6d0e5 PP |
335 | struct bt_field_class_array common; |
336 | ||
b38aea74 | 337 | /* Owned by this */ |
5cd6d0e5 PP |
338 | struct bt_field_class *length_fc; |
339 | ||
340 | /* Owned by this */ | |
341 | struct bt_field_path *length_field_path; | |
342 | }; | |
343 | ||
b38aea74 PP |
344 | struct bt_field_class_option { |
345 | struct bt_field_class common; | |
346 | ||
347 | /* Owned by this */ | |
348 | struct bt_field_class *content_fc; | |
0aa006b7 PP |
349 | }; |
350 | ||
de821fe5 | 351 | struct bt_field_class_option_with_selector_field { |
0aa006b7 | 352 | struct bt_field_class_option common; |
b38aea74 PP |
353 | |
354 | /* Owned by this */ | |
355 | struct bt_field_class *selector_fc; | |
356 | ||
357 | /* Owned by this */ | |
358 | struct bt_field_path *selector_field_path; | |
359 | }; | |
360 | ||
de821fe5 PP |
361 | struct bt_field_class_option_with_selector_field_bool { |
362 | struct bt_field_class_option_with_selector_field common; | |
0aa006b7 PP |
363 | |
364 | /* Owned by this */ | |
365 | bool sel_is_reversed; | |
366 | }; | |
367 | ||
de821fe5 PP |
368 | struct bt_field_class_option_with_selector_field_integer { |
369 | struct bt_field_class_option_with_selector_field common; | |
0aa006b7 PP |
370 | |
371 | /* Owned by this */ | |
372 | const struct bt_integer_range_set *range_set; | |
373 | }; | |
374 | ||
45c51519 | 375 | /* Variant FC (with selector) option: named field class + range set */ |
de821fe5 | 376 | struct bt_field_class_variant_with_selector_field_option { |
45c51519 PP |
377 | struct bt_named_field_class common; |
378 | ||
379 | /* Owned by this */ | |
380 | const struct bt_integer_range_set *range_set; | |
381 | }; | |
382 | ||
5cd6d0e5 | 383 | struct bt_field_class_variant { |
45c51519 PP |
384 | /* |
385 | * Depending on the variant field class type, the contained | |
386 | * named field classes are of type | |
387 | * `struct bt_named_field_class *` if the variant field class | |
388 | * doesn't have a selector, or | |
de821fe5 | 389 | * `struct bt_field_class_variant_with_selector_field_option *` |
45c51519 PP |
390 | * if it has. |
391 | */ | |
5cd6d0e5 | 392 | struct bt_field_class_named_field_class_container common; |
45c51519 | 393 | }; |
5cd6d0e5 | 394 | |
de821fe5 | 395 | struct bt_field_class_variant_with_selector_field { |
45c51519 PP |
396 | struct bt_field_class_variant common; |
397 | ||
398 | /* | |
399 | * Owned by this, but never dereferenced: only use to find it | |
400 | * elsewhere. | |
401 | */ | |
402 | const struct bt_field_class *selector_fc; | |
5cd6d0e5 PP |
403 | |
404 | /* Owned by this */ | |
405 | struct bt_field_path *selector_field_path; | |
406 | }; | |
407 | ||
5cd6d0e5 | 408 | BT_HIDDEN |
40f4ba76 | 409 | void _bt_field_class_freeze(const struct bt_field_class *field_class); |
5cd6d0e5 PP |
410 | |
411 | #ifdef BT_DEV_MODE | |
412 | # define bt_field_class_freeze _bt_field_class_freeze | |
413 | #else | |
1d7f91d1 | 414 | # define bt_field_class_freeze(_fc) ((void) _fc) |
5cd6d0e5 PP |
415 | #endif |
416 | ||
1e6fd1d7 PP |
417 | BT_HIDDEN |
418 | void _bt_named_field_class_freeze(const struct bt_named_field_class *named_fc); | |
419 | ||
420 | #ifdef BT_DEV_MODE | |
421 | # define bt_named_field_class_freeze _bt_named_field_class_freeze | |
422 | #else | |
1d7f91d1 | 423 | # define bt_named_field_class_freeze(_named_fc) ((void) _named_fc) |
1e6fd1d7 PP |
424 | #endif |
425 | ||
5cd6d0e5 PP |
426 | /* |
427 | * This function recursively marks `field_class` and its children as | |
428 | * being part of a trace. This is used to validate that all field classes | |
429 | * are used at a single location within trace objects even if they are | |
430 | * shared objects for other purposes. | |
431 | */ | |
432 | BT_HIDDEN | |
bdb288b3 | 433 | void bt_field_class_make_part_of_trace_class( |
862ca4ed | 434 | const struct bt_field_class *field_class); |
5cd6d0e5 | 435 | |
5cd6d0e5 | 436 | #endif /* BABELTRACE_TRACE_IR_FIELD_CLASSES_INTERNAL_H */ |