Commit | Line | Data |
---|---|---|
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> |
5cd6d0e5 PP |
34 | #include <stdint.h> |
35 | #include <glib.h> | |
36 | ||
bdb288b3 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 | ||
45c51519 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 | ||
bdb288b3 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 || \ | |
81b8fa44 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) | |
bdb288b3 PP |
72 | |
73 | #define _BT_ASSERT_PRE_FC_IS_ARRAY_FMT(_name) \ | |
74 | _name " is not an array field class: %![fc-]+F" | |
75 | ||
0aa006b7 PP |
76 | #define _BT_ASSERT_PRE_FC_IS_OPTION_COND(_fc) \ |
77 | (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITHOUT_SELECTOR || \ | |
78 | ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR || \ | |
79 | ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR || \ | |
80 | ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_SIGNED_INTEGER_SELECTOR) | |
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) \ | |
86 | (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR || \ | |
87 | ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR || \ | |
88 | ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_SIGNED_INTEGER_SELECTOR) | |
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) \ | |
94 | (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR || \ | |
95 | ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_SIGNED_INTEGER_SELECTOR) | |
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 | ||
45c51519 PP |
100 | #define _BT_ASSERT_PRE_FC_IS_VARIANT_COND(_fc) \ |
101 | (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_VARIANT_WITHOUT_SELECTOR || \ | |
fabfe034 PP |
102 | ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_INTEGER_SELECTOR || \ |
103 | ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_INTEGER_SELECTOR) | |
45c51519 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) \ | |
fabfe034 PP |
109 | (((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_INTEGER_SELECTOR || \ |
110 | ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_INTEGER_SELECTOR) | |
45c51519 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 | ||
bdb288b3 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 | ||
5cd6d0e5 | 121 | #define BT_ASSERT_PRE_FC_IS_INT(_fc, _name) \ |
bdb288b3 | 122 | BT_ASSERT_PRE(_BT_ASSERT_PRE_FC_IS_INT_COND(_fc), \ |
45c51519 | 123 | _BT_ASSERT_PRE_FC_IS_INT_FMT(_name), (_fc)) |
5cd6d0e5 PP |
124 | |
125 | #define BT_ASSERT_PRE_FC_IS_UNSIGNED_INT(_fc, _name) \ | |
bdb288b3 | 126 | BT_ASSERT_PRE(_BT_ASSERT_PRE_FC_IS_UNSIGNED_INT_COND(_fc), \ |
45c51519 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)) | |
5cd6d0e5 PP |
132 | |
133 | #define BT_ASSERT_PRE_FC_IS_ENUM(_fc, _name) \ | |
bdb288b3 | 134 | BT_ASSERT_PRE(_BT_ASSERT_PRE_FC_IS_ENUM_COND(_fc), \ |
45c51519 | 135 | _BT_ASSERT_PRE_FC_IS_ENUM_FMT(_name), (_fc)) |
5cd6d0e5 PP |
136 | |
137 | #define BT_ASSERT_PRE_FC_IS_ARRAY(_fc, _name) \ | |
bdb288b3 | 138 | BT_ASSERT_PRE(_BT_ASSERT_PRE_FC_IS_ARRAY_COND(_fc), \ |
45c51519 PP |
139 | _BT_ASSERT_PRE_FC_IS_ARRAY_FMT(_name), (_fc)) |
140 | ||
0aa006b7 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 | ||
45c51519 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)) | |
5cd6d0e5 | 160 | |
864cad70 | 161 | #define BT_ASSERT_PRE_FC_HAS_ID(_fc, _type, _name) \ |
bdb288b3 | 162 | BT_ASSERT_PRE(_BT_ASSERT_PRE_FC_HAS_ID_COND((_fc), (_type)), \ |
45c51519 PP |
163 | _BT_ASSERT_PRE_FC_HAS_ID_FMT(_name), \ |
164 | bt_common_field_class_type_string(_type), (_fc)) | |
5cd6d0e5 | 165 | |
bdb288b3 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), \ | |
45c51519 | 168 | _BT_ASSERT_PRE_FC_IS_INT_FMT(_name), (_fc)) |
bdb288b3 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), \ | |
45c51519 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)) | |
bdb288b3 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), \ | |
45c51519 | 180 | _BT_ASSERT_PRE_FC_IS_ENUM_FMT(_name), (_fc)) |
bdb288b3 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), \ | |
45c51519 PP |
184 | _BT_ASSERT_PRE_FC_IS_ARRAY_FMT(_name), (_fc)) |
185 | ||
0aa006b7 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 | ||
45c51519 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)) | |
bdb288b3 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)), \ | |
45c51519 PP |
208 | _BT_ASSERT_PRE_FC_HAS_ID_FMT(_name), \ |
209 | bt_common_field_class_type_string(_type), (_fc)) | |
bdb288b3 PP |
210 | |
211 | #define BT_ASSERT_PRE_DEV_FC_HOT(_fc, _name) \ | |
212 | BT_ASSERT_PRE_DEV_HOT((const struct bt_field_class *) (_fc), \ | |
5cd6d0e5 PP |
213 | (_name), ": %!+F", (_fc)) |
214 | ||
5cd6d0e5 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 | ||
223 | struct bt_field; | |
224 | struct bt_field_class; | |
225 | ||
226 | struct bt_field_class { | |
227 | struct bt_object base; | |
864cad70 | 228 | enum bt_field_class_type type; |
5cd6d0e5 PP |
229 | bool frozen; |
230 | ||
c6962c96 PP |
231 | /* Owned by this */ |
232 | struct bt_value *user_attributes; | |
233 | ||
5cd6d0e5 | 234 | /* |
bdb288b3 PP |
235 | * This flag indicates whether or not this field class is part |
236 | * of a trace class. | |
5cd6d0e5 | 237 | */ |
862ca4ed | 238 | bool part_of_trace_class; |
5cd6d0e5 PP |
239 | }; |
240 | ||
5cebbe7f PP |
241 | struct bt_field_class_bool { |
242 | struct bt_field_class common; | |
243 | }; | |
244 | ||
1094efa4 PP |
245 | struct bt_field_class_bit_array { |
246 | struct bt_field_class common; | |
247 | uint64_t length; | |
248 | }; | |
249 | ||
5cd6d0e5 PP |
250 | struct 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 | ||
5cd6d0e5 PP |
266 | struct bt_field_class_enumeration_mapping { |
267 | GString *label; | |
268 | ||
45c51519 PP |
269 | /* Owner by this */ |
270 | const struct bt_integer_range_set *range_set; | |
5cd6d0e5 PP |
271 | }; |
272 | ||
9c08c816 PP |
273 | struct bt_field_class_enumeration_unsigned_mapping; |
274 | struct bt_field_class_enumeration_signed_mapping; | |
8f3ccfbc | 275 | |
5cd6d0e5 PP |
276 | struct 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 | |
9c08c816 | 285 | * bt_field_class_enumeration_unsigned_get_mapping_labels_for_value() |
5cd6d0e5 | 286 | * and |
9c08c816 | 287 | * bt_field_class_enumeration_signed_get_mapping_labels_for_value(). |
5cd6d0e5 PP |
288 | * |
289 | * The actual strings are owned by the mappings above. | |
290 | */ | |
291 | GPtrArray *label_buf; | |
292 | }; | |
293 | ||
294 | struct bt_field_class_real { | |
295 | struct bt_field_class common; | |
5cd6d0e5 PP |
296 | }; |
297 | ||
298 | struct bt_field_class_string { | |
299 | struct bt_field_class common; | |
300 | }; | |
301 | ||
302 | /* A named field class is a (name, field class) pair */ | |
303 | struct bt_named_field_class { | |
304 | GString *name; | |
305 | ||
c6962c96 PP |
306 | /* Owned by this */ |
307 | struct bt_value *user_attributes; | |
308 | ||
5cd6d0e5 PP |
309 | /* Owned by this */ |
310 | struct bt_field_class *fc; | |
1e6fd1d7 PP |
311 | |
312 | bool frozen; | |
5cd6d0e5 PP |
313 | }; |
314 | ||
1e6fd1d7 PP |
315 | struct bt_field_class_structure_member; |
316 | struct bt_field_class_variant_option; | |
fabfe034 PP |
317 | struct bt_field_class_variant_with_selector_integer_unsigned_option; |
318 | struct bt_field_class_variant_with_selector_integer_signed_option; | |
1e6fd1d7 | 319 | |
5cd6d0e5 PP |
320 | struct 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 | |
45c51519 | 325 | * class objects contained in `named_fcs` below). |
5cd6d0e5 PP |
326 | */ |
327 | GHashTable *name_to_index; | |
328 | ||
45c51519 PP |
329 | /* Array of `struct bt_named_field_class *` */ |
330 | GPtrArray *named_fcs; | |
5cd6d0e5 PP |
331 | }; |
332 | ||
333 | struct bt_field_class_structure { | |
334 | struct bt_field_class_named_field_class_container common; | |
335 | }; | |
336 | ||
337 | struct bt_field_class_array { | |
338 | struct bt_field_class common; | |
339 | ||
340 | /* Owned by this */ | |
341 | struct bt_field_class *element_fc; | |
342 | }; | |
343 | ||
9c08c816 | 344 | struct bt_field_class_array_static { |
5cd6d0e5 PP |
345 | struct bt_field_class_array common; |
346 | uint64_t length; | |
347 | }; | |
348 | ||
9c08c816 | 349 | struct bt_field_class_array_dynamic { |
5cd6d0e5 PP |
350 | struct bt_field_class_array common; |
351 | ||
b38aea74 | 352 | /* Owned by this */ |
5cd6d0e5 PP |
353 | struct bt_field_class *length_fc; |
354 | ||
355 | /* Owned by this */ | |
356 | struct bt_field_path *length_field_path; | |
357 | }; | |
358 | ||
b38aea74 PP |
359 | struct bt_field_class_option { |
360 | struct bt_field_class common; | |
361 | ||
362 | /* Owned by this */ | |
363 | struct bt_field_class *content_fc; | |
0aa006b7 PP |
364 | }; |
365 | ||
366 | struct bt_field_class_option_with_selector { | |
367 | struct bt_field_class_option common; | |
b38aea74 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 | ||
0aa006b7 PP |
376 | struct bt_field_class_option_with_selector_bool { |
377 | struct bt_field_class_option_with_selector common; | |
378 | ||
379 | /* Owned by this */ | |
380 | bool sel_is_reversed; | |
381 | }; | |
382 | ||
383 | struct bt_field_class_option_with_selector_integer { | |
384 | struct bt_field_class_option_with_selector common; | |
385 | ||
386 | /* Owned by this */ | |
387 | const struct bt_integer_range_set *range_set; | |
388 | }; | |
389 | ||
45c51519 PP |
390 | /* Variant FC (with selector) option: named field class + range set */ |
391 | struct bt_field_class_variant_with_selector_option { | |
392 | struct bt_named_field_class common; | |
393 | ||
394 | /* Owned by this */ | |
395 | const struct bt_integer_range_set *range_set; | |
396 | }; | |
397 | ||
5cd6d0e5 | 398 | struct bt_field_class_variant { |
45c51519 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 | |
404 | * `struct bt_field_class_variant_with_selector_option *` | |
405 | * if it has. | |
406 | */ | |
5cd6d0e5 | 407 | struct bt_field_class_named_field_class_container common; |
45c51519 | 408 | }; |
5cd6d0e5 | 409 | |
45c51519 PP |
410 | struct bt_field_class_variant_with_selector { |
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; | |
5cd6d0e5 PP |
418 | |
419 | /* Owned by this */ | |
420 | struct bt_field_path *selector_field_path; | |
421 | }; | |
422 | ||
5cd6d0e5 | 423 | BT_HIDDEN |
40f4ba76 | 424 | void _bt_field_class_freeze(const struct bt_field_class *field_class); |
5cd6d0e5 PP |
425 | |
426 | #ifdef BT_DEV_MODE | |
427 | # define bt_field_class_freeze _bt_field_class_freeze | |
428 | #else | |
1d7f91d1 | 429 | # define bt_field_class_freeze(_fc) ((void) _fc) |
5cd6d0e5 PP |
430 | #endif |
431 | ||
1e6fd1d7 PP |
432 | BT_HIDDEN |
433 | void _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 | |
1d7f91d1 | 438 | # define bt_named_field_class_freeze(_named_fc) ((void) _named_fc) |
1e6fd1d7 PP |
439 | #endif |
440 | ||
5cd6d0e5 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 | */ | |
447 | BT_HIDDEN | |
bdb288b3 | 448 | void bt_field_class_make_part_of_trace_class( |
862ca4ed | 449 | const struct bt_field_class *field_class); |
5cd6d0e5 | 450 | |
5cd6d0e5 | 451 | #endif /* BABELTRACE_TRACE_IR_FIELD_CLASSES_INTERNAL_H */ |