Commit | Line | Data |
---|---|---|
11b0cdc8 | 1 | /* |
3f043b05 | 2 | * stream-class.c |
11b0cdc8 | 3 | * |
108b91d0 | 4 | * Babeltrace trace IR - Stream Class |
11b0cdc8 | 5 | * |
de9dd397 | 6 | * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com> |
11b0cdc8 JG |
7 | * |
8 | * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com> | |
9 | * | |
10 | * Permission is hereby granted, free of charge, to any person obtaining a copy | |
11 | * of this software and associated documentation files (the "Software"), to deal | |
12 | * in the Software without restriction, including without limitation the rights | |
13 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
14 | * copies of the Software, and to permit persons to whom the Software is | |
15 | * furnished to do so, subject to the following conditions: | |
16 | * | |
17 | * The above copyright notice and this permission notice shall be included in | |
18 | * all copies or substantial portions of the Software. | |
19 | * | |
20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
23 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
24 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
25 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | |
26 | * SOFTWARE. | |
27 | */ | |
28 | ||
d2f71f12 PP |
29 | #define BT_LOG_TAG "STREAM-CLASS" |
30 | #include <babeltrace/lib-logging-internal.h> | |
31 | ||
8deee039 | 32 | #include <babeltrace/assert-pre-internal.h> |
108b91d0 PP |
33 | #include <babeltrace/trace-ir/clock-class-internal.h> |
34 | #include <babeltrace/trace-ir/event-class-internal.h> | |
939190b3 | 35 | #include <babeltrace/trace-ir/field-classes-internal.h> |
108b91d0 PP |
36 | #include <babeltrace/trace-ir/fields-internal.h> |
37 | #include <babeltrace/trace-ir/stream-class-internal.h> | |
38 | #include <babeltrace/trace-ir/utils-internal.h> | |
39 | #include <babeltrace/trace-ir/field-wrapper-internal.h> | |
40 | #include <babeltrace/trace-ir/resolve-field-path-internal.h> | |
83509119 | 41 | #include <babeltrace/ref.h> |
3d9990ac PP |
42 | #include <babeltrace/compiler-internal.h> |
43 | #include <babeltrace/align-internal.h> | |
44 | #include <babeltrace/endian-internal.h> | |
8b45963b | 45 | #include <babeltrace/assert-internal.h> |
7b33a0e0 | 46 | #include <babeltrace/property-internal.h> |
dc3fffef | 47 | #include <inttypes.h> |
544d0515 | 48 | #include <stdint.h> |
e011d2c1 | 49 | #include <stdbool.h> |
11b0cdc8 | 50 | |
7b33a0e0 PP |
51 | #define BT_ASSERT_PRE_STREAM_CLASS_HOT(_sc) \ |
52 | BT_ASSERT_PRE_HOT((_sc), "Stream class", ": %!+S", (_sc)) | |
142c5610 | 53 | |
18acc6f8 | 54 | static |
7b33a0e0 | 55 | void destroy_stream_class(struct bt_object *obj) |
3ea33115 | 56 | { |
18acc6f8 PP |
57 | struct bt_stream_class *stream_class = (void *) obj; |
58 | ||
7b33a0e0 PP |
59 | BT_LIB_LOGD("Destroying stream class: %!+S", stream_class); |
60 | BT_LOGD_STR("Putting default clock class."); | |
61 | bt_put(stream_class->default_clock_class); | |
3ea33115 | 62 | |
8deee039 PP |
63 | if (stream_class->event_classes) { |
64 | BT_LOGD_STR("Destroying event classes."); | |
65 | g_ptr_array_free(stream_class->event_classes, TRUE); | |
d2f71f12 PP |
66 | } |
67 | ||
7b33a0e0 PP |
68 | if (stream_class->name.str) { |
69 | g_string_free(stream_class->name.str, TRUE); | |
3ea33115 JG |
70 | } |
71 | ||
939190b3 PP |
72 | BT_LOGD_STR("Putting event header field classe."); |
73 | bt_put(stream_class->event_header_fc); | |
74 | BT_LOGD_STR("Putting packet context field classe."); | |
75 | bt_put(stream_class->packet_context_fc); | |
76 | BT_LOGD_STR("Putting event common context field classe."); | |
77 | bt_put(stream_class->event_common_context_fc); | |
a6918753 PP |
78 | bt_object_pool_finalize(&stream_class->event_header_field_pool); |
79 | bt_object_pool_finalize(&stream_class->packet_context_field_pool); | |
8deee039 | 80 | g_free(stream_class); |
3ea33115 JG |
81 | } |
82 | ||
a6918753 PP |
83 | static |
84 | void free_field_wrapper(struct bt_field_wrapper *field_wrapper, | |
85 | struct bt_stream_class *stream_class) | |
86 | { | |
87 | bt_field_wrapper_destroy((void *) field_wrapper); | |
88 | } | |
89 | ||
7b33a0e0 PP |
90 | BT_ASSERT_PRE_FUNC |
91 | static | |
92 | bool stream_class_id_is_unique(struct bt_trace *trace, uint64_t id) | |
93 | { | |
94 | uint64_t i; | |
95 | bool is_unique = true; | |
96 | ||
97 | for (i = 0; i < trace->stream_classes->len; i++) { | |
98 | struct bt_stream_class *sc = | |
99 | trace->stream_classes->pdata[i]; | |
100 | ||
101 | if (sc->id == id) { | |
102 | is_unique = false; | |
103 | goto end; | |
104 | } | |
105 | } | |
106 | ||
107 | end: | |
108 | return is_unique; | |
109 | } | |
110 | ||
111 | static | |
112 | struct bt_stream_class *create_stream_class_with_id(struct bt_trace *trace, | |
113 | uint64_t id) | |
2f100782 | 114 | { |
8deee039 PP |
115 | struct bt_stream_class *stream_class = NULL; |
116 | int ret; | |
2f100782 | 117 | |
7b33a0e0 PP |
118 | BT_ASSERT(trace); |
119 | BT_ASSERT_PRE(stream_class_id_is_unique(trace, id), | |
120 | "Duplicate stream class ID: %![trace-]+t, id=%" PRIu64, | |
121 | trace, id); | |
122 | BT_LIB_LOGD("Creating stream class object: %![trace-]+t, id=%" PRIu64, | |
123 | trace, id); | |
8deee039 | 124 | stream_class = g_new0(struct bt_stream_class, 1); |
d2f71f12 | 125 | if (!stream_class) { |
8deee039 PP |
126 | BT_LOGE_STR("Failed to allocate one stream class."); |
127 | goto error; | |
d2f71f12 PP |
128 | } |
129 | ||
7b33a0e0 PP |
130 | bt_object_init_shared_with_parent(&stream_class->base, |
131 | destroy_stream_class); | |
132 | ||
133 | stream_class->name.str = g_string_new(NULL); | |
134 | if (!stream_class->name.str) { | |
135 | BT_LOGE_STR("Failed to allocate a GString."); | |
136 | ret = -1; | |
137 | goto end; | |
138 | } | |
139 | ||
140 | stream_class->id = id; | |
141 | stream_class->assigns_automatic_event_class_id = true; | |
142 | stream_class->assigns_automatic_stream_id = true; | |
143 | stream_class->event_classes = g_ptr_array_new_with_free_func( | |
144 | (GDestroyNotify) bt_object_try_spec_release); | |
145 | if (!stream_class->event_classes) { | |
146 | BT_LOGE_STR("Failed to allocate a GPtrArray."); | |
8deee039 | 147 | goto error; |
2f100782 JG |
148 | } |
149 | ||
a6918753 PP |
150 | ret = bt_object_pool_initialize(&stream_class->event_header_field_pool, |
151 | (bt_object_pool_new_object_func) bt_field_wrapper_new, | |
152 | (bt_object_pool_destroy_object_func) free_field_wrapper, | |
153 | stream_class); | |
154 | if (ret) { | |
155 | BT_LOGE("Failed to initialize event header field pool: ret=%d", | |
156 | ret); | |
157 | goto error; | |
158 | } | |
159 | ||
160 | ret = bt_object_pool_initialize(&stream_class->packet_context_field_pool, | |
161 | (bt_object_pool_new_object_func) bt_field_wrapper_new, | |
162 | (bt_object_pool_destroy_object_func) free_field_wrapper, | |
163 | stream_class); | |
164 | if (ret) { | |
165 | BT_LOGE("Failed to initialize packet context field pool: ret=%d", | |
166 | ret); | |
167 | goto error; | |
168 | } | |
169 | ||
7b33a0e0 PP |
170 | bt_object_set_parent(&stream_class->base, &trace->base); |
171 | g_ptr_array_add(trace->stream_classes, stream_class); | |
172 | bt_trace_freeze(trace); | |
173 | BT_LIB_LOGD("Created stream class object: %!+S", stream_class); | |
a6918753 PP |
174 | goto end; |
175 | ||
176 | error: | |
7b33a0e0 | 177 | BT_PUT(stream_class); |
a6918753 PP |
178 | |
179 | end: | |
7b33a0e0 | 180 | return stream_class; |
a6918753 PP |
181 | } |
182 | ||
7b33a0e0 | 183 | struct bt_stream_class *bt_stream_class_create(struct bt_trace *trace) |
a6918753 | 184 | { |
7b33a0e0 PP |
185 | BT_ASSERT_PRE_NON_NULL(trace, "Trace"); |
186 | BT_ASSERT_PRE(trace->assigns_automatic_stream_class_id, | |
187 | "Trace does not automatically assigns stream class IDs: " | |
188 | "%![sc-]+t", trace); | |
189 | return create_stream_class_with_id(trace, | |
190 | (uint64_t) trace->stream_classes->len); | |
191 | } | |
a6918753 | 192 | |
7b33a0e0 PP |
193 | struct bt_stream_class *bt_stream_class_create_with_id( |
194 | struct bt_trace *trace, uint64_t id) | |
195 | { | |
196 | BT_ASSERT_PRE_NON_NULL(trace, "Trace"); | |
197 | BT_ASSERT_PRE(!trace->assigns_automatic_stream_class_id, | |
198 | "Trace automatically assigns stream class IDs: " | |
199 | "%![sc-]+t", trace); | |
200 | return create_stream_class_with_id(trace, id); | |
a6918753 PP |
201 | } |
202 | ||
5fe68922 | 203 | struct bt_trace *bt_stream_class_borrow_trace(struct bt_stream_class *stream_class) |
11b0cdc8 | 204 | { |
7b33a0e0 PP |
205 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); |
206 | return bt_stream_class_borrow_trace_inline(stream_class); | |
11b0cdc8 JG |
207 | } |
208 | ||
8deee039 | 209 | const char *bt_stream_class_get_name(struct bt_stream_class *stream_class) |
2f100782 | 210 | { |
18acc6f8 | 211 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); |
7b33a0e0 | 212 | return stream_class->name.value; |
2f100782 JG |
213 | } |
214 | ||
8deee039 PP |
215 | int bt_stream_class_set_name(struct bt_stream_class *stream_class, |
216 | const char *name) | |
5ca83563 | 217 | { |
7b33a0e0 PP |
218 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); |
219 | BT_ASSERT_PRE_NON_NULL(name, "Name"); | |
220 | BT_ASSERT_PRE_STREAM_CLASS_HOT(stream_class); | |
221 | g_string_assign(stream_class->name.str, name); | |
222 | stream_class->name.value = stream_class->name.str->str; | |
223 | BT_LIB_LOGV("Set stream class's name: %!+S", stream_class); | |
224 | return 0; | |
5ca83563 JG |
225 | } |
226 | ||
7b33a0e0 | 227 | uint64_t bt_stream_class_get_id(struct bt_stream_class *stream_class) |
2f100782 | 228 | { |
18acc6f8 | 229 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); |
7b33a0e0 | 230 | return stream_class->id; |
2f100782 JG |
231 | } |
232 | ||
7b33a0e0 PP |
233 | uint64_t bt_stream_class_get_event_class_count( |
234 | struct bt_stream_class *stream_class) | |
29664b2a | 235 | { |
7b33a0e0 PP |
236 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); |
237 | return (uint64_t) stream_class->event_classes->len; | |
29664b2a PP |
238 | } |
239 | ||
7b33a0e0 PP |
240 | struct bt_event_class *bt_stream_class_borrow_event_class_by_index( |
241 | struct bt_stream_class *stream_class, uint64_t index) | |
0d23acbe | 242 | { |
7b33a0e0 PP |
243 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); |
244 | BT_ASSERT_PRE_VALID_INDEX(index, stream_class->event_classes->len); | |
245 | return g_ptr_array_index(stream_class->event_classes, index); | |
0d23acbe PP |
246 | } |
247 | ||
7b33a0e0 PP |
248 | struct bt_event_class *bt_stream_class_borrow_event_class_by_id( |
249 | struct bt_stream_class *trace, uint64_t id) | |
11b0cdc8 | 250 | { |
7b33a0e0 PP |
251 | struct bt_event_class *event_class = NULL; |
252 | uint64_t i; | |
0b9ce69f | 253 | |
7b33a0e0 | 254 | BT_ASSERT_PRE_NON_NULL(trace, "Trace"); |
11b0cdc8 | 255 | |
7b33a0e0 PP |
256 | for (i = 0; i < trace->event_classes->len; i++) { |
257 | struct bt_event_class *event_class_candidate = | |
258 | g_ptr_array_index(trace->event_classes, i); | |
e6a8e8e4 | 259 | |
7b33a0e0 PP |
260 | if (event_class_candidate->id == id) { |
261 | event_class = event_class_candidate; | |
09840de5 PP |
262 | goto end; |
263 | } | |
69dc4535 JG |
264 | } |
265 | ||
69dc4535 | 266 | end: |
7b33a0e0 | 267 | return event_class; |
0863f950 PP |
268 | } |
269 | ||
939190b3 | 270 | struct bt_field_class *bt_stream_class_borrow_packet_context_field_class( |
839d52a5 | 271 | struct bt_stream_class *stream_class) |
12c8a1a3 | 272 | { |
18acc6f8 | 273 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); |
939190b3 | 274 | return stream_class->packet_context_fc; |
12c8a1a3 JG |
275 | } |
276 | ||
939190b3 | 277 | int bt_stream_class_set_packet_context_field_class( |
839d52a5 | 278 | struct bt_stream_class *stream_class, |
939190b3 | 279 | struct bt_field_class *field_class) |
12c8a1a3 | 280 | { |
7b33a0e0 PP |
281 | int ret; |
282 | struct bt_resolve_field_path_context resolve_ctx = { | |
283 | .packet_header = NULL, | |
939190b3 | 284 | .packet_context = field_class, |
7b33a0e0 PP |
285 | .event_header = NULL, |
286 | .event_common_context = NULL, | |
287 | .event_specific_context = NULL, | |
288 | .event_payload = NULL, | |
289 | }; | |
18acc6f8 | 290 | |
7b33a0e0 | 291 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); |
939190b3 | 292 | BT_ASSERT_PRE_NON_NULL(field_class, "Field class"); |
7b33a0e0 | 293 | BT_ASSERT_PRE_STREAM_CLASS_HOT(stream_class); |
af0c18e3 PP |
294 | BT_ASSERT_PRE(bt_field_class_get_type(field_class) == |
295 | BT_FIELD_CLASS_TYPE_STRUCTURE, | |
939190b3 PP |
296 | "Packet context field classe is not a structure field classe: %!+F", |
297 | field_class); | |
7b33a0e0 | 298 | resolve_ctx.packet_header = |
939190b3 PP |
299 | bt_stream_class_borrow_trace_inline(stream_class)->packet_header_fc; |
300 | ret = bt_resolve_field_paths(field_class, &resolve_ctx); | |
7b33a0e0 | 301 | if (ret) { |
18acc6f8 PP |
302 | goto end; |
303 | } | |
304 | ||
939190b3 PP |
305 | bt_field_class_make_part_of_trace(field_class); |
306 | bt_put(stream_class->packet_context_fc); | |
307 | stream_class->packet_context_fc = bt_get(field_class); | |
308 | bt_field_class_freeze(field_class); | |
309 | BT_LIB_LOGV("Set stream class's packet context field classe: %!+S", | |
7b33a0e0 | 310 | stream_class); |
18acc6f8 PP |
311 | |
312 | end: | |
313 | return ret; | |
12c8a1a3 JG |
314 | } |
315 | ||
939190b3 | 316 | struct bt_field_class *bt_stream_class_borrow_event_header_field_class( |
839d52a5 | 317 | struct bt_stream_class *stream_class) |
662e778c | 318 | { |
18acc6f8 | 319 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); |
939190b3 | 320 | return stream_class->event_header_fc; |
662e778c JG |
321 | } |
322 | ||
939190b3 | 323 | int bt_stream_class_set_event_header_field_class( |
839d52a5 | 324 | struct bt_stream_class *stream_class, |
939190b3 | 325 | struct bt_field_class *field_class) |
662e778c | 326 | { |
7b33a0e0 PP |
327 | int ret; |
328 | struct bt_resolve_field_path_context resolve_ctx = { | |
329 | .packet_header = NULL, | |
330 | .packet_context = NULL, | |
939190b3 | 331 | .event_header = field_class, |
7b33a0e0 PP |
332 | .event_common_context = NULL, |
333 | .event_specific_context = NULL, | |
334 | .event_payload = NULL, | |
335 | }; | |
18acc6f8 | 336 | |
7b33a0e0 | 337 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); |
939190b3 | 338 | BT_ASSERT_PRE_NON_NULL(field_class, "Field class"); |
7b33a0e0 | 339 | BT_ASSERT_PRE_STREAM_CLASS_HOT(stream_class); |
af0c18e3 PP |
340 | BT_ASSERT_PRE(bt_field_class_get_type(field_class) == |
341 | BT_FIELD_CLASS_TYPE_STRUCTURE, | |
939190b3 PP |
342 | "Event header field classe is not a structure field classe: %!+F", |
343 | field_class); | |
7b33a0e0 | 344 | resolve_ctx.packet_header = |
939190b3 PP |
345 | bt_stream_class_borrow_trace_inline(stream_class)->packet_header_fc; |
346 | resolve_ctx.packet_context = stream_class->packet_context_fc; | |
347 | ret = bt_resolve_field_paths(field_class, &resolve_ctx); | |
7b33a0e0 | 348 | if (ret) { |
18acc6f8 PP |
349 | goto end; |
350 | } | |
351 | ||
939190b3 PP |
352 | bt_field_class_make_part_of_trace(field_class); |
353 | bt_put(stream_class->event_header_fc); | |
354 | stream_class->event_header_fc = bt_get(field_class); | |
355 | bt_field_class_freeze(field_class); | |
356 | BT_LIB_LOGV("Set stream class's event header field classe: %!+S", | |
7b33a0e0 | 357 | stream_class); |
18acc6f8 | 358 | |
18acc6f8 PP |
359 | end: |
360 | return ret; | |
662e778c JG |
361 | } |
362 | ||
939190b3 | 363 | struct bt_field_class *bt_stream_class_borrow_event_common_context_field_class( |
839d52a5 | 364 | struct bt_stream_class *stream_class) |
af181248 | 365 | { |
18acc6f8 | 366 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); |
939190b3 | 367 | return stream_class->event_common_context_fc; |
af181248 JG |
368 | } |
369 | ||
939190b3 | 370 | int bt_stream_class_set_event_common_context_field_class( |
839d52a5 | 371 | struct bt_stream_class *stream_class, |
939190b3 | 372 | struct bt_field_class *field_class) |
af181248 | 373 | { |
7b33a0e0 PP |
374 | int ret; |
375 | struct bt_resolve_field_path_context resolve_ctx = { | |
376 | .packet_header = NULL, | |
377 | .packet_context = NULL, | |
378 | .event_header = NULL, | |
939190b3 | 379 | .event_common_context = field_class, |
7b33a0e0 PP |
380 | .event_specific_context = NULL, |
381 | .event_payload = NULL, | |
382 | }; | |
18acc6f8 | 383 | |
7b33a0e0 | 384 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); |
939190b3 | 385 | BT_ASSERT_PRE_NON_NULL(field_class, "Field class"); |
7b33a0e0 | 386 | BT_ASSERT_PRE_STREAM_CLASS_HOT(stream_class); |
af0c18e3 PP |
387 | BT_ASSERT_PRE(bt_field_class_get_type(field_class) == |
388 | BT_FIELD_CLASS_TYPE_STRUCTURE, | |
939190b3 PP |
389 | "Event common context field classe is not a structure field classe: %!+F", |
390 | field_class); | |
7b33a0e0 | 391 | resolve_ctx.packet_header = |
939190b3 PP |
392 | bt_stream_class_borrow_trace_inline(stream_class)->packet_header_fc; |
393 | resolve_ctx.packet_context = stream_class->packet_context_fc; | |
394 | resolve_ctx.event_header = stream_class->event_header_fc; | |
395 | ret = bt_resolve_field_paths(field_class, &resolve_ctx); | |
7b33a0e0 | 396 | if (ret) { |
18acc6f8 PP |
397 | goto end; |
398 | } | |
399 | ||
939190b3 PP |
400 | bt_field_class_make_part_of_trace(field_class); |
401 | bt_put(stream_class->event_common_context_fc); | |
402 | stream_class->event_common_context_fc = bt_get(field_class); | |
403 | bt_field_class_freeze(field_class); | |
404 | BT_LIB_LOGV("Set stream class's event common context field classe: %!+S", | |
7b33a0e0 | 405 | stream_class); |
18acc6f8 | 406 | |
18acc6f8 PP |
407 | end: |
408 | return ret; | |
11b0cdc8 JG |
409 | } |
410 | ||
7b33a0e0 PP |
411 | BT_HIDDEN |
412 | void _bt_stream_class_freeze(struct bt_stream_class *stream_class) | |
8bf65fbd | 413 | { |
939190b3 | 414 | /* The field classes and default clock class are already frozen */ |
7b33a0e0 PP |
415 | BT_ASSERT(stream_class); |
416 | BT_LIB_LOGD("Freezing stream class: %!+S", stream_class); | |
417 | stream_class->frozen = true; | |
8bf65fbd JG |
418 | } |
419 | ||
7b33a0e0 PP |
420 | int bt_stream_class_set_default_clock_class( |
421 | struct bt_stream_class *stream_class, | |
422 | struct bt_clock_class *clock_class) | |
8bf65fbd | 423 | { |
7b33a0e0 PP |
424 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); |
425 | BT_ASSERT_PRE_NON_NULL(clock_class, "Clock class"); | |
426 | BT_ASSERT_PRE_STREAM_CLASS_HOT(stream_class); | |
427 | bt_put(stream_class->default_clock_class); | |
428 | stream_class->default_clock_class = bt_get(clock_class); | |
429 | bt_clock_class_freeze(clock_class); | |
430 | BT_LIB_LOGV("Set stream class's default clock class: %!+S", | |
431 | stream_class); | |
432 | return 0; | |
8bf65fbd JG |
433 | } |
434 | ||
7b33a0e0 PP |
435 | struct bt_clock_class *bt_stream_class_borrow_default_clock_class( |
436 | struct bt_stream_class *stream_class) | |
8bf65fbd | 437 | { |
7b33a0e0 PP |
438 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); |
439 | return stream_class->default_clock_class; | |
440 | } | |
8bf65fbd | 441 | |
7b33a0e0 PP |
442 | bt_bool bt_stream_class_assigns_automatic_event_class_id( |
443 | struct bt_stream_class *stream_class) | |
444 | { | |
445 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); | |
446 | return (bt_bool) stream_class->assigns_automatic_event_class_id; | |
8bf65fbd JG |
447 | } |
448 | ||
7b33a0e0 PP |
449 | int bt_stream_class_set_assigns_automatic_event_class_id( |
450 | struct bt_stream_class *stream_class, bt_bool value) | |
8bf65fbd | 451 | { |
7b33a0e0 PP |
452 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); |
453 | BT_ASSERT_PRE_STREAM_CLASS_HOT(stream_class); | |
454 | stream_class->assigns_automatic_event_class_id = (bool) value; | |
455 | BT_LIB_LOGV("Set stream class's automatic event class ID " | |
456 | "assignment property: %!+S", stream_class); | |
457 | return 0; | |
458 | } | |
8bf65fbd | 459 | |
7b33a0e0 PP |
460 | bt_bool bt_stream_class_assigns_automatic_stream_id( |
461 | struct bt_stream_class *stream_class) | |
462 | { | |
463 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); | |
464 | return (bt_bool) stream_class->assigns_automatic_stream_id; | |
465 | } | |
8bf65fbd | 466 | |
7b33a0e0 PP |
467 | int bt_stream_class_set_assigns_automatic_stream_id( |
468 | struct bt_stream_class *stream_class, bt_bool value) | |
469 | { | |
470 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); | |
471 | BT_ASSERT_PRE_STREAM_CLASS_HOT(stream_class); | |
472 | stream_class->assigns_automatic_stream_id = (bool) value; | |
473 | BT_LIB_LOGV("Set stream class's automatic stream ID " | |
474 | "assignment property: %!+S", stream_class); | |
475 | return 0; | |
476 | } | |
8deee039 | 477 | |
7b33a0e0 PP |
478 | bt_bool bt_stream_class_packets_have_discarded_event_counter_snapshot( |
479 | struct bt_stream_class *stream_class) | |
480 | { | |
481 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); | |
482 | return (bt_bool) stream_class->packets_have_discarded_event_counter_snapshot; | |
8bf65fbd JG |
483 | } |
484 | ||
7b33a0e0 PP |
485 | int bt_stream_class_set_packets_have_discarded_event_counter_snapshot( |
486 | struct bt_stream_class *stream_class, bt_bool value) | |
11b0cdc8 | 487 | { |
7b33a0e0 PP |
488 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); |
489 | BT_ASSERT_PRE_STREAM_CLASS_HOT(stream_class); | |
490 | stream_class->packets_have_discarded_event_counter_snapshot = | |
491 | (bool) value; | |
492 | BT_LIB_LOGV("Set stream class's " | |
493 | "\"packets have discarded event counter snapshot\" property: " | |
494 | "%!+S", stream_class); | |
495 | return 0; | |
496 | } | |
11b0cdc8 | 497 | |
7b33a0e0 PP |
498 | bt_bool bt_stream_class_packets_have_packet_counter_snapshot( |
499 | struct bt_stream_class *stream_class) | |
500 | { | |
501 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); | |
502 | return (bt_bool) stream_class->packets_have_packet_counter_snapshot; | |
11b0cdc8 JG |
503 | } |
504 | ||
7b33a0e0 PP |
505 | int bt_stream_class_set_packets_have_packet_counter_snapshot( |
506 | struct bt_stream_class *stream_class, bt_bool value) | |
8c4a29ba | 507 | { |
7b33a0e0 PP |
508 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); |
509 | BT_ASSERT_PRE_STREAM_CLASS_HOT(stream_class); | |
510 | stream_class->packets_have_packet_counter_snapshot = | |
511 | (bool) value; | |
512 | BT_LIB_LOGV("Set stream class's " | |
513 | "\"packets have packet counter snapshot\" property: " | |
514 | "%!+S", stream_class); | |
515 | return 0; | |
516 | } | |
8c4a29ba | 517 | |
7b33a0e0 PP |
518 | bt_bool bt_stream_class_packets_have_default_beginning_clock_value( |
519 | struct bt_stream_class *stream_class) | |
520 | { | |
521 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); | |
522 | return (bt_bool) stream_class->packets_have_default_beginning_cv; | |
523 | } | |
8c4a29ba | 524 | |
7b33a0e0 PP |
525 | int bt_stream_class_set_packets_have_default_beginning_clock_value( |
526 | struct bt_stream_class *stream_class, bt_bool value) | |
527 | { | |
528 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); | |
529 | BT_ASSERT_PRE_STREAM_CLASS_HOT(stream_class); | |
530 | BT_ASSERT_PRE(!value || stream_class->default_clock_class, | |
531 | "Stream class does not have a default clock class: %!+S", | |
532 | stream_class); | |
533 | stream_class->packets_have_default_beginning_cv = (bool) value; | |
534 | BT_LIB_LOGV("Set stream class's " | |
535 | "\"packets have default beginning clock value\" property: " | |
536 | "%!+S", stream_class); | |
537 | return 0; | |
538 | } | |
8c4a29ba | 539 | |
7b33a0e0 PP |
540 | bt_bool bt_stream_class_packets_have_default_end_clock_value( |
541 | struct bt_stream_class *stream_class) | |
542 | { | |
543 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); | |
544 | return (bt_bool) stream_class->packets_have_default_end_cv; | |
545 | } | |
8c4a29ba | 546 | |
7b33a0e0 PP |
547 | int bt_stream_class_set_packets_have_default_end_clock_value( |
548 | struct bt_stream_class *stream_class, bt_bool value) | |
549 | { | |
550 | BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class"); | |
551 | BT_ASSERT_PRE_STREAM_CLASS_HOT(stream_class); | |
552 | BT_ASSERT_PRE(!value || stream_class->default_clock_class, | |
553 | "Stream class does not have a default clock class: %!+S", | |
554 | stream_class); | |
555 | stream_class->packets_have_default_end_cv = (bool) value; | |
556 | BT_LIB_LOGV("Set stream class's " | |
557 | "\"packets have default end clock value\" property: " | |
558 | "%!+S", stream_class); | |
559 | return 0; | |
560 | } | |
8c4a29ba | 561 | |
7b33a0e0 PP |
562 | bt_bool bt_stream_class_default_clock_is_always_known( |
563 | struct bt_stream_class *stream_class) | |
564 | { | |
565 | /* BT_CLOCK_VALUE_STATUS_UNKNOWN is not supported as of 2.0 */ | |
566 | return BT_TRUE; | |
8c4a29ba | 567 | } |