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