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