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