ir: remove unused event_headers member from struct bt_ctf_stream
[babeltrace.git] / include / babeltrace / ctf-ir / event.h
CommitLineData
adc315b8
JG
1#ifndef BABELTRACE_CTF_IR_EVENT_H
2#define BABELTRACE_CTF_IR_EVENT_H
3
4/*
5 * BabelTrace - CTF IR: Event
6 *
de9dd397 7 * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
adc315b8
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 * The Common Trace Format (CTF) Specification is available at
30 * http://www.efficios.com/ctf
31 */
32
2f100782
JG
33#include <stdint.h>
34#include <stddef.h>
dac5c838 35#include <babeltrace/values.h>
2f100782 36
adc315b8
JG
37#ifdef __cplusplus
38extern "C" {
39#endif
40
41struct bt_ctf_event_class;
42struct bt_ctf_event;
43struct bt_ctf_field;
44struct bt_ctf_field_type;
2f100782 45struct bt_ctf_stream_class;
adc315b8 46
adc315b8
JG
47/*
48 * bt_ctf_event_create: instanciate an event.
49 *
50 * Allocate a new event of the given event class. The creation of an event
51 * sets its reference count to 1. Each instance shares the ownership of the
52 * event class using its reference count.
53 *
54fca895
JG
54 * An event class must be associated with a stream class before events
55 * may be instanciated.
56 *
adc315b8
JG
57 * @param event_class Event class.
58 *
59 * Returns an allocated field type on success, NULL on error.
60 */
61extern struct bt_ctf_event *bt_ctf_event_create(
62 struct bt_ctf_event_class *event_class);
63
2f100782
JG
64/*
65 * bt_ctf_event_get_class: get an event's class.
66 *
67 * @param event Event.
68 *
69 * Returns the event's class, NULL on error.
70 */
71extern struct bt_ctf_event_class *bt_ctf_event_get_class(
72 struct bt_ctf_event *event);
73
8e5003bb
JG
74/*
75 * bt_ctf_event_get_stream: get an event's associated stream.
76 *
77 * @param event Event.
78 *
79 * Returns the event's associated stream, NULL on error.
80 */
81extern struct bt_ctf_stream *bt_ctf_event_get_stream(
82 struct bt_ctf_event *event);
83
2f100782
JG
84/*
85 * bt_ctf_event_get_clock: get an event's associated clock.
86 *
87 * @param event Event.
88 *
89 * Returns the event's clock, NULL on error.
90 */
91extern struct bt_ctf_clock *bt_ctf_event_get_clock(
92 struct bt_ctf_event *event);
93
71362d53
PP
94/*
95 * bt_ctf_event_get_payload_field: get an event's payload.
96 *
97 * @param event Event instance.
98 *
99 * Returns a field instance on success, NULL on error.
100 */
101extern struct bt_ctf_field *bt_ctf_event_get_payload_field(
102 struct bt_ctf_event *event);
103
e5e6eb3a
JG
104/*
105 * bt_ctf_event_set_payload_field: set an event's payload.
106 *
107 * @param event Event instance.
108 * @param payload Field instance (must be a structure).
109 *
110 * Returns 0 on success, a negative value on error.
111 */
112extern int bt_ctf_event_set_payload_field(struct bt_ctf_event *event,
113 struct bt_ctf_field *payload);
114
2f100782
JG
115/*
116 * bt_ctf_event_get_payload: get an event's field.
117 *
118 * Returns the field matching "name". bt_ctf_field_put() must be called on the
119 * returned value.
120 *
121 * @param event Event instance.
c5a9aa19 122 * @param name Event field name, see notes.
2f100782
JG
123 *
124 * Returns a field instance on success, NULL on error.
c5a9aa19
JG
125 *
126 * Note: Passing a name will cause the function to perform a look-up by
127 * name assuming the event's payload is a structure. This will return
128 * the raw payload instance if name is NULL.
2f100782
JG
129 */
130extern struct bt_ctf_field *bt_ctf_event_get_payload(struct bt_ctf_event *event,
131 const char *name);
132
adc315b8
JG
133/*
134 * bt_ctf_event_set_payload: set an event's field.
135 *
136 * Set a manually allocated field as an event's payload. The event will share
137 * the field's ownership by using its reference count.
138 * bt_ctf_field_put() must be called on the returned value.
139 *
140 * @param event Event instance.
c5a9aa19 141 * @param name Event field name, see notes.
adc315b8
JG
142 * @param value Instance of a field whose type corresponds to the event's field.
143 *
144 * Returns 0 on success, a negative value on error.
c5a9aa19
JG
145 *
146 * Note: The function will return an error if a name is provided and the payload
147 * type is not a structure. If name is NULL, the payload field will be set
148 * directly and must match the event class' payload's type.
adc315b8
JG
149 */
150extern int bt_ctf_event_set_payload(struct bt_ctf_event *event,
151 const char *name,
152 struct bt_ctf_field *value);
153
154/*
2f100782 155 * bt_ctf_event_get_payload_by_index: Get event's field by index.
adc315b8 156 *
2f100782
JG
157 * Returns the field associated with the provided index. bt_ctf_field_put()
158 * must be called on the returned value. The indexes to be provided are
159 * the same as can be retrieved from the event class.
adc315b8 160 *
2f100782
JG
161 * @param event Event.
162 * @param index Index of field.
adc315b8 163 *
2f100782 164 * Returns the event's field, NULL on error.
c5a9aa19
JG
165 *
166 * Note: Will return an error if the payload's type is not a structure.
adc315b8 167 */
2f100782 168extern struct bt_ctf_field *bt_ctf_event_get_payload_by_index(
074ee56d 169 struct bt_ctf_event *event, int index);
adc315b8 170
662e778c
JG
171/*
172 * bt_ctf_event_get_header: get an event's header.
173 *
174 * @param event Event instance.
175 *
176 * Returns a field instance on success, NULL on error.
177 */
178extern struct bt_ctf_field *bt_ctf_event_get_header(
179 struct bt_ctf_event *event);
180
181/*
182 * bt_ctf_event_set_header: set an event's header.
183 *
184 * The event header's type must match the stream class' event
185 * header type.
186 *
187 * @param event Event instance.
188 * @param header Event header field instance.
189 *
190 * Returns a field instance on success, NULL on error.
191 */
192extern int bt_ctf_event_set_header(
193 struct bt_ctf_event *event,
194 struct bt_ctf_field *header);
195
f655a84d
JG
196/*
197 * bt_ctf_event_get_event_context: Get an event's context
198 *
199 * @param event_class Event class.
200 *
201 * Returns a field on success (a structure), NULL on error.
202 *
203 * Note: This function is named this way instead of the expected
204 * "bt_ctf_event_get_context" in order to work around a name clash with
205 * an unrelated function bearing this name in context.h.
206 */
207extern struct bt_ctf_field *bt_ctf_event_get_event_context(
208 struct bt_ctf_event *event);
209
210/*
211 * bt_ctf_event_set_event_context: Set an event's context
212 *
213 * @param event Event.
214 * @param context Event context field (must match the event class'
215 * context type).
216 *
217 * Returns 0 on success, a negative value on error.
218 */
219extern int bt_ctf_event_set_event_context(struct bt_ctf_event *event,
220 struct bt_ctf_field *context);
221
9c4c8f6e
PP
222/*
223 * bt_ctf_event_copy: Deep-copy an event.
224 *
225 * Get an event's deep copy.
226 *
227 * On success, the returned copy has its reference count set to 1.
228 *
229 * @param event Event to copy.
230 *
231 * Returns the deep-copied event on success, NULL on error.
232 */
233extern struct bt_ctf_event *bt_ctf_event_copy(struct bt_ctf_event *event);
234
adc315b8
JG
235/*
236 * bt_ctf_event_get and bt_ctf_event_put: increment and decrement
237 * the event's reference count.
238 *
de3dd40e
PP
239 * You may also use bt_ctf_get() and bt_ctf_put() with event objects.
240 *
adc315b8
JG
241 * These functions ensure that the event won't be destroyed while it
242 * is in use. The same number of get and put (plus one extra put to
243 * release the initial reference done at creation) have to be done to
244 * destroy an event.
245 *
246 * When the event's reference count is decremented to 0 by a
247 * bt_ctf_event_put, the event is freed.
248 *
249 * @param event Event instance.
250 */
251extern void bt_ctf_event_get(struct bt_ctf_event *event);
252extern void bt_ctf_event_put(struct bt_ctf_event *event);
253
254#ifdef __cplusplus
255}
256#endif
257
258#endif /* BABELTRACE_CTF_IR_EVENT_H */
This page took 0.037072 seconds and 4 git commands to generate.