1 #ifndef BABELTRACE_TRACE_IR_FIELD_CLASSES_H
2 #define BABELTRACE_TRACE_IR_FIELD_CLASSES_H
5 * BabelTrace - Trace IR: Event field classes
7 * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
9 * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
11 * Permission is hereby granted, free of charge, to any person obtaining a copy
12 * of this software and associated documentation files (the "Software"), to deal
13 * in the Software without restriction, including without limitation the rights
14 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 * copies of the Software, and to permit persons to whom the Software is
16 * furnished to do so, subject to the following conditions:
18 * The above copyright notice and this permission notice shall be included in
19 * all copies or substantial portions of the Software.
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29 * The Common Trace Format (CTF) Specification is available at
30 * http://www.efficios.com/ctf
33 /* For bt_object_get_ref() */
34 #include <babeltrace/object.h>
37 #include <babeltrace/types.h>
46 struct bt_field_class
;
48 struct bt_field_class_signed_enumeration_mapping_ranges
;
49 struct bt_field_class_unsigned_enumeration_mapping_ranges
;
51 typedef const char * const *bt_field_class_enumeration_mapping_label_array
;
53 enum bt_field_class_type
{
54 BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER
,
55 BT_FIELD_CLASS_TYPE_SIGNED_INTEGER
,
56 BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION
,
57 BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION
,
58 BT_FIELD_CLASS_TYPE_REAL
,
59 BT_FIELD_CLASS_TYPE_STRING
,
60 BT_FIELD_CLASS_TYPE_STRUCTURE
,
61 BT_FIELD_CLASS_TYPE_STATIC_ARRAY
,
62 BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY
,
63 BT_FIELD_CLASS_TYPE_VARIANT
,
66 enum bt_field_class_integer_preferred_display_base
{
67 BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_BINARY
,
68 BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_OCTAL
,
69 BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_DECIMAL
,
70 BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_HEXADECIMAL
,
73 extern enum bt_field_class_type
bt_field_class_get_type(
74 struct bt_field_class
*field_class
);
76 extern struct bt_field_class
*bt_field_class_unsigned_integer_create(void);
78 extern struct bt_field_class
*bt_field_class_signed_integer_create(void);
80 extern uint64_t bt_field_class_integer_get_field_value_range(
81 struct bt_field_class
*field_class
);
83 extern int bt_field_class_integer_set_field_value_range(
84 struct bt_field_class
*field_class
, uint64_t size
);
86 extern enum bt_field_class_integer_preferred_display_base
87 bt_field_class_integer_get_preferred_display_base(
88 struct bt_field_class
*field_class
);
90 extern int bt_field_class_integer_set_preferred_display_base(
91 struct bt_field_class
*field_class
,
92 enum bt_field_class_integer_preferred_display_base base
);
94 extern struct bt_field_class
*bt_field_class_real_create(void);
96 extern bt_bool
bt_field_class_real_is_single_precision(
97 struct bt_field_class
*field_class
);
99 extern int bt_field_class_real_set_is_single_precision(
100 struct bt_field_class
*field_class
,
101 bt_bool is_single_precision
);
103 extern struct bt_field_class
*bt_field_class_unsigned_enumeration_create(void);
105 extern struct bt_field_class
*bt_field_class_signed_enumeration_create(void);
107 extern uint64_t bt_field_class_enumeration_get_mapping_count(
108 struct bt_field_class
*field_class
);
110 extern void bt_field_class_unsigned_enumeration_borrow_mapping_by_index(
111 struct bt_field_class
*field_class
, uint64_t index
,
113 struct bt_field_class_unsigned_enumeration_mapping_ranges
**ranges
);
115 extern void bt_field_class_signed_enumeration_borrow_mapping_by_index(
116 struct bt_field_class
*field_class
, uint64_t index
,
118 struct bt_field_class_signed_enumeration_mapping_ranges
**ranges
);
120 extern uint64_t bt_field_class_unsigned_enumeration_mapping_ranges_get_range_count(
121 struct bt_field_class_unsigned_enumeration_mapping_ranges
*ranges
);
123 extern uint64_t bt_field_class_signed_enumeration_mapping_ranges_get_range_count(
124 struct bt_field_class_signed_enumeration_mapping_ranges
*ranges
);
126 extern void bt_field_class_unsigned_enumeration_mapping_ranges_get_range_by_index(
127 struct bt_field_class_unsigned_enumeration_mapping_ranges
*ranges
,
128 uint64_t index
, uint64_t *lower
, uint64_t *upper
);
130 extern void bt_field_class_signed_enumeration_mapping_ranges_get_range_by_index(
131 struct bt_field_class_unsigned_enumeration_mapping_ranges
*ranges
,
132 uint64_t index
, int64_t *lower
, int64_t *upper
);
134 extern int bt_field_class_unsigned_enumeration_get_mapping_labels_by_value(
135 struct bt_field_class
*field_class
, uint64_t value
,
136 bt_field_class_enumeration_mapping_label_array
*label_array
,
139 extern int bt_field_class_signed_enumeration_get_mapping_labels_by_value(
140 struct bt_field_class
*field_class
, int64_t value
,
141 bt_field_class_enumeration_mapping_label_array
*label_array
,
144 extern int bt_field_class_unsigned_enumeration_map_range(
145 struct bt_field_class
*field_class
, const char *label
,
146 uint64_t range_lower
, uint64_t range_upper
);
148 extern int bt_field_class_signed_enumeration_map_range(
149 struct bt_field_class
*field_class
, const char *label
,
150 int64_t range_lower
, int64_t range_upper
);
152 extern struct bt_field_class
*bt_field_class_string_create(void);
154 extern struct bt_field_class
*bt_field_class_structure_create(void);
156 extern uint64_t bt_field_class_structure_get_member_count(
157 struct bt_field_class
*field_class
);
159 extern void bt_field_class_structure_borrow_member_by_index(
160 struct bt_field_class
*struct_field_class
, uint64_t index
,
161 const char **name
, struct bt_field_class
**field_class
);
164 struct bt_field_class
*bt_field_class_structure_borrow_member_field_class_by_name(
165 struct bt_field_class
*field_class
, const char *name
);
167 extern int bt_field_class_structure_append_member(
168 struct bt_field_class
*struct_field_class
, const char *name
,
169 struct bt_field_class
*field_class
);
171 extern struct bt_field_class
*bt_field_class_static_array_create(
172 struct bt_field_class
*elem_field_class
,
175 extern struct bt_field_class
*bt_field_class_dynamic_array_create(
176 struct bt_field_class
*elem_field_class
);
178 extern struct bt_field_class
*bt_field_class_array_borrow_element_field_class(
179 struct bt_field_class
*field_class
);
181 extern uint64_t bt_field_class_static_array_get_length(
182 struct bt_field_class
*field_class
);
184 extern struct bt_field_path
*
185 bt_field_class_dynamic_array_borrow_length_field_path(
186 struct bt_field_class
*field_class
);
188 extern int bt_field_class_dynamic_array_set_length_field_class(
189 struct bt_field_class
*field_class
,
190 struct bt_field_class
*length_field_class
);
192 extern struct bt_field_class
*bt_field_class_variant_create(void);
194 extern struct bt_field_path
*
195 bt_field_class_variant_borrow_selector_field_path(
196 struct bt_field_class
*field_class
);
198 extern int bt_field_class_variant_set_selector_field_class(
199 struct bt_field_class
*field_class
,
200 struct bt_field_class
*selector_field_class
);
202 extern uint64_t bt_field_class_variant_get_option_count(
203 struct bt_field_class
*field_class
);
205 extern void bt_field_class_variant_borrow_option_by_index(
206 struct bt_field_class
*variant_field_class
, uint64_t index
,
207 const char **name
, struct bt_field_class
**field_class
);
210 struct bt_field_class
*bt_field_class_variant_borrow_option_field_class_by_name(
211 struct bt_field_class
*field_class
,
214 extern int bt_field_class_variant_append_option(
215 struct bt_field_class
*var_field_class
,
216 const char *name
, struct bt_field_class
*field_class
);
222 #endif /* BABELTRACE_TRACE_IR_FIELD_CLASSES_H */