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