stream.h: doc: add missing type doc
[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
1556a1af
JG
41struct bt_ctf_clock;
42struct bt_ctf_clock_value;
adc315b8
JG
43struct bt_ctf_event_class;
44struct bt_ctf_event;
45struct bt_ctf_field;
46struct bt_ctf_field_type;
2f100782 47struct bt_ctf_stream_class;
5c3b707d 48struct bt_ctf_packet;
adc315b8 49
adc315b8
JG
50/*
51 * bt_ctf_event_create: instanciate an event.
52 *
53 * Allocate a new event of the given event class. The creation of an event
54 * sets its reference count to 1. Each instance shares the ownership of the
55 * event class using its reference count.
56 *
54fca895
JG
57 * An event class must be associated with a stream class before events
58 * may be instanciated.
59 *
adc315b8
JG
60 * @param event_class Event class.
61 *
62 * Returns an allocated field type on success, NULL on error.
63 */
64extern struct bt_ctf_event *bt_ctf_event_create(
65 struct bt_ctf_event_class *event_class);
66
2f100782
JG
67/*
68 * bt_ctf_event_get_class: get an event's class.
69 *
70 * @param event Event.
71 *
72 * Returns the event's class, NULL on error.
73 */
74extern struct bt_ctf_event_class *bt_ctf_event_get_class(
75 struct bt_ctf_event *event);
76
8e5003bb
JG
77/*
78 * bt_ctf_event_get_stream: get an event's associated stream.
79 *
80 * @param event Event.
81 *
82 * Returns the event's associated stream, NULL on error.
83 */
84extern struct bt_ctf_stream *bt_ctf_event_get_stream(
85 struct bt_ctf_event *event);
86
71362d53
PP
87/*
88 * bt_ctf_event_get_payload_field: get an event's payload.
89 *
90 * @param event Event instance.
91 *
92 * Returns a field instance on success, NULL on error.
93 */
94extern struct bt_ctf_field *bt_ctf_event_get_payload_field(
95 struct bt_ctf_event *event);
96
e5e6eb3a
JG
97/*
98 * bt_ctf_event_set_payload_field: set an event's payload.
99 *
100 * @param event Event instance.
101 * @param payload Field instance (must be a structure).
102 *
103 * Returns 0 on success, a negative value on error.
104 */
105extern int bt_ctf_event_set_payload_field(struct bt_ctf_event *event,
106 struct bt_ctf_field *payload);
107
2f100782
JG
108/*
109 * bt_ctf_event_get_payload: get an event's field.
110 *
51865548 111 * Returns the field matching "name". bt_put() must be called on the
2f100782
JG
112 * returned value.
113 *
114 * @param event Event instance.
c5a9aa19 115 * @param name Event field name, see notes.
2f100782
JG
116 *
117 * Returns a field instance on success, NULL on error.
c5a9aa19
JG
118 *
119 * Note: Passing a name will cause the function to perform a look-up by
120 * name assuming the event's payload is a structure. This will return
121 * the raw payload instance if name is NULL.
2f100782
JG
122 */
123extern struct bt_ctf_field *bt_ctf_event_get_payload(struct bt_ctf_event *event,
124 const char *name);
125
adc315b8
JG
126/*
127 * bt_ctf_event_set_payload: set an event's field.
128 *
129 * Set a manually allocated field as an event's payload. The event will share
130 * the field's ownership by using its reference count.
51865548 131 * bt_put() must be called on the returned value.
adc315b8
JG
132 *
133 * @param event Event instance.
c5a9aa19 134 * @param name Event field name, see notes.
adc315b8
JG
135 * @param value Instance of a field whose type corresponds to the event's field.
136 *
137 * Returns 0 on success, a negative value on error.
c5a9aa19
JG
138 *
139 * Note: The function will return an error if a name is provided and the payload
140 * type is not a structure. If name is NULL, the payload field will be set
141 * directly and must match the event class' payload's type.
adc315b8
JG
142 */
143extern int bt_ctf_event_set_payload(struct bt_ctf_event *event,
144 const char *name,
145 struct bt_ctf_field *value);
146
147/*
2f100782 148 * bt_ctf_event_get_payload_by_index: Get event's field by index.
adc315b8 149 *
51865548 150 * Returns the field associated with the provided index. bt_put()
2f100782
JG
151 * must be called on the returned value. The indexes to be provided are
152 * the same as can be retrieved from the event class.
adc315b8 153 *
2f100782
JG
154 * @param event Event.
155 * @param index Index of field.
adc315b8 156 *
2f100782 157 * Returns the event's field, NULL on error.
c5a9aa19
JG
158 *
159 * Note: Will return an error if the payload's type is not a structure.
adc315b8 160 */
2f100782 161extern struct bt_ctf_field *bt_ctf_event_get_payload_by_index(
074ee56d 162 struct bt_ctf_event *event, int index);
adc315b8 163
662e778c
JG
164/*
165 * bt_ctf_event_get_header: get an event's header.
166 *
167 * @param event Event instance.
168 *
169 * Returns a field instance on success, NULL on error.
170 */
171extern struct bt_ctf_field *bt_ctf_event_get_header(
172 struct bt_ctf_event *event);
173
174/*
175 * bt_ctf_event_set_header: set an event's header.
176 *
177 * The event header's type must match the stream class' event
178 * header type.
179 *
180 * @param event Event instance.
181 * @param header Event header field instance.
182 *
183 * Returns a field instance on success, NULL on error.
184 */
185extern int bt_ctf_event_set_header(
186 struct bt_ctf_event *event,
187 struct bt_ctf_field *header);
188
f655a84d
JG
189/*
190 * bt_ctf_event_get_event_context: Get an event's context
191 *
192 * @param event_class Event class.
193 *
194 * Returns a field on success (a structure), NULL on error.
195 *
196 * Note: This function is named this way instead of the expected
197 * "bt_ctf_event_get_context" in order to work around a name clash with
198 * an unrelated function bearing this name in context.h.
199 */
200extern struct bt_ctf_field *bt_ctf_event_get_event_context(
201 struct bt_ctf_event *event);
202
203/*
204 * bt_ctf_event_set_event_context: Set an event's context
205 *
206 * @param event Event.
207 * @param context Event context field (must match the event class'
208 * context type).
209 *
210 * Returns 0 on success, a negative value on error.
211 */
212extern int bt_ctf_event_set_event_context(struct bt_ctf_event *event,
213 struct bt_ctf_field *context);
214
5fd2e9fd
PP
215/*
216 * bt_ctf_event_get_stream_event_context: Get an event's stream event context
217 *
218 * @param event_class Event class.
219 *
220 * Returns a field on success (a structure), NULL on error.
221 */
222extern struct bt_ctf_field *bt_ctf_event_get_stream_event_context(
223 struct bt_ctf_event *event);
224
225/*
226 * bt_ctf_event_set_stream_event_context: Set an event's stream event context
227 *
228 * @param event Event.
229 * @param context Event stream context field (must match the stream class'
230 * stream event context type).
231 *
232 * Returns 0 on success, a negative value on error.
233 */
234extern int bt_ctf_event_set_stream_event_context(struct bt_ctf_event *event,
235 struct bt_ctf_field *context);
236
5c0f40f4
JG
237extern struct bt_ctf_packet *bt_ctf_event_get_packet(
238 struct bt_ctf_event *event);
239
5c3b707d
PP
240extern int bt_ctf_event_set_packet(struct bt_ctf_event *event,
241 struct bt_ctf_packet *packet);
242
1556a1af
JG
243extern struct bt_ctf_clock_value *bt_ctf_event_get_clock_value(
244 struct bt_ctf_event *event, struct bt_ctf_clock *clock);
245
246extern int bt_ctf_event_set_clock_value(
247 struct bt_ctf_event *event, struct bt_ctf_clock *clock,
248 struct bt_ctf_clock_value *value);
41ac640a 249
adc315b8
JG
250#ifdef __cplusplus
251}
252#endif
253
254#endif /* BABELTRACE_CTF_IR_EVENT_H */
This page took 0.042344 seconds and 4 git commands to generate.