lib: remove unused includes
[babeltrace.git] / src / lib / trace-ir / stream-class.c
... / ...
CommitLineData
1/*
2 * SPDX-License-Identifier: MIT
3 *
4 * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
5 * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 */
7
8#define BT_LOG_TAG "LIB/STREAM-CLASS"
9#include "lib/logging.h"
10
11#include "lib/assert-cond.h"
12#include <babeltrace2/trace-ir/trace.h>
13#include "compat/compiler.h"
14#include "compat/endian.h"
15#include "common/assert.h"
16#include <inttypes.h>
17#include <stdint.h>
18#include <stdbool.h>
19
20#include "clock-class.h"
21#include "event-class.h"
22#include "field-class.h"
23#include "field-wrapper.h"
24#include "resolve-field-path.h"
25#include "stream-class.h"
26#include "lib/value.h"
27#include "lib/func-status.h"
28
29#define BT_ASSERT_PRE_DEV_STREAM_CLASS_HOT(_sc) \
30 BT_ASSERT_PRE_DEV_HOT("stream-class", (_sc), "Stream class", \
31 ": %!+S", (_sc))
32
33static
34void destroy_stream_class(struct bt_object *obj)
35{
36 struct bt_stream_class *stream_class = (void *) obj;
37
38 BT_LIB_LOGD("Destroying stream class: %!+S", stream_class);
39 BT_LOGD_STR("Putting default clock class.");
40 BT_OBJECT_PUT_REF_AND_RESET(stream_class->user_attributes);
41 BT_OBJECT_PUT_REF_AND_RESET(stream_class->default_clock_class);
42
43 if (stream_class->event_classes) {
44 BT_LOGD_STR("Destroying event classes.");
45 g_ptr_array_free(stream_class->event_classes, TRUE);
46 stream_class->event_classes = NULL;
47 }
48
49 if (stream_class->name.str) {
50 g_string_free(stream_class->name.str, TRUE);
51 stream_class->name.str = NULL;
52 stream_class->name.value = NULL;
53 }
54
55 BT_LOGD_STR("Putting packet context field class.");
56 BT_OBJECT_PUT_REF_AND_RESET(stream_class->packet_context_fc);
57 BT_LOGD_STR("Putting event common context field class.");
58 BT_OBJECT_PUT_REF_AND_RESET(stream_class->event_common_context_fc);
59 bt_object_pool_finalize(&stream_class->packet_context_field_pool);
60 g_free(stream_class);
61}
62
63static
64void free_field_wrapper(struct bt_field_wrapper *field_wrapper,
65 struct bt_stream_class *stream_class __attribute__((unused)))
66{
67 bt_field_wrapper_destroy((void *) field_wrapper);
68}
69
70static
71bool stream_class_id_is_unique(const struct bt_trace_class *tc, uint64_t id)
72{
73 uint64_t i;
74 bool is_unique = true;
75
76 for (i = 0; i < tc->stream_classes->len; i++) {
77 const struct bt_stream_class *sc =
78 tc->stream_classes->pdata[i];
79
80 if (sc->id == id) {
81 is_unique = false;
82 goto end;
83 }
84 }
85
86end:
87 return is_unique;
88}
89
90static
91struct bt_stream_class *create_stream_class_with_id(
92 struct bt_trace_class *tc, uint64_t id)
93{
94 struct bt_stream_class *stream_class = NULL;
95 int ret;
96
97 BT_ASSERT(tc);
98 BT_ASSERT_PRE("stream-class-id-is-unique",
99 stream_class_id_is_unique(tc, id),
100 "Duplicate stream class ID: %![tc-]+T, id=%" PRIu64, tc, id);
101 BT_LIB_LOGD("Creating stream class object: %![tc-]+T, id=%" PRIu64,
102 tc, id);
103 stream_class = g_new0(struct bt_stream_class, 1);
104 if (!stream_class) {
105 BT_LIB_LOGE_APPEND_CAUSE(
106 "Failed to allocate one stream class.");
107 goto error;
108 }
109
110 bt_object_init_shared_with_parent(&stream_class->base,
111 destroy_stream_class);
112 stream_class->user_attributes = bt_value_map_create();
113 if (!stream_class->user_attributes) {
114 BT_LIB_LOGE_APPEND_CAUSE(
115 "Failed to create a map value object.");
116 goto error;
117 }
118
119 stream_class->name.str = g_string_new(NULL);
120 if (!stream_class->name.str) {
121 BT_LIB_LOGE_APPEND_CAUSE("Failed to allocate a GString.");
122 goto error;
123 }
124
125 stream_class->id = id;
126 stream_class->assigns_automatic_event_class_id = true;
127 stream_class->assigns_automatic_stream_id = true;
128 stream_class->event_classes = g_ptr_array_new_with_free_func(
129 (GDestroyNotify) bt_object_try_spec_release);
130 if (!stream_class->event_classes) {
131 BT_LIB_LOGE_APPEND_CAUSE("Failed to allocate a GPtrArray.");
132 goto error;
133 }
134
135 ret = bt_object_pool_initialize(&stream_class->packet_context_field_pool,
136 (bt_object_pool_new_object_func) bt_field_wrapper_new,
137 (bt_object_pool_destroy_object_func) free_field_wrapper,
138 stream_class);
139 if (ret) {
140 BT_LIB_LOGE_APPEND_CAUSE(
141 "Failed to initialize packet context field pool: ret=%d",
142 ret);
143 goto error;
144 }
145
146 bt_object_set_parent(&stream_class->base, &tc->base);
147 g_ptr_array_add(tc->stream_classes, stream_class);
148 bt_trace_class_freeze(tc);
149 BT_LIB_LOGD("Created stream class object: %!+S", stream_class);
150 goto end;
151
152error:
153 BT_OBJECT_PUT_REF_AND_RESET(stream_class);
154
155end:
156 return stream_class;
157}
158
159BT_EXPORT
160struct bt_stream_class *bt_stream_class_create(struct bt_trace_class *tc)
161{
162 BT_ASSERT_PRE_NO_ERROR();
163 BT_ASSERT_PRE_TC_NON_NULL(tc);
164 BT_ASSERT_PRE("trace-class-automatically-assigns-stream-class-ids",
165 tc->assigns_automatic_stream_class_id,
166 "Trace class does not automatically assigns stream class IDs: "
167 "%![sc-]+T", tc);
168 return create_stream_class_with_id(tc,
169 (uint64_t) tc->stream_classes->len);
170}
171
172BT_EXPORT
173struct bt_stream_class *bt_stream_class_create_with_id(
174 struct bt_trace_class *tc, uint64_t id)
175{
176 BT_ASSERT_PRE_NO_ERROR();
177 BT_ASSERT_PRE_TC_NON_NULL(tc);
178 BT_ASSERT_PRE(
179 "trace-class-does-not-automatically-assigns-stream-class-ids",
180 !tc->assigns_automatic_stream_class_id,
181 "Trace class automatically assigns stream class IDs: "
182 "%![sc-]+T", tc);
183 return create_stream_class_with_id(tc, id);
184}
185
186BT_EXPORT
187struct bt_trace_class *bt_stream_class_borrow_trace_class(
188 struct bt_stream_class *stream_class)
189{
190 BT_ASSERT_PRE_DEV_SC_NON_NULL(stream_class);
191 return bt_stream_class_borrow_trace_class_inline(stream_class);
192}
193
194BT_EXPORT
195const struct bt_trace_class *bt_stream_class_borrow_trace_class_const(
196 const struct bt_stream_class *stream_class)
197{
198 return bt_stream_class_borrow_trace_class((void *) stream_class);
199}
200
201BT_EXPORT
202const char *bt_stream_class_get_name(const struct bt_stream_class *stream_class)
203{
204 BT_ASSERT_PRE_DEV_SC_NON_NULL(stream_class);
205 return stream_class->name.value;
206}
207
208BT_EXPORT
209enum bt_stream_class_set_name_status bt_stream_class_set_name(
210 struct bt_stream_class *stream_class,
211 const char *name)
212{
213 BT_ASSERT_PRE_NO_ERROR();
214 BT_ASSERT_PRE_SC_NON_NULL(stream_class);
215 BT_ASSERT_PRE_NAME_NON_NULL(name);
216 BT_ASSERT_PRE_DEV_STREAM_CLASS_HOT(stream_class);
217 g_string_assign(stream_class->name.str, name);
218 stream_class->name.value = stream_class->name.str->str;
219 BT_LIB_LOGD("Set stream class's name: %!+S", stream_class);
220 return BT_FUNC_STATUS_OK;
221}
222
223BT_EXPORT
224uint64_t bt_stream_class_get_id(const struct bt_stream_class *stream_class)
225{
226 BT_ASSERT_PRE_DEV_SC_NON_NULL(stream_class);
227 return stream_class->id;
228}
229
230BT_EXPORT
231uint64_t bt_stream_class_get_event_class_count(
232 const struct bt_stream_class *stream_class)
233{
234 BT_ASSERT_PRE_DEV_SC_NON_NULL(stream_class);
235 return (uint64_t) stream_class->event_classes->len;
236}
237
238BT_EXPORT
239struct bt_event_class *bt_stream_class_borrow_event_class_by_index(
240 struct bt_stream_class *stream_class, uint64_t index)
241{
242 BT_ASSERT_PRE_DEV_SC_NON_NULL(stream_class);
243 BT_ASSERT_PRE_DEV_VALID_INDEX(index, stream_class->event_classes->len);
244 return g_ptr_array_index(stream_class->event_classes, index);
245}
246
247BT_EXPORT
248const struct bt_event_class *
249bt_stream_class_borrow_event_class_by_index_const(
250 const struct bt_stream_class *stream_class, uint64_t index)
251{
252 return bt_stream_class_borrow_event_class_by_index(
253 (void *) stream_class, index);
254}
255
256BT_EXPORT
257struct bt_event_class *bt_stream_class_borrow_event_class_by_id(
258 struct bt_stream_class *stream_class, uint64_t id)
259{
260 struct bt_event_class *event_class = NULL;
261 uint64_t i;
262
263 BT_ASSERT_PRE_DEV_SC_NON_NULL(stream_class);
264
265 for (i = 0; i < stream_class->event_classes->len; i++) {
266 struct bt_event_class *event_class_candidate =
267 g_ptr_array_index(stream_class->event_classes, i);
268
269 if (event_class_candidate->id == id) {
270 event_class = event_class_candidate;
271 goto end;
272 }
273 }
274
275end:
276 return event_class;
277}
278
279BT_EXPORT
280const struct bt_event_class *
281bt_stream_class_borrow_event_class_by_id_const(
282 const struct bt_stream_class *stream_class, uint64_t id)
283{
284 return bt_stream_class_borrow_event_class_by_id(
285 (void *) stream_class, id);
286}
287
288BT_EXPORT
289const struct bt_field_class *
290bt_stream_class_borrow_packet_context_field_class_const(
291 const struct bt_stream_class *stream_class)
292{
293 BT_ASSERT_PRE_DEV_SC_NON_NULL(stream_class);
294 return stream_class->packet_context_fc;
295}
296
297BT_EXPORT
298struct bt_field_class *
299bt_stream_class_borrow_packet_context_field_class(
300 struct bt_stream_class *stream_class)
301{
302 BT_ASSERT_PRE_DEV_SC_NON_NULL(stream_class);
303 return stream_class->packet_context_fc;
304}
305
306BT_EXPORT
307enum bt_stream_class_set_field_class_status
308bt_stream_class_set_packet_context_field_class(
309 struct bt_stream_class *stream_class,
310 struct bt_field_class *field_class)
311{
312 int ret;
313 struct bt_resolve_field_path_context resolve_ctx = {
314 .packet_context = field_class,
315 .event_common_context = NULL,
316 .event_specific_context = NULL,
317 .event_payload = NULL,
318 };
319
320 BT_ASSERT_PRE_NO_ERROR();
321 BT_ASSERT_PRE_SC_NON_NULL(stream_class);
322 BT_ASSERT_PRE("supports-packets",
323 stream_class->supports_packets,
324 "Stream class does not support packets: %![sc-]+S",
325 stream_class);
326 BT_ASSERT_PRE_FC_NON_NULL(field_class);
327 BT_ASSERT_PRE_DEV_STREAM_CLASS_HOT(stream_class);
328 BT_ASSERT_PRE_FC_IS_STRUCT("field-class", field_class,
329 "Packet context field class");
330 ret = bt_resolve_field_paths(field_class, &resolve_ctx, __func__);
331 if (ret) {
332 /*
333 * This is the only reason for which
334 * bt_resolve_field_paths() can fail: anything else
335 * would be because a precondition is not satisfied.
336 */
337 ret = BT_FUNC_STATUS_MEMORY_ERROR;
338 goto end;
339 }
340
341 bt_field_class_make_part_of_trace_class(field_class);
342 bt_object_put_ref(stream_class->packet_context_fc);
343 stream_class->packet_context_fc = field_class;
344 bt_object_get_ref_no_null_check(stream_class->packet_context_fc);
345 bt_field_class_freeze(field_class);
346 BT_LIB_LOGD("Set stream class's packet context field class: %!+S",
347 stream_class);
348
349end:
350 return ret;
351}
352
353BT_EXPORT
354const struct bt_field_class *
355bt_stream_class_borrow_event_common_context_field_class_const(
356 const struct bt_stream_class *stream_class)
357{
358 BT_ASSERT_PRE_DEV_SC_NON_NULL(stream_class);
359 return stream_class->event_common_context_fc;
360}
361
362BT_EXPORT
363struct bt_field_class *
364bt_stream_class_borrow_event_common_context_field_class(
365 struct bt_stream_class *stream_class)
366{
367 BT_ASSERT_PRE_DEV_SC_NON_NULL(stream_class);
368 return stream_class->event_common_context_fc;
369}
370
371BT_EXPORT
372enum bt_stream_class_set_field_class_status
373bt_stream_class_set_event_common_context_field_class(
374 struct bt_stream_class *stream_class,
375 struct bt_field_class *field_class)
376{
377 int ret;
378 struct bt_resolve_field_path_context resolve_ctx = {
379 .packet_context = NULL,
380 .event_common_context = field_class,
381 .event_specific_context = NULL,
382 .event_payload = NULL,
383 };
384
385 BT_ASSERT_PRE_NO_ERROR();
386 BT_ASSERT_PRE_SC_NON_NULL(stream_class);
387 BT_ASSERT_PRE_FC_NON_NULL(field_class);
388 BT_ASSERT_PRE_DEV_STREAM_CLASS_HOT(stream_class);
389 BT_ASSERT_PRE_FC_IS_STRUCT("field-class", field_class,
390 "Event common context field class");
391 resolve_ctx.packet_context = stream_class->packet_context_fc;
392 ret = bt_resolve_field_paths(field_class, &resolve_ctx, __func__);
393 if (ret) {
394 /*
395 * This is the only reason for which
396 * bt_resolve_field_paths() can fail: anything else
397 * would be because a precondition is not satisfied.
398 */
399 ret = BT_FUNC_STATUS_MEMORY_ERROR;
400 goto end;
401 }
402
403 bt_field_class_make_part_of_trace_class(field_class);
404 bt_object_put_ref(stream_class->event_common_context_fc);
405 stream_class->event_common_context_fc = field_class;
406 bt_object_get_ref_no_null_check(stream_class->event_common_context_fc);
407 bt_field_class_freeze(field_class);
408 BT_LIB_LOGD("Set stream class's event common context field class: %!+S",
409 stream_class);
410
411end:
412 return ret;
413}
414
415void _bt_stream_class_freeze(const struct bt_stream_class *stream_class)
416{
417 /* The field classes and default clock class are already frozen */
418 BT_ASSERT(stream_class);
419 BT_LIB_LOGD("Freezing stream class's user attributes: %!+v",
420 stream_class->user_attributes);
421 bt_value_freeze(stream_class->user_attributes);
422 BT_LIB_LOGD("Freezing stream class: %!+S", stream_class);
423 ((struct bt_stream_class *) stream_class)->frozen = true;
424}
425
426BT_EXPORT
427enum bt_stream_class_set_default_clock_class_status
428bt_stream_class_set_default_clock_class(
429 struct bt_stream_class *stream_class,
430 struct bt_clock_class *clock_class)
431{
432 BT_ASSERT_PRE_NO_ERROR();
433 BT_ASSERT_PRE_SC_NON_NULL(stream_class);
434 BT_ASSERT_PRE_CLK_CLS_NON_NULL(clock_class);
435 BT_ASSERT_PRE_DEV_STREAM_CLASS_HOT(stream_class);
436 bt_object_put_ref(stream_class->default_clock_class);
437 stream_class->default_clock_class = clock_class;
438 bt_object_get_ref_no_null_check(stream_class->default_clock_class);
439 bt_clock_class_freeze(clock_class);
440 BT_LIB_LOGD("Set stream class's default clock class: %!+S",
441 stream_class);
442 return BT_FUNC_STATUS_OK;
443}
444
445BT_EXPORT
446struct bt_clock_class *bt_stream_class_borrow_default_clock_class(
447 struct bt_stream_class *stream_class)
448{
449 BT_ASSERT_PRE_DEV_SC_NON_NULL(stream_class);
450 return stream_class->default_clock_class;
451}
452
453BT_EXPORT
454const struct bt_clock_class *bt_stream_class_borrow_default_clock_class_const(
455 const struct bt_stream_class *stream_class)
456{
457 BT_ASSERT_PRE_DEV_SC_NON_NULL(stream_class);
458 return stream_class->default_clock_class;
459}
460
461BT_EXPORT
462bt_bool bt_stream_class_assigns_automatic_event_class_id(
463 const struct bt_stream_class *stream_class)
464{
465 BT_ASSERT_PRE_DEV_SC_NON_NULL(stream_class);
466 return (bt_bool) stream_class->assigns_automatic_event_class_id;
467}
468
469BT_EXPORT
470void bt_stream_class_set_assigns_automatic_event_class_id(
471 struct bt_stream_class *stream_class,
472 bt_bool value)
473{
474 BT_ASSERT_PRE_SC_NON_NULL(stream_class);
475 BT_ASSERT_PRE_DEV_STREAM_CLASS_HOT(stream_class);
476 stream_class->assigns_automatic_event_class_id = (bool) value;
477 BT_LIB_LOGD("Set stream class's automatic event class ID "
478 "assignment property: %!+S", stream_class);
479}
480
481BT_EXPORT
482bt_bool bt_stream_class_assigns_automatic_stream_id(
483 const struct bt_stream_class *stream_class)
484{
485 BT_ASSERT_PRE_DEV_SC_NON_NULL(stream_class);
486 return (bt_bool) stream_class->assigns_automatic_stream_id;
487}
488
489BT_EXPORT
490void bt_stream_class_set_supports_discarded_events(
491 struct bt_stream_class *stream_class,
492 bt_bool supports_discarded_events,
493 bt_bool with_default_clock_snapshots)
494{
495 BT_ASSERT_PRE_SC_NON_NULL(stream_class);
496 BT_ASSERT_PRE_DEV_STREAM_CLASS_HOT(stream_class);
497 BT_ASSERT_PRE("supports-discarded-events-for-default-clock-snapshots",
498 supports_discarded_events ||
499 !with_default_clock_snapshots,
500 "Discarded events cannot have default clock snapshots when "
501 "not supported: %!+S", stream_class);
502 BT_ASSERT_PRE("has-default-clock-class-for-default-clock-snapshots",
503 !with_default_clock_snapshots ||
504 stream_class->default_clock_class,
505 "Stream class has no default clock class: %!+S", stream_class);
506 stream_class->supports_discarded_events =
507 (bool) supports_discarded_events;
508 stream_class->discarded_events_have_default_clock_snapshots =
509 (bool) with_default_clock_snapshots;
510 BT_LIB_LOGD("Set stream class's discarded events support property: "
511 "%!+S", stream_class);
512}
513
514BT_EXPORT
515bt_bool bt_stream_class_supports_discarded_events(
516 const struct bt_stream_class *stream_class)
517{
518 BT_ASSERT_PRE_DEV_SC_NON_NULL(stream_class);
519 return (bt_bool) stream_class->supports_discarded_events;
520}
521
522BT_EXPORT
523bt_bool bt_stream_class_discarded_events_have_default_clock_snapshots(
524 const struct bt_stream_class *stream_class)
525{
526 BT_ASSERT_PRE_DEV_SC_NON_NULL(stream_class);
527 return (bt_bool) stream_class->discarded_events_have_default_clock_snapshots;
528}
529
530BT_EXPORT
531void bt_stream_class_set_supports_discarded_packets(
532 struct bt_stream_class *stream_class,
533 bt_bool supports_discarded_packets,
534 bt_bool with_default_clock_snapshots)
535{
536 BT_ASSERT_PRE_SC_NON_NULL(stream_class);
537 BT_ASSERT_PRE_DEV_STREAM_CLASS_HOT(stream_class);
538 BT_ASSERT_PRE("supports-packets-for-discarded-packets-support",
539 !supports_discarded_packets ||
540 stream_class->supports_packets,
541 "Stream class does not support packets: %!+S",
542 stream_class);
543 BT_ASSERT_PRE("supports-discarded-packets-for-default-clock-snapshots",
544 supports_discarded_packets ||
545 !with_default_clock_snapshots,
546 "Discarded packets cannot have default clock snapshots when "
547 "not supported: %!+S", stream_class);
548 BT_ASSERT_PRE("has-default-clock-class-for-default-clock-snapshots",
549 !with_default_clock_snapshots ||
550 stream_class->default_clock_class,
551 "Stream class has no default clock class: %!+S", stream_class);
552 stream_class->supports_discarded_packets =
553 (bool) supports_discarded_packets;
554 stream_class->discarded_packets_have_default_clock_snapshots =
555 (bool) with_default_clock_snapshots;
556 BT_LIB_LOGD("Set stream class's discarded packets support property: "
557 "%!+S", stream_class);
558}
559
560BT_EXPORT
561bt_bool bt_stream_class_supports_discarded_packets(
562 const struct bt_stream_class *stream_class)
563{
564 BT_ASSERT_PRE_DEV_SC_NON_NULL(stream_class);
565 return (bt_bool) stream_class->supports_discarded_packets;
566}
567
568BT_EXPORT
569bt_bool bt_stream_class_discarded_packets_have_default_clock_snapshots(
570 const struct bt_stream_class *stream_class)
571{
572 BT_ASSERT_PRE_DEV_SC_NON_NULL(stream_class);
573 return (bt_bool) stream_class->discarded_packets_have_default_clock_snapshots;
574}
575
576BT_EXPORT
577void bt_stream_class_set_supports_packets(
578 struct bt_stream_class *stream_class,
579 bt_bool supports_packets,
580 bt_bool with_beginning_default_clock_snapshot,
581 bt_bool with_end_default_clock_snapshot)
582{
583 bt_bool with_default_clock_snapshot =
584 with_beginning_default_clock_snapshot ||
585 with_end_default_clock_snapshot;
586 BT_ASSERT_PRE_SC_NON_NULL(stream_class);
587 BT_ASSERT_PRE_DEV_STREAM_CLASS_HOT(stream_class);
588 BT_ASSERT_PRE("supports-packets-for-default-clock-snapshot",
589 supports_packets ||
590 !with_default_clock_snapshot,
591 "Packets cannot have default clock snapshots when "
592 "not supported: %!+S", stream_class);
593 BT_ASSERT_PRE("has-default-clock-class-for-default-clock-snapshot",
594 !with_default_clock_snapshot ||
595 stream_class->default_clock_class,
596 "Stream class has no default clock class: %!+S", stream_class);
597 BT_ASSERT_PRE("supports-packets-for-packet-context-field-class",
598 supports_packets || !stream_class->packet_context_fc,
599 "Stream class already has a packet context field class: %!+S",
600 stream_class);
601 BT_ASSERT_PRE("supports-packets-for-discarded-packets-support",
602 supports_packets || !stream_class->supports_discarded_packets,
603 "Stream class already supports discarded packets: %!+S",
604 stream_class);
605 stream_class->supports_packets = (bool) supports_packets;
606 stream_class->packets_have_beginning_default_clock_snapshot =
607 (bool) with_beginning_default_clock_snapshot;
608 stream_class->packets_have_end_default_clock_snapshot =
609 (bool) with_end_default_clock_snapshot;
610 BT_LIB_LOGD("Set stream class's packets support property: %!+S",
611 stream_class);
612}
613
614BT_EXPORT
615bt_bool bt_stream_class_supports_packets(
616 const struct bt_stream_class *stream_class)
617{
618 BT_ASSERT_PRE_SC_NON_NULL(stream_class);
619 return (bt_bool) stream_class->supports_packets;
620}
621
622BT_EXPORT
623bt_bool bt_stream_class_packets_have_beginning_default_clock_snapshot(
624 const struct bt_stream_class *stream_class)
625{
626 BT_ASSERT_PRE_DEV_SC_NON_NULL(stream_class);
627 return (bt_bool) stream_class->packets_have_beginning_default_clock_snapshot;
628}
629
630BT_EXPORT
631bt_bool bt_stream_class_packets_have_end_default_clock_snapshot(
632 const struct bt_stream_class *stream_class)
633{
634 BT_ASSERT_PRE_DEV_SC_NON_NULL(stream_class);
635 return (bt_bool) stream_class->packets_have_end_default_clock_snapshot;
636}
637
638BT_EXPORT
639void bt_stream_class_set_assigns_automatic_stream_id(
640 struct bt_stream_class *stream_class,
641 bt_bool value)
642{
643 BT_ASSERT_PRE_SC_NON_NULL(stream_class);
644 BT_ASSERT_PRE_DEV_STREAM_CLASS_HOT(stream_class);
645 stream_class->assigns_automatic_stream_id = (bool) value;
646 BT_LIB_LOGD("Set stream class's automatic stream ID "
647 "assignment property: %!+S", stream_class);
648}
649
650BT_EXPORT
651const struct bt_value *bt_stream_class_borrow_user_attributes_const(
652 const struct bt_stream_class *stream_class)
653{
654 BT_ASSERT_PRE_DEV_SC_NON_NULL(stream_class);
655 return stream_class->user_attributes;
656}
657
658BT_EXPORT
659struct bt_value *bt_stream_class_borrow_user_attributes(
660 struct bt_stream_class *stream_class)
661{
662 return (void *) bt_stream_class_borrow_user_attributes_const(
663 (void *) stream_class);
664}
665
666BT_EXPORT
667void bt_stream_class_set_user_attributes(
668 struct bt_stream_class *stream_class,
669 const struct bt_value *user_attributes)
670{
671 BT_ASSERT_PRE_SC_NON_NULL(stream_class);
672 BT_ASSERT_PRE_USER_ATTRS_NON_NULL(user_attributes);
673 BT_ASSERT_PRE_USER_ATTRS_IS_MAP(user_attributes);
674 BT_ASSERT_PRE_DEV_STREAM_CLASS_HOT(stream_class);
675 bt_object_put_ref_no_null_check(stream_class->user_attributes);
676 stream_class->user_attributes = (void *) user_attributes;
677 bt_object_get_ref_no_null_check(stream_class->user_attributes);
678}
679
680BT_EXPORT
681void bt_stream_class_get_ref(const struct bt_stream_class *stream_class)
682{
683 bt_object_get_ref(stream_class);
684}
685
686BT_EXPORT
687void bt_stream_class_put_ref(const struct bt_stream_class *stream_class)
688{
689 bt_object_put_ref(stream_class);
690}
This page took 0.037995 seconds and 4 git commands to generate.