lib: remove unneeded forward declarations in trace-ir/field-class.h
[babeltrace.git] / src / lib / trace-ir / field-class.h
... / ...
CommitLineData
1/*
2 * SPDX-License-Identifier: MIT
3 *
4 * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
5 * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 */
7
8#ifndef BABELTRACE_TRACE_IR_FIELD_CLASSES_INTERNAL_H
9#define BABELTRACE_TRACE_IR_FIELD_CLASSES_INTERNAL_H
10
11#include "lib/assert-cond.h"
12#include <babeltrace2/trace-ir/clock-class.h>
13#include <babeltrace2/trace-ir/field-class.h>
14#include "common/macros.h"
15#include "common/common.h"
16#include "lib/object.h"
17#include <babeltrace2/types.h>
18#include <stdbool.h>
19#include <stdint.h>
20#include <glib.h>
21
22#define BT_FIELD_CLASS_ENUM_MAPPING_AT_INDEX(_fc, _index) \
23 (&g_array_index(((struct bt_field_class_enumeration *) (_fc))->mappings, \
24 struct bt_field_class_enumeration_mapping, (_index)))
25
26#define BT_FIELD_CLASS_ENUM_MAPPING_RANGE_AT_INDEX(_mapping, _index) \
27 (&g_array_index((_mapping)->ranges, \
28 struct bt_field_class_enumeration_mapping_range, (_index)))
29
30struct bt_field_class {
31 struct bt_object base;
32 enum bt_field_class_type type;
33 bool frozen;
34
35 /* Owned by this */
36 struct bt_value *user_attributes;
37
38 /*
39 * This flag indicates whether or not this field class is part
40 * of a trace class.
41 */
42 bool part_of_trace_class;
43};
44
45struct bt_field_class_bool {
46 struct bt_field_class common;
47};
48
49struct bt_field_class_bit_array {
50 struct bt_field_class common;
51 uint64_t length;
52};
53
54struct bt_field_class_integer {
55 struct bt_field_class common;
56
57 /*
58 * Value range of fields built from this integer field class:
59 * this is an equivalent integer size in bits. More formally,
60 * `range` is `n` in:
61 *
62 * Unsigned range: [0, 2^n - 1]
63 * Signed range: [-2^(n - 1), 2^(n - 1) - 1]
64 */
65 uint64_t range;
66
67 enum bt_field_class_integer_preferred_display_base base;
68};
69
70struct bt_field_class_enumeration_mapping {
71 GString *label;
72
73 /* Owner by this */
74 const struct bt_integer_range_set *range_set;
75};
76
77struct bt_field_class_enumeration_unsigned_mapping;
78struct bt_field_class_enumeration_signed_mapping;
79
80struct bt_field_class_enumeration {
81 struct bt_field_class_integer common;
82
83 /* Array of `struct bt_field_class_enumeration_mapping *` */
84 GArray *mappings;
85
86 /*
87 * This is an array of `const char *` which acts as a temporary
88 * (potentially growing) buffer for
89 * bt_field_class_enumeration_unsigned_get_mapping_labels_for_value()
90 * and
91 * bt_field_class_enumeration_signed_get_mapping_labels_for_value().
92 *
93 * The actual strings are owned by the mappings above.
94 */
95 GPtrArray *label_buf;
96};
97
98struct bt_field_class_real {
99 struct bt_field_class common;
100};
101
102struct bt_field_class_string {
103 struct bt_field_class common;
104};
105
106/* A named field class is a (name, field class) pair */
107struct bt_named_field_class {
108 GString *name;
109
110 /* Owned by this */
111 struct bt_value *user_attributes;
112
113 /* Owned by this */
114 struct bt_field_class *fc;
115
116 bool frozen;
117};
118
119struct bt_field_class_structure_member;
120struct bt_field_class_variant_option;
121struct bt_field_class_variant_with_selector_field_integer_unsigned_option;
122struct bt_field_class_variant_with_selector_field_integer_signed_option;
123
124struct bt_field_class_named_field_class_container {
125 struct bt_field_class common;
126
127 /*
128 * Key: `const char *`, not owned by this (owned by named field
129 * class objects contained in `named_fcs` below).
130 */
131 GHashTable *name_to_index;
132
133 /* Array of `struct bt_named_field_class *` */
134 GPtrArray *named_fcs;
135};
136
137struct bt_field_class_structure {
138 struct bt_field_class_named_field_class_container common;
139};
140
141struct bt_field_class_array {
142 struct bt_field_class common;
143
144 /* Owned by this */
145 struct bt_field_class *element_fc;
146};
147
148struct bt_field_class_array_static {
149 struct bt_field_class_array common;
150 uint64_t length;
151};
152
153struct bt_field_class_array_dynamic {
154 struct bt_field_class_array common;
155
156 /* Owned by this */
157 struct bt_field_class *length_fc;
158
159 /* Owned by this */
160 struct bt_field_path *length_field_path;
161};
162
163struct bt_field_class_option {
164 struct bt_field_class common;
165
166 /* Owned by this */
167 struct bt_field_class *content_fc;
168};
169
170struct bt_field_class_option_with_selector_field {
171 struct bt_field_class_option common;
172
173 /* Owned by this */
174 struct bt_field_class *selector_fc;
175
176 /* Owned by this */
177 struct bt_field_path *selector_field_path;
178};
179
180struct bt_field_class_option_with_selector_field_bool {
181 struct bt_field_class_option_with_selector_field common;
182
183 /* Owned by this */
184 bool sel_is_reversed;
185};
186
187struct bt_field_class_option_with_selector_field_integer {
188 struct bt_field_class_option_with_selector_field common;
189
190 /* Owned by this */
191 const struct bt_integer_range_set *range_set;
192};
193
194/* Variant FC (with selector) option: named field class + range set */
195struct bt_field_class_variant_with_selector_field_option {
196 struct bt_named_field_class common;
197
198 /* Owned by this */
199 const struct bt_integer_range_set *range_set;
200};
201
202struct bt_field_class_variant {
203 /*
204 * Depending on the variant field class type, the contained
205 * named field classes are of type
206 * `struct bt_named_field_class *` if the variant field class
207 * doesn't have a selector, or
208 * `struct bt_field_class_variant_with_selector_field_option *`
209 * if it has.
210 */
211 struct bt_field_class_named_field_class_container common;
212};
213
214struct bt_field_class_variant_with_selector_field {
215 struct bt_field_class_variant common;
216
217 /*
218 * Owned by this, but never dereferenced: only use to find it
219 * elsewhere.
220 */
221 const struct bt_field_class *selector_fc;
222
223 /* Owned by this */
224 struct bt_field_path *selector_field_path;
225};
226
227void _bt_field_class_freeze(const struct bt_field_class *field_class);
228
229#ifdef BT_DEV_MODE
230# define bt_field_class_freeze _bt_field_class_freeze
231#else
232# define bt_field_class_freeze(_fc) ((void) _fc)
233#endif
234
235void _bt_named_field_class_freeze(const struct bt_named_field_class *named_fc);
236
237#ifdef BT_DEV_MODE
238# define bt_named_field_class_freeze _bt_named_field_class_freeze
239#else
240# define bt_named_field_class_freeze(_named_fc) ((void) _named_fc)
241#endif
242
243/*
244 * This function recursively marks `field_class` and its children as
245 * being part of a trace. This is used to validate that all field classes
246 * are used at a single location within trace objects even if they are
247 * shared objects for other purposes.
248 */
249void bt_field_class_make_part_of_trace_class(
250 const struct bt_field_class *field_class);
251
252#endif /* BABELTRACE_TRACE_IR_FIELD_CLASSES_INTERNAL_H */
This page took 0.024022 seconds and 4 git commands to generate.