Fix: src.ctf.lttng-live: emitting stream end msg with no stream
[babeltrace.git] / include / babeltrace2 / trace-ir / field-class-const.h
1 #ifndef BABELTRACE2_TRACE_IR_FIELD_CLASS_CONST_H
2 #define BABELTRACE2_TRACE_IR_FIELD_CLASS_CONST_H
3
4 /*
5 * Copyright (c) 2010-2019 EfficiOS Inc. and Linux Foundation
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to deal
9 * in the Software without restriction, including without limitation the rights
10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 * copies of the Software, and to permit persons to whom the Software is
12 * furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included in
15 * all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 * SOFTWARE.
24 */
25
26 #ifndef __BT_IN_BABELTRACE_H
27 # error "Please include <babeltrace2/babeltrace.h> instead."
28 #endif
29
30 #include <stdint.h>
31 #include <stddef.h>
32
33 #include <babeltrace2/types.h>
34
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38
39 typedef enum bt_field_class_type {
40 BT_FIELD_CLASS_TYPE_BOOL = 1ULL << 0,
41 BT_FIELD_CLASS_TYPE_BIT_ARRAY = 1ULL << 1,
42 BT_FIELD_CLASS_TYPE_INTEGER = 1ULL << 2,
43 BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER = (1ULL << 3) | BT_FIELD_CLASS_TYPE_INTEGER,
44 BT_FIELD_CLASS_TYPE_SIGNED_INTEGER = (1ULL << 4) | BT_FIELD_CLASS_TYPE_INTEGER,
45 BT_FIELD_CLASS_TYPE_ENUMERATION = 1ULL << 5,
46 BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION = BT_FIELD_CLASS_TYPE_ENUMERATION | BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER,
47 BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION = BT_FIELD_CLASS_TYPE_ENUMERATION | BT_FIELD_CLASS_TYPE_SIGNED_INTEGER,
48 BT_FIELD_CLASS_TYPE_REAL = 1ULL << 6,
49 BT_FIELD_CLASS_TYPE_SINGLE_PRECISION_REAL = (1ULL << 7) | BT_FIELD_CLASS_TYPE_REAL,
50 BT_FIELD_CLASS_TYPE_DOUBLE_PRECISION_REAL = (1ULL << 8) | BT_FIELD_CLASS_TYPE_REAL,
51 BT_FIELD_CLASS_TYPE_STRING = 1ULL << 9,
52 BT_FIELD_CLASS_TYPE_STRUCTURE = 1ULL << 10,
53 BT_FIELD_CLASS_TYPE_ARRAY = 1ULL << 11,
54 BT_FIELD_CLASS_TYPE_STATIC_ARRAY = (1ULL << 12) | BT_FIELD_CLASS_TYPE_ARRAY,
55 BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY = (1ULL << 13) | BT_FIELD_CLASS_TYPE_ARRAY,
56 BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD = (1ULL << 14) | BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY,
57 BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD = (1ULL << 15) | BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY,
58 BT_FIELD_CLASS_TYPE_OPTION = 1ULL << 16,
59 BT_FIELD_CLASS_TYPE_OPTION_WITHOUT_SELECTOR_FIELD = (1ULL << 17) | BT_FIELD_CLASS_TYPE_OPTION,
60 BT_FIELD_CLASS_TYPE_OPTION_WITH_SELECTOR_FIELD = (1ULL << 18) | BT_FIELD_CLASS_TYPE_OPTION,
61 BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR_FIELD = (1ULL << 19) | BT_FIELD_CLASS_TYPE_OPTION_WITH_SELECTOR_FIELD,
62 BT_FIELD_CLASS_TYPE_OPTION_WITH_INTEGER_SELECTOR_FIELD = (1ULL << 20) | BT_FIELD_CLASS_TYPE_OPTION_WITH_SELECTOR_FIELD,
63 BT_FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD = (1ULL << 21) | BT_FIELD_CLASS_TYPE_OPTION_WITH_INTEGER_SELECTOR_FIELD,
64 BT_FIELD_CLASS_TYPE_OPTION_WITH_SIGNED_INTEGER_SELECTOR_FIELD = (1ULL << 22) | BT_FIELD_CLASS_TYPE_OPTION_WITH_INTEGER_SELECTOR_FIELD,
65 BT_FIELD_CLASS_TYPE_VARIANT = 1ULL << 23,
66 BT_FIELD_CLASS_TYPE_VARIANT_WITHOUT_SELECTOR_FIELD = (1ULL << 24) | BT_FIELD_CLASS_TYPE_VARIANT,
67 BT_FIELD_CLASS_TYPE_VARIANT_WITH_SELECTOR_FIELD = (1ULL << 25) | BT_FIELD_CLASS_TYPE_VARIANT,
68 BT_FIELD_CLASS_TYPE_VARIANT_WITH_INTEGER_SELECTOR_FIELD = (1ULL << 26) | BT_FIELD_CLASS_TYPE_VARIANT_WITH_SELECTOR_FIELD,
69 BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD = (1ULL << 27) | BT_FIELD_CLASS_TYPE_VARIANT_WITH_INTEGER_SELECTOR_FIELD,
70 BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_INTEGER_SELECTOR_FIELD = (1ULL << 28) | BT_FIELD_CLASS_TYPE_VARIANT_WITH_INTEGER_SELECTOR_FIELD,
71
72 /*
73 * Make sure the enumeration type is a 64-bit integer in case
74 * the project needs field class types in the future.
75 *
76 * This is not part of the API.
77 */
78 __BT_FIELD_CLASS_TYPE_BIG_VALUE = 1ULL << 62,
79 } bt_field_class_type;
80
81 typedef enum bt_field_class_integer_preferred_display_base {
82 BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_BINARY = 2,
83 BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_OCTAL = 8,
84 BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_DECIMAL = 10,
85 BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_HEXADECIMAL = 16,
86 } bt_field_class_integer_preferred_display_base;
87
88 extern bt_field_class_type bt_field_class_get_type(
89 const bt_field_class *field_class);
90
91 static inline
92 bt_bool bt_field_class_type_is(const bt_field_class_type type,
93 const bt_field_class_type type_to_check)
94 {
95 return (type & type_to_check) == type_to_check;
96 }
97
98 extern const bt_value *bt_field_class_borrow_user_attributes_const(
99 const bt_field_class *field_class);
100
101 extern uint64_t bt_field_class_bit_array_get_length(
102 const bt_field_class *field_class);
103
104 extern uint64_t bt_field_class_integer_get_field_value_range(
105 const bt_field_class *field_class);
106
107 extern bt_field_class_integer_preferred_display_base
108 bt_field_class_integer_get_preferred_display_base(
109 const bt_field_class *field_class);
110
111 extern uint64_t bt_field_class_enumeration_get_mapping_count(
112 const bt_field_class *field_class);
113
114 extern const bt_field_class_enumeration_unsigned_mapping *
115 bt_field_class_enumeration_unsigned_borrow_mapping_by_index_const(
116 const bt_field_class *field_class, uint64_t index);
117
118 extern const bt_field_class_enumeration_unsigned_mapping *
119 bt_field_class_enumeration_unsigned_borrow_mapping_by_label_const(
120 const bt_field_class *field_class, const char *label);
121
122 extern const bt_field_class_enumeration_signed_mapping *
123 bt_field_class_enumeration_signed_borrow_mapping_by_index_const(
124 const bt_field_class *field_class, uint64_t index);
125
126 extern const bt_field_class_enumeration_signed_mapping *
127 bt_field_class_enumeration_signed_borrow_mapping_by_label_const(
128 const bt_field_class *field_class, const char *label);
129
130 static inline
131 const bt_field_class_enumeration_mapping *
132 bt_field_class_enumeration_unsigned_mapping_as_mapping_const(
133 const bt_field_class_enumeration_unsigned_mapping *mapping)
134 {
135 return __BT_UPCAST_CONST(bt_field_class_enumeration_mapping, mapping);
136 }
137
138 static inline
139 const bt_field_class_enumeration_mapping *
140 bt_field_class_enumeration_signed_mapping_as_mapping_const(
141 const bt_field_class_enumeration_signed_mapping *mapping)
142 {
143 return __BT_UPCAST_CONST(bt_field_class_enumeration_mapping, mapping);
144 }
145
146 extern const char *bt_field_class_enumeration_mapping_get_label(
147 const bt_field_class_enumeration_mapping *mapping);
148
149 extern const bt_integer_range_set_unsigned *
150 bt_field_class_enumeration_unsigned_mapping_borrow_ranges_const(
151 const bt_field_class_enumeration_unsigned_mapping *mapping);
152
153 extern const bt_integer_range_set_signed *
154 bt_field_class_enumeration_signed_mapping_borrow_ranges_const(
155 const bt_field_class_enumeration_signed_mapping *mapping);
156
157 typedef enum bt_field_class_enumeration_get_mapping_labels_for_value_status {
158 BT_FIELD_CLASS_ENUMERATION_GET_MAPPING_LABELS_BY_VALUE_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR,
159 BT_FIELD_CLASS_ENUMERATION_GET_MAPPING_LABELS_BY_VALUE_STATUS_OK = __BT_FUNC_STATUS_OK,
160 } bt_field_class_enumeration_get_mapping_labels_for_value_status;
161
162 extern bt_field_class_enumeration_get_mapping_labels_for_value_status
163 bt_field_class_enumeration_unsigned_get_mapping_labels_for_value(
164 const bt_field_class *field_class, uint64_t value,
165 bt_field_class_enumeration_mapping_label_array *label_array,
166 uint64_t *count);
167
168 extern bt_field_class_enumeration_get_mapping_labels_for_value_status
169 bt_field_class_enumeration_signed_get_mapping_labels_for_value(
170 const bt_field_class *field_class, int64_t value,
171 bt_field_class_enumeration_mapping_label_array *label_array,
172 uint64_t *count);
173
174 extern uint64_t bt_field_class_structure_get_member_count(
175 const bt_field_class *field_class);
176
177 extern const bt_field_class_structure_member *
178 bt_field_class_structure_borrow_member_by_index_const(
179 const bt_field_class *field_class, uint64_t index);
180
181 extern const bt_field_class_structure_member *
182 bt_field_class_structure_borrow_member_by_name_const(
183 const bt_field_class *field_class, const char *name);
184
185 extern const char *bt_field_class_structure_member_get_name(
186 const bt_field_class_structure_member *member);
187
188 extern const bt_field_class *
189 bt_field_class_structure_member_borrow_field_class_const(
190 const bt_field_class_structure_member *member);
191
192 extern const bt_value *bt_field_class_structure_member_borrow_user_attributes_const(
193 const bt_field_class_structure_member *member);
194
195 extern const bt_field_class *
196 bt_field_class_array_borrow_element_field_class_const(
197 const bt_field_class *field_class);
198
199 extern uint64_t bt_field_class_array_static_get_length(
200 const bt_field_class *field_class);
201
202 extern const bt_field_path *
203 bt_field_class_array_dynamic_with_length_field_borrow_length_field_path_const(
204 const bt_field_class *field_class);
205
206 extern const bt_field_class *
207 bt_field_class_option_borrow_field_class_const(
208 const bt_field_class *field_class);
209
210 extern const bt_field_path *
211 bt_field_class_option_with_selector_field_borrow_selector_field_path_const(
212 const bt_field_class *field_class);
213
214 extern bt_bool
215 bt_field_class_option_with_selector_field_bool_selector_is_reversed(
216 const bt_field_class *field_class);
217
218 extern const bt_integer_range_set_unsigned *
219 bt_field_class_option_with_selector_field_integer_unsigned_borrow_selector_ranges_const(
220 const bt_field_class *field_class);
221
222 extern const bt_integer_range_set_signed *
223 bt_field_class_option_with_selector_field_integer_signed_borrow_selector_ranges_const(
224 const bt_field_class *field_class);
225
226 extern uint64_t bt_field_class_variant_get_option_count(
227 const bt_field_class *field_class);
228
229 extern const bt_field_class_variant_option *
230 bt_field_class_variant_borrow_option_by_index_const(
231 const bt_field_class *field_class, uint64_t index);
232
233 extern const bt_field_class_variant_option *
234 bt_field_class_variant_borrow_option_by_name_const(
235 const bt_field_class *field_class, const char *name);
236
237 extern const bt_field_class_variant_with_selector_field_integer_unsigned_option *
238 bt_field_class_variant_with_selector_field_integer_unsigned_borrow_option_by_index_const(
239 const bt_field_class *field_class, uint64_t index);
240
241 extern const bt_field_class_variant_with_selector_field_integer_unsigned_option *
242 bt_field_class_variant_with_selector_field_integer_unsigned_borrow_option_by_name_const(
243 const bt_field_class *field_class, const char *name);
244
245 extern const bt_field_class_variant_with_selector_field_integer_signed_option *
246 bt_field_class_variant_with_selector_field_integer_signed_borrow_option_by_index_const(
247 const bt_field_class *field_class, uint64_t index);
248
249 extern const bt_field_class_variant_with_selector_field_integer_signed_option *
250 bt_field_class_variant_with_selector_field_integer_signed_borrow_option_by_name_const(
251 const bt_field_class *field_class, const char *name);
252
253 extern const char *bt_field_class_variant_option_get_name(
254 const bt_field_class_variant_option *option);
255
256 extern const bt_field_class *
257 bt_field_class_variant_option_borrow_field_class_const(
258 const bt_field_class_variant_option *option);
259
260 extern const bt_value *bt_field_class_variant_option_borrow_user_attributes_const(
261 const bt_field_class_variant_option *option);
262
263 extern const bt_field_path *
264 bt_field_class_variant_with_selector_field_borrow_selector_field_path_const(
265 const bt_field_class *field_class);
266
267 extern const bt_integer_range_set_unsigned *
268 bt_field_class_variant_with_selector_field_integer_unsigned_option_borrow_ranges_const(
269 const bt_field_class_variant_with_selector_field_integer_unsigned_option *option);
270
271 static inline
272 const bt_field_class_variant_option *
273 bt_field_class_variant_with_selector_field_integer_unsigned_option_as_option_const(
274 const bt_field_class_variant_with_selector_field_integer_unsigned_option *option)
275 {
276 return __BT_UPCAST_CONST(bt_field_class_variant_option, option);
277 }
278
279 extern const bt_integer_range_set_signed *
280 bt_field_class_variant_with_selector_field_integer_signed_option_borrow_ranges_const(
281 const bt_field_class_variant_with_selector_field_integer_signed_option *option);
282
283 static inline
284 const bt_field_class_variant_option *
285 bt_field_class_variant_with_selector_field_integer_signed_option_as_option_const(
286 const bt_field_class_variant_with_selector_field_integer_signed_option *option)
287 {
288 return __BT_UPCAST_CONST(bt_field_class_variant_option, option);
289 }
290
291 extern void bt_field_class_get_ref(const bt_field_class *field_class);
292
293 extern void bt_field_class_put_ref(const bt_field_class *field_class);
294
295 #define BT_FIELD_CLASS_PUT_REF_AND_RESET(_var) \
296 do { \
297 bt_field_class_put_ref(_var); \
298 (_var) = NULL; \
299 } while (0)
300
301 #define BT_FIELD_CLASS_MOVE_REF(_var_dst, _var_src) \
302 do { \
303 bt_field_class_put_ref(_var_dst); \
304 (_var_dst) = (_var_src); \
305 (_var_src) = NULL; \
306 } while (0)
307
308
309 #ifdef __cplusplus
310 }
311 #endif
312
313 #endif /* BABELTRACE2_TRACE_IR_FIELD_CLASS_CONST_H */
This page took 0.040207 seconds and 4 git commands to generate.