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