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