Fix: src.ctf.lttng-live: emitting stream end msg with no stream
[babeltrace.git] / include / babeltrace2 / trace-ir / field-class-const.h
CommitLineData
3fd40f46
PP
1#ifndef BABELTRACE2_TRACE_IR_FIELD_CLASS_CONST_H
2#define BABELTRACE2_TRACE_IR_FIELD_CLASS_CONST_H
78cf9df6
PP
3
4/*
0dcb770f 5 * Copyright (c) 2010-2019 EfficiOS Inc. and Linux Foundation
78cf9df6 6 *
78cf9df6
PP
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.
78cf9df6
PP
24 */
25
9df34b44
PP
26#ifndef __BT_IN_BABELTRACE_H
27# error "Please include <babeltrace2/babeltrace.h> instead."
28#endif
29
78cf9df6
PP
30#include <stdint.h>
31#include <stddef.h>
32
e278f258
PP
33#include <babeltrace2/types.h>
34
78cf9df6
PP
35#ifdef __cplusplus
36extern "C" {
37#endif
38
ee78f405 39typedef enum bt_field_class_type {
5d2d8d18
PP
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,
ee78f405 79} bt_field_class_type;
78cf9df6 80
ee78f405 81typedef enum bt_field_class_integer_preferred_display_base {
a0c6c1d7
PP
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,
ee78f405 86} bt_field_class_integer_preferred_display_base;
78cf9df6 87
ee78f405 88extern bt_field_class_type bt_field_class_get_type(
8eee8ea2 89 const bt_field_class *field_class);
78cf9df6 90
5d2d8d18
PP
91static inline
92bt_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
af90138b
PP
98extern const bt_value *bt_field_class_borrow_user_attributes_const(
99 const bt_field_class *field_class);
100
6943da6a
PP
101extern uint64_t bt_field_class_bit_array_get_length(
102 const bt_field_class *field_class);
103
78cf9df6 104extern uint64_t bt_field_class_integer_get_field_value_range(
8eee8ea2 105 const bt_field_class *field_class);
78cf9df6 106
ee78f405 107extern bt_field_class_integer_preferred_display_base
78cf9df6 108bt_field_class_integer_get_preferred_display_base(
8eee8ea2 109 const bt_field_class *field_class);
78cf9df6 110
78cf9df6 111extern uint64_t bt_field_class_enumeration_get_mapping_count(
8eee8ea2 112 const bt_field_class *field_class);
78cf9df6 113
60bbfc7c
PP
114extern const bt_field_class_enumeration_unsigned_mapping *
115bt_field_class_enumeration_unsigned_borrow_mapping_by_index_const(
b6baf3bb
PP
116 const bt_field_class *field_class, uint64_t index);
117
60bbfc7c
PP
118extern const bt_field_class_enumeration_unsigned_mapping *
119bt_field_class_enumeration_unsigned_borrow_mapping_by_label_const(
02b61fe0
PP
120 const bt_field_class *field_class, const char *label);
121
60bbfc7c
PP
122extern const bt_field_class_enumeration_signed_mapping *
123bt_field_class_enumeration_signed_borrow_mapping_by_index_const(
b6baf3bb
PP
124 const bt_field_class *field_class, uint64_t index);
125
60bbfc7c
PP
126extern const bt_field_class_enumeration_signed_mapping *
127bt_field_class_enumeration_signed_borrow_mapping_by_label_const(
02b61fe0
PP
128 const bt_field_class *field_class, const char *label);
129
b6baf3bb
PP
130static inline
131const bt_field_class_enumeration_mapping *
60bbfc7c
PP
132bt_field_class_enumeration_unsigned_mapping_as_mapping_const(
133 const bt_field_class_enumeration_unsigned_mapping *mapping)
b6baf3bb 134{
8470daa9 135 return __BT_UPCAST_CONST(bt_field_class_enumeration_mapping, mapping);
b6baf3bb 136}
78cf9df6 137
b6baf3bb
PP
138static inline
139const bt_field_class_enumeration_mapping *
60bbfc7c
PP
140bt_field_class_enumeration_signed_mapping_as_mapping_const(
141 const bt_field_class_enumeration_signed_mapping *mapping)
b6baf3bb 142{
8470daa9 143 return __BT_UPCAST_CONST(bt_field_class_enumeration_mapping, mapping);
b6baf3bb 144}
78cf9df6 145
b6baf3bb
PP
146extern const char *bt_field_class_enumeration_mapping_get_label(
147 const bt_field_class_enumeration_mapping *mapping);
78cf9df6 148
02b61fe0 149extern const bt_integer_range_set_unsigned *
60bbfc7c
PP
150bt_field_class_enumeration_unsigned_mapping_borrow_ranges_const(
151 const bt_field_class_enumeration_unsigned_mapping *mapping);
78cf9df6 152
02b61fe0 153extern const bt_integer_range_set_signed *
60bbfc7c
PP
154bt_field_class_enumeration_signed_mapping_borrow_ranges_const(
155 const bt_field_class_enumeration_signed_mapping *mapping);
78cf9df6 156
1091bb60 157typedef enum bt_field_class_enumeration_get_mapping_labels_for_value_status {
fb25b9e3
PP
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,
1091bb60 160} bt_field_class_enumeration_get_mapping_labels_for_value_status;
fb25b9e3 161
1091bb60 162extern bt_field_class_enumeration_get_mapping_labels_for_value_status
60bbfc7c 163bt_field_class_enumeration_unsigned_get_mapping_labels_for_value(
8eee8ea2 164 const bt_field_class *field_class, uint64_t value,
78cf9df6
PP
165 bt_field_class_enumeration_mapping_label_array *label_array,
166 uint64_t *count);
167
1091bb60 168extern bt_field_class_enumeration_get_mapping_labels_for_value_status
60bbfc7c 169bt_field_class_enumeration_signed_get_mapping_labels_for_value(
8eee8ea2 170 const bt_field_class *field_class, int64_t value,
78cf9df6
PP
171 bt_field_class_enumeration_mapping_label_array *label_array,
172 uint64_t *count);
173
174extern uint64_t bt_field_class_structure_get_member_count(
8eee8ea2 175 const bt_field_class *field_class);
78cf9df6 176
e24f271a
PP
177extern const bt_field_class_structure_member *
178bt_field_class_structure_borrow_member_by_index_const(
179 const bt_field_class *field_class, uint64_t index);
78cf9df6 180
e24f271a
PP
181extern const bt_field_class_structure_member *
182bt_field_class_structure_borrow_member_by_name_const(
8eee8ea2 183 const bt_field_class *field_class, const char *name);
78cf9df6 184
e24f271a
PP
185extern const char *bt_field_class_structure_member_get_name(
186 const bt_field_class_structure_member *member);
187
188extern const bt_field_class *
189bt_field_class_structure_member_borrow_field_class_const(
190 const bt_field_class_structure_member *member);
191
af90138b
PP
192extern const bt_value *bt_field_class_structure_member_borrow_user_attributes_const(
193 const bt_field_class_structure_member *member);
194
8eee8ea2 195extern const bt_field_class *
78cf9df6 196bt_field_class_array_borrow_element_field_class_const(
8eee8ea2 197 const bt_field_class *field_class);
78cf9df6 198
60bbfc7c 199extern uint64_t bt_field_class_array_static_get_length(
8eee8ea2 200 const bt_field_class *field_class);
78cf9df6 201
8eee8ea2 202extern const bt_field_path *
b8ddb4f0 203bt_field_class_array_dynamic_with_length_field_borrow_length_field_path_const(
8eee8ea2 204 const bt_field_class *field_class);
78cf9df6 205
247fa9e3
PP
206extern const bt_field_class *
207bt_field_class_option_borrow_field_class_const(
208 const bt_field_class *field_class);
209
210extern const bt_field_path *
8bc207af 211bt_field_class_option_with_selector_field_borrow_selector_field_path_const(
467673c1
PP
212 const bt_field_class *field_class);
213
214extern bt_bool
8bc207af 215bt_field_class_option_with_selector_field_bool_selector_is_reversed(
467673c1
PP
216 const bt_field_class *field_class);
217
218extern const bt_integer_range_set_unsigned *
8bc207af 219bt_field_class_option_with_selector_field_integer_unsigned_borrow_selector_ranges_const(
467673c1
PP
220 const bt_field_class *field_class);
221
222extern const bt_integer_range_set_signed *
8bc207af 223bt_field_class_option_with_selector_field_integer_signed_borrow_selector_ranges_const(
247fa9e3
PP
224 const bt_field_class *field_class);
225
78cf9df6 226extern uint64_t bt_field_class_variant_get_option_count(
8eee8ea2 227 const bt_field_class *field_class);
78cf9df6 228
e24f271a
PP
229extern const bt_field_class_variant_option *
230bt_field_class_variant_borrow_option_by_index_const(
231 const bt_field_class *field_class, uint64_t index);
78cf9df6 232
e24f271a
PP
233extern const bt_field_class_variant_option *
234bt_field_class_variant_borrow_option_by_name_const(
235 const bt_field_class *field_class, const char *name);
236
8bc207af
PP
237extern const bt_field_class_variant_with_selector_field_integer_unsigned_option *
238bt_field_class_variant_with_selector_field_integer_unsigned_borrow_option_by_index_const(
02b61fe0
PP
239 const bt_field_class *field_class, uint64_t index);
240
8bc207af
PP
241extern const bt_field_class_variant_with_selector_field_integer_unsigned_option *
242bt_field_class_variant_with_selector_field_integer_unsigned_borrow_option_by_name_const(
02b61fe0
PP
243 const bt_field_class *field_class, const char *name);
244
8bc207af
PP
245extern const bt_field_class_variant_with_selector_field_integer_signed_option *
246bt_field_class_variant_with_selector_field_integer_signed_borrow_option_by_index_const(
02b61fe0
PP
247 const bt_field_class *field_class, uint64_t index);
248
8bc207af
PP
249extern const bt_field_class_variant_with_selector_field_integer_signed_option *
250bt_field_class_variant_with_selector_field_integer_signed_borrow_option_by_name_const(
02b61fe0
PP
251 const bt_field_class *field_class, const char *name);
252
e24f271a
PP
253extern const char *bt_field_class_variant_option_get_name(
254 const bt_field_class_variant_option *option);
255
256extern const bt_field_class *
257bt_field_class_variant_option_borrow_field_class_const(
258 const bt_field_class_variant_option *option);
78cf9df6 259
af90138b
PP
260extern const bt_value *bt_field_class_variant_option_borrow_user_attributes_const(
261 const bt_field_class_variant_option *option);
262
02b61fe0 263extern const bt_field_path *
8bc207af 264bt_field_class_variant_with_selector_field_borrow_selector_field_path_const(
02b61fe0
PP
265 const bt_field_class *field_class);
266
267extern const bt_integer_range_set_unsigned *
8bc207af
PP
268bt_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);
02b61fe0
PP
270
271static inline
272const bt_field_class_variant_option *
8bc207af
PP
273bt_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)
02b61fe0
PP
275{
276 return __BT_UPCAST_CONST(bt_field_class_variant_option, option);
277}
278
279extern const bt_integer_range_set_signed *
8bc207af
PP
280bt_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);
02b61fe0
PP
282
283static inline
284const bt_field_class_variant_option *
8bc207af
PP
285bt_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)
02b61fe0
PP
287{
288 return __BT_UPCAST_CONST(bt_field_class_variant_option, option);
289}
290
8eee8ea2 291extern void bt_field_class_get_ref(const bt_field_class *field_class);
8c6884d9 292
8eee8ea2 293extern void bt_field_class_put_ref(const bt_field_class *field_class);
8c6884d9
PP
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
78cf9df6
PP
309#ifdef __cplusplus
310}
311#endif
312
3fd40f46 313#endif /* BABELTRACE2_TRACE_IR_FIELD_CLASS_CONST_H */
This page took 0.060307 seconds and 4 git commands to generate.