Python build fix
[babeltrace.git] / include / babeltrace / ctf-ir / event-class-internal.h
CommitLineData
1c822dfb
JG
1#ifndef BABELTRACE_CTF_IR_EVENT_CLASS_INTERNAL_H
2#define BABELTRACE_CTF_IR_EVENT_CLASS_INTERNAL_H
273b65be
JG
3
4/*
1c822dfb 5 * Babeltrace - CTF IR: Event class internal
273b65be 6 *
1c822dfb 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
1c822dfb
JG
30#include <babeltrace/ctf-ir/field-types.h>
31#include <babeltrace/ctf-ir/fields.h>
273b65be 32#include <babeltrace/babeltrace-internal.h>
1c822dfb 33#include <babeltrace/values.h>
273b65be 34#include <babeltrace/ctf/types.h>
1c822dfb 35#include <babeltrace/ctf-ir/stream-class.h>
1c822dfb 36#include <babeltrace/object-internal.h>
273b65be
JG
37#include <glib.h>
38
1c822dfb
JG
39#define BT_CTF_EVENT_CLASS_ATTR_ID_INDEX 0
40#define BT_CTF_EVENT_CLASS_ATTR_NAME_INDEX 1
41
273b65be 42struct bt_ctf_event_class {
1c822dfb
JG
43 struct bt_object base;
44 struct bt_value *attributes;
273b65be
JG
45 /* Structure type containing the event's context */
46 struct bt_ctf_field_type *context;
47 /* Structure type containing the event's fields */
48 struct bt_ctf_field_type *fields;
49 int frozen;
273b65be 50
1c822dfb
JG
51 /*
52 * This flag indicates if the event class is valid. A valid
53 * event class is _always_ frozen. However, an event class
54 * may be frozen, but not valid yet. This is okay, as long as
55 * no events are created out of this event class.
56 */
57 int valid;
273b65be
JG
58};
59
60BT_HIDDEN
61void bt_ctf_event_class_freeze(struct bt_ctf_event_class *event_class);
62
273b65be
JG
63BT_HIDDEN
64int bt_ctf_event_class_serialize(struct bt_ctf_event_class *event_class,
65 struct metadata_context *context);
66
67BT_HIDDEN
1c822dfb
JG
68void bt_ctf_event_class_set_native_byte_order(
69 struct bt_ctf_event_class *event_class,
70 int byte_order);
273b65be
JG
71
72BT_HIDDEN
1c822dfb
JG
73int bt_ctf_event_class_set_stream_id(struct bt_ctf_event_class *event_class,
74 uint32_t stream_id);
273b65be 75
55667b40
JG
76/*
77 * bt_ctf_event_class_set_attribute: sets an attribute to the event
78 * class.
79 *
80 * Sets an attribute to the event class. The name parameter is copied,
81 * whereas the value parameter's reference count is incremented
82 * (if the function succeeds).
83 *
84 * If an attribute exists in the event class for the specified name, it
85 * is replaced by the new value.
86 *
87 * Valid attributes and object types are:
88 *
89 * - "id": integer object with a value >= 0
90 * - "name": string object
91 * - "loglevel": integer object with a value >= 0
92 * - "model.emf.uri": string object
93 *
94 * @param event_class Event class.
95 * @param name Name of the attribute (will be copied).
96 * @param value Value of the attribute.
97 *
98 * Returns 0 on success, a negative value on error.
99 */
100BT_HIDDEN
101int bt_ctf_event_class_set_attribute(
102 struct bt_ctf_event_class *event_class, const char *name,
103 struct bt_value *value);
104
105/*
106 * bt_ctf_event_class_get_attribute_count: get the number of attributes
107 * in this event class.
108 *
109 * Get the event class' attribute count.
110 *
111 * @param event_class Event class.
112 *
113 * Returns the attribute count, a negative value on error.
114 */
115BT_HIDDEN
116int bt_ctf_event_class_get_attribute_count(
117 struct bt_ctf_event_class *event_class);
118
119/*
120 * bt_ctf_event_class_get_attribute_name: get attribute name.
121 *
122 * Get an attribute's name. The string's ownership is not
123 * transferred to the caller. The string data is valid as long as
124 * this event class' attributes are not modified.
125 *
126 * @param event_class Event class.
127 * @param index Index of the attribute.
128 *
129 * Returns the attribute's name, NULL on error.
130 */
131BT_HIDDEN
132const char *
133bt_ctf_event_class_get_attribute_name(
134 struct bt_ctf_event_class *event_class, int index);
135
136/*
137 * bt_ctf_event_class_get_attribute_value: get attribute value (an object).
138 *
139 * Get an attribute's value (an object). The returned object's
140 * reference count is incremented. When done with the object, the caller
141 * must call bt_value_put() on it.
142 *
143 * @param event_class Event class.
144 * @param index Index of the attribute.
145 *
146 * Returns the attribute's object value, NULL on error.
147 */
148BT_HIDDEN
149struct bt_value *
150bt_ctf_event_class_get_attribute_value(struct bt_ctf_event_class *event_class,
151 int index);
152
153/*
154 * bt_ctf_event_class_get_attribute_value_by_name: get attribute
155 * value (an object) by name.
156 *
157 * Get an attribute's value (an object) by its name. The returned object's
158 * reference count is incremented. When done with the object, the caller
159 * must call bt_value_put() on it.
160 *
161 * @param event_class Event class.
162 * @param name Attribute's name
163 *
164 * Returns the attribute's object value, NULL on error.
165 */
166BT_HIDDEN
167struct bt_value *
168bt_ctf_event_class_get_attribute_value_by_name(
169 struct bt_ctf_event_class *event_class, const char *name);
170
171/*
172 * bt_ctf_event_class_get_context_type: Get an event class's context type
173 *
174 * @param event_class Event class.
175 *
176 * Returns a field type (a structure) on success, NULL on error.
177 */
178BT_HIDDEN
179struct bt_ctf_field_type *bt_ctf_event_class_get_context_type(
180 struct bt_ctf_event_class *event_class);
181
182
183/*
184 * bt_ctf_event_class_get_field_count: Get an event class' field count.
185 *
186 * @param event_class Event class.
187 *
188 * Returns the event class' field count, a negative value on error.
189 *
190 * Note: Returns an error if the payload is not a structure.
191 */
192BT_HIDDEN
193int bt_ctf_event_class_get_field_count(
194 struct bt_ctf_event_class *event_class);
195
196/*
197 * bt_ctf_event_class_get_field: Get event class' field type and name by index.
198 *
199 * @param event_class Event class.
200 * @param field_name Pointer to a const char* where the field's name will
201 * be returned.
202 * @param field_type Pointer to a bt_ctf_field_type* where the field's type will
203 * be returned.
204 * @param index Index of field.
205 *
206 * Returns 0 on success, a negative error on value.
207 *
208 * Note: Returns an error if the payload is not a structure.
209 */
210BT_HIDDEN
211int bt_ctf_event_class_get_field(struct bt_ctf_event_class *event_class,
212 const char **field_name, struct bt_ctf_field_type **field_type,
213 int index);
214
215/*
216 * bt_ctf_event_class_get_id: Get an event class' id.
217 *
218 * @param event_class Event class.
219 *
220 * Returns the event class' id, a negative value on error.
221 */
222BT_HIDDEN
223int64_t bt_ctf_event_class_get_id(struct bt_ctf_event_class *event_class);
224
225/*
226 * bt_ctf_event_class_get_name: Get an event class' name.
227 *
228 * @param event_class Event class.
229 *
230 * Returns the event class' name, NULL on error.
231 */
232BT_HIDDEN
233const char *bt_ctf_event_class_get_name(
234 struct bt_ctf_event_class *event_class);
235
236/*
237 * bt_ctf_event_class_get_stream_class: Get an event class' stream class.
238 *
239 * @param event_class Event class.
240 *
241 * Returns the event class' stream class, NULL on error or if the event class
242 * is not associated with a stream class.
243 */
244BT_HIDDEN
245struct bt_ctf_stream_class *bt_ctf_event_class_get_stream_class(
246 struct bt_ctf_event_class *event_class);
247
248/*
249 * bt_ctf_event_class_get_payload_type: get an event class' payload.
250 *
251 * Get an event class' payload type.
252 *
253 * @param event_class Event class.
254 *
255 * Returns the event class' payload, NULL on error.
256 */
257BT_HIDDEN
258struct bt_ctf_field_type *bt_ctf_event_class_get_payload_type(
259 struct bt_ctf_event_class *event_class);
260
261/*
262 * bt_ctf_event_class_set_id: Set an event class' id.
263 *
264 * Set an event class' id. Must be unique stream-wise.
265 * Note that event classes are already assigned a unique id when added to a
266 * stream class if none was set explicitly.
267 *
268 * @param event_class Event class.
269 * @param id Event class id.
270 *
271 * Returns 0 on success, a negative value on error.
272 */
273BT_HIDDEN
274int bt_ctf_event_class_set_id(
275 struct bt_ctf_event_class *event_class, uint32_t id);
276
277/*
278 * bt_ctf_event_class_set_payload_type: set an event class' payload.
279 *
280 * Set an event class' payload type.
281 *
282 * @param event_class Event class.
283 * @param payload The payload's type (must be a structure).
284 *
285 * Returns 0 on success, a negative value on error.
286 */
287BT_HIDDEN
288int bt_ctf_event_class_set_payload_type(
289 struct bt_ctf_event_class *event_class,
290 struct bt_ctf_field_type *payload);
291
292/*
293 * bt_ctf_event_class_set_context_type: Set an event class's context type
294 *
295 * @param event_class Event class.
296 * @param context Event context field type (must be a structure).
297 *
298 * Returns 0 on success, a negative value on error.
299 */
300BT_HIDDEN
301int bt_ctf_event_class_set_context_type(
302 struct bt_ctf_event_class *event_class,
303 struct bt_ctf_field_type *context);
304
1c822dfb 305#endif /* BABELTRACE_CTF_IR_EVENT_CLASS_INTERNAL_H */
This page took 0.036563 seconds and 4 git commands to generate.