ir: add bt_ctf_field_type_structure_get_field_name_index()
[babeltrace.git] / include / babeltrace / ctf-ir / event-types-internal.h
CommitLineData
adc315b8
JG
1#ifndef BABELTRACE_CTF_IR_EVENT_TYPES_INTERNAL_H
2#define BABELTRACE_CTF_IR_EVENT_TYPES_INTERNAL_H
273b65be
JG
3
4/*
adc315b8 5 * BabelTrace - CTF IR: Event types internal
273b65be 6 *
de9dd397 7 * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
273b65be
JG
8 *
9 * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
10 *
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:
17 *
18 * The above copyright notice and this permission notice shall be included in
19 * all copies or substantial portions of the Software.
20 *
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
27 * SOFTWARE.
28 */
29
30#include <babeltrace/ctf-writer/event-types.h>
31#include <babeltrace/ctf-writer/ref-internal.h>
32#include <babeltrace/ctf-writer/event-fields.h>
33#include <babeltrace/ctf-writer/writer.h>
bc37ae52 34#include <babeltrace/ctf-ir/trace-internal.h>
273b65be
JG
35#include <babeltrace/babeltrace-internal.h>
36#include <babeltrace/types.h>
37#include <babeltrace/ctf/events.h>
38#include <glib.h>
39
b75277fb
JG
40typedef void (*type_freeze_func)(struct bt_ctf_field_type *);
41typedef int (*type_serialize_func)(struct bt_ctf_field_type *,
273b65be
JG
42 struct metadata_context *);
43
44struct bt_ctf_field_type {
45 struct bt_ctf_ref ref_count;
46 struct bt_declaration *declaration;
47 type_freeze_func freeze;
48 type_serialize_func serialize;
49 /*
50 * A type can't be modified once it is added to an event or after a
51 * a field has been instanciated from it.
52 */
53 int frozen;
54};
55
56struct bt_ctf_field_type_integer {
57 struct bt_ctf_field_type parent;
58 struct declaration_integer declaration;
6cfb906f 59 struct bt_ctf_clock *mapped_clock;
273b65be
JG
60};
61
62struct enumeration_mapping {
b92ddaaa
JG
63 union {
64 uint64_t _unsigned;
65 int64_t _signed;
66 } range_start;
67
68 union {
69 uint64_t _unsigned;
70 int64_t _signed;
71 } range_end;
273b65be
JG
72 GQuark string;
73};
74
75struct bt_ctf_field_type_enumeration {
76 struct bt_ctf_field_type parent;
77 struct bt_ctf_field_type *container;
78 GPtrArray *entries; /* Array of pointers to struct enum_mapping */
79 struct declaration_enum declaration;
80};
81
82struct bt_ctf_field_type_floating_point {
83 struct bt_ctf_field_type parent;
84 struct declaration_float declaration;
85 struct declaration_integer sign;
86 struct declaration_integer mantissa;
87 struct declaration_integer exp;
88};
89
90struct structure_field {
91 GQuark name;
92 struct bt_ctf_field_type *type;
93};
94
95struct bt_ctf_field_type_structure {
96 struct bt_ctf_field_type parent;
97 GHashTable *field_name_to_index;
98 GPtrArray *fields; /* Array of pointers to struct structure_field */
24724933 99 struct declaration_struct declaration;
273b65be
JG
100};
101
102struct bt_ctf_field_type_variant {
103 struct bt_ctf_field_type parent;
104 GString *tag_name;
105 struct bt_ctf_field_type_enumeration *tag;
106 GHashTable *field_name_to_index;
107 GPtrArray *fields; /* Array of pointers to struct structure_field */
108 struct declaration_variant declaration;
109};
110
111struct bt_ctf_field_type_array {
112 struct bt_ctf_field_type parent;
113 struct bt_ctf_field_type *element_type;
114 unsigned int length; /* Number of elements */
115 struct declaration_array declaration;
116};
117
118struct bt_ctf_field_type_sequence {
119 struct bt_ctf_field_type parent;
120 struct bt_ctf_field_type *element_type;
121 GString *length_field_name;
122 struct declaration_sequence declaration;
123};
124
125struct bt_ctf_field_type_string {
126 struct bt_ctf_field_type parent;
127 struct declaration_string declaration;
128};
129
130BT_HIDDEN
131void bt_ctf_field_type_freeze(struct bt_ctf_field_type *type);
132
133BT_HIDDEN
b92ddaaa
JG
134struct bt_ctf_field_type *bt_ctf_field_type_variant_get_field_type_signed(
135 struct bt_ctf_field_type_variant *variant, int64_t tag_value);
273b65be
JG
136
137BT_HIDDEN
b92ddaaa
JG
138struct bt_ctf_field_type *bt_ctf_field_type_variant_get_field_type_unsigned(
139 struct bt_ctf_field_type_variant *variant, uint64_t tag_value);
273b65be
JG
140
141BT_HIDDEN
142int bt_ctf_field_type_serialize(struct bt_ctf_field_type *type,
143 struct metadata_context *context);
144
9ce21c30
JG
145BT_HIDDEN
146int bt_ctf_field_type_validate(struct bt_ctf_field_type *type);
147
e5958c30
JG
148BT_HIDDEN
149const char *bt_ctf_field_type_enumeration_get_mapping_name_unsigned(
150 struct bt_ctf_field_type_enumeration *enumeration_type,
151 uint64_t value);
152
153BT_HIDDEN
154const char *bt_ctf_field_type_enumeration_get_mapping_name_signed(
155 struct bt_ctf_field_type_enumeration *enumeration_type,
156 int64_t value);
157
c35a1669
JG
158/* Override field type's byte order only if it is set to "native" */
159BT_HIDDEN
160void bt_ctf_field_type_set_native_byte_order(
161 struct bt_ctf_field_type *type, int byte_order);
24724933
JG
162
163/* Deep copy a field type */
164BT_HIDDEN
165struct bt_ctf_field_type *bt_ctf_field_type_copy(
166 struct bt_ctf_field_type *type);
167
39a5e0db
JG
168
169BT_HIDDEN
170int bt_ctf_field_type_structure_get_field_name_index(
171 struct bt_ctf_field_type *structure, const char *name);
adc315b8 172#endif /* BABELTRACE_CTF_IR_EVENT_TYPES_INTERNAL_H */
This page took 0.032555 seconds and 4 git commands to generate.