2 * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
3 * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to deal
7 * in the Software without restriction, including without limitation the rights
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 * copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 #define BT_LOG_TAG "LIB/STREAM-CLASS"
25 #include "lib/logging.h"
27 #include "lib/assert-pre.h"
28 #include <babeltrace2/trace-ir/trace-const.h>
29 #include "compat/compiler.h"
30 #include "common/align.h"
31 #include "compat/endian.h"
32 #include "common/assert.h"
33 #include "lib/property.h"
38 #include "clock-class.h"
39 #include "event-class.h"
40 #include "field-class.h"
42 #include "field-wrapper.h"
43 #include "resolve-field-path.h"
44 #include "stream-class.h"
47 #include "lib/value.h"
48 #include "lib/func-status.h"
50 #define BT_ASSERT_PRE_DEV_STREAM_CLASS_HOT(_sc) \
51 BT_ASSERT_PRE_DEV_HOT((_sc), "Stream class", ": %!+S", (_sc))
54 void destroy_stream_class(struct bt_object
*obj
)
56 struct bt_stream_class
*stream_class
= (void *) obj
;
58 BT_LIB_LOGD("Destroying stream class: %!+S", stream_class
);
59 BT_LOGD_STR("Putting default clock class.");
60 BT_OBJECT_PUT_REF_AND_RESET(stream_class
->user_attributes
);
61 BT_OBJECT_PUT_REF_AND_RESET(stream_class
->default_clock_class
);
63 if (stream_class
->event_classes
) {
64 BT_LOGD_STR("Destroying event classes.");
65 g_ptr_array_free(stream_class
->event_classes
, TRUE
);
66 stream_class
->event_classes
= NULL
;
69 if (stream_class
->name
.str
) {
70 g_string_free(stream_class
->name
.str
, TRUE
);
71 stream_class
->name
.str
= NULL
;
72 stream_class
->name
.value
= NULL
;
75 BT_LOGD_STR("Putting packet context field class.");
76 BT_OBJECT_PUT_REF_AND_RESET(stream_class
->packet_context_fc
);
77 BT_LOGD_STR("Putting event common context field class.");
78 BT_OBJECT_PUT_REF_AND_RESET(stream_class
->event_common_context_fc
);
79 bt_object_pool_finalize(&stream_class
->packet_context_field_pool
);
84 void free_field_wrapper(struct bt_field_wrapper
*field_wrapper
,
85 struct bt_stream_class
*stream_class
)
87 bt_field_wrapper_destroy((void *) field_wrapper
);
91 bool stream_class_id_is_unique(const struct bt_trace_class
*tc
, uint64_t id
)
94 bool is_unique
= true;
96 for (i
= 0; i
< tc
->stream_classes
->len
; i
++) {
97 const struct bt_stream_class
*sc
=
98 tc
->stream_classes
->pdata
[i
];
111 struct bt_stream_class
*create_stream_class_with_id(
112 struct bt_trace_class
*tc
, uint64_t id
)
114 struct bt_stream_class
*stream_class
= NULL
;
118 BT_ASSERT_PRE(stream_class_id_is_unique(tc
, id
),
119 "Duplicate stream class ID: %![tc-]+T, id=%" PRIu64
, tc
, id
);
120 BT_LIB_LOGD("Creating stream class object: %![tc-]+T, id=%" PRIu64
,
122 stream_class
= g_new0(struct bt_stream_class
, 1);
124 BT_LIB_LOGE_APPEND_CAUSE(
125 "Failed to allocate one stream class.");
129 bt_object_init_shared_with_parent(&stream_class
->base
,
130 destroy_stream_class
);
131 stream_class
->user_attributes
= bt_value_map_create();
132 if (!stream_class
->user_attributes
) {
133 BT_LIB_LOGE_APPEND_CAUSE(
134 "Failed to create a map value object.");
138 stream_class
->name
.str
= g_string_new(NULL
);
139 if (!stream_class
->name
.str
) {
140 BT_LIB_LOGE_APPEND_CAUSE("Failed to allocate a GString.");
144 stream_class
->id
= id
;
145 stream_class
->assigns_automatic_event_class_id
= true;
146 stream_class
->assigns_automatic_stream_id
= true;
147 stream_class
->event_classes
= g_ptr_array_new_with_free_func(
148 (GDestroyNotify
) bt_object_try_spec_release
);
149 if (!stream_class
->event_classes
) {
150 BT_LIB_LOGE_APPEND_CAUSE("Failed to allocate a GPtrArray.");
154 ret
= bt_object_pool_initialize(&stream_class
->packet_context_field_pool
,
155 (bt_object_pool_new_object_func
) bt_field_wrapper_new
,
156 (bt_object_pool_destroy_object_func
) free_field_wrapper
,
159 BT_LIB_LOGE_APPEND_CAUSE(
160 "Failed to initialize packet context field pool: ret=%d",
165 bt_object_set_parent(&stream_class
->base
, &tc
->base
);
166 g_ptr_array_add(tc
->stream_classes
, stream_class
);
167 bt_trace_class_freeze(tc
);
168 BT_LIB_LOGD("Created stream class object: %!+S", stream_class
);
172 BT_OBJECT_PUT_REF_AND_RESET(stream_class
);
178 struct bt_stream_class
*bt_stream_class_create(struct bt_trace_class
*tc
)
180 BT_ASSERT_PRE_NON_NULL(tc
, "Trace class");
181 BT_ASSERT_PRE(tc
->assigns_automatic_stream_class_id
,
182 "Trace class does not automatically assigns stream class IDs: "
184 return create_stream_class_with_id(tc
,
185 (uint64_t) tc
->stream_classes
->len
);
188 struct bt_stream_class
*bt_stream_class_create_with_id(
189 struct bt_trace_class
*tc
, uint64_t id
)
191 BT_ASSERT_PRE_NON_NULL(tc
, "Trace class");
192 BT_ASSERT_PRE(!tc
->assigns_automatic_stream_class_id
,
193 "Trace class automatically assigns stream class IDs: "
195 return create_stream_class_with_id(tc
, id
);
198 struct bt_trace_class
*bt_stream_class_borrow_trace_class(
199 struct bt_stream_class
*stream_class
)
201 BT_ASSERT_PRE_DEV_NON_NULL(stream_class
, "Stream class");
202 return bt_stream_class_borrow_trace_class_inline(stream_class
);
205 const struct bt_trace_class
*bt_stream_class_borrow_trace_class_const(
206 const struct bt_stream_class
*stream_class
)
208 return bt_stream_class_borrow_trace_class((void *) stream_class
);
211 const char *bt_stream_class_get_name(const struct bt_stream_class
*stream_class
)
213 BT_ASSERT_PRE_DEV_NON_NULL(stream_class
, "Stream class");
214 return stream_class
->name
.value
;
217 enum bt_stream_class_set_name_status
bt_stream_class_set_name(
218 struct bt_stream_class
*stream_class
,
221 BT_ASSERT_PRE_NON_NULL(stream_class
, "Stream class");
222 BT_ASSERT_PRE_NON_NULL(name
, "Name");
223 BT_ASSERT_PRE_DEV_STREAM_CLASS_HOT(stream_class
);
224 g_string_assign(stream_class
->name
.str
, name
);
225 stream_class
->name
.value
= stream_class
->name
.str
->str
;
226 BT_LIB_LOGD("Set stream class's name: %!+S", stream_class
);
227 return BT_FUNC_STATUS_OK
;
230 uint64_t bt_stream_class_get_id(const struct bt_stream_class
*stream_class
)
232 BT_ASSERT_PRE_DEV_NON_NULL(stream_class
, "Stream class");
233 return stream_class
->id
;
236 uint64_t bt_stream_class_get_event_class_count(
237 const struct bt_stream_class
*stream_class
)
239 BT_ASSERT_PRE_DEV_NON_NULL(stream_class
, "Stream class");
240 return (uint64_t) stream_class
->event_classes
->len
;
243 struct bt_event_class
*bt_stream_class_borrow_event_class_by_index(
244 struct bt_stream_class
*stream_class
, uint64_t index
)
246 BT_ASSERT_PRE_DEV_NON_NULL(stream_class
, "Stream class");
247 BT_ASSERT_PRE_DEV_VALID_INDEX(index
, stream_class
->event_classes
->len
);
248 return g_ptr_array_index(stream_class
->event_classes
, index
);
251 const struct bt_event_class
*
252 bt_stream_class_borrow_event_class_by_index_const(
253 const struct bt_stream_class
*stream_class
, uint64_t index
)
255 return bt_stream_class_borrow_event_class_by_index(
256 (void *) stream_class
, index
);
259 struct bt_event_class
*bt_stream_class_borrow_event_class_by_id(
260 struct bt_stream_class
*stream_class
, uint64_t id
)
262 struct bt_event_class
*event_class
= NULL
;
265 BT_ASSERT_PRE_DEV_NON_NULL(stream_class
, "Stream class");
267 for (i
= 0; i
< stream_class
->event_classes
->len
; i
++) {
268 struct bt_event_class
*event_class_candidate
=
269 g_ptr_array_index(stream_class
->event_classes
, i
);
271 if (event_class_candidate
->id
== id
) {
272 event_class
= event_class_candidate
;
281 const struct bt_event_class
*
282 bt_stream_class_borrow_event_class_by_id_const(
283 const struct bt_stream_class
*stream_class
, uint64_t id
)
285 return bt_stream_class_borrow_event_class_by_id(
286 (void *) stream_class
, id
);
289 const struct bt_field_class
*
290 bt_stream_class_borrow_packet_context_field_class_const(
291 const struct bt_stream_class
*stream_class
)
293 BT_ASSERT_PRE_DEV_NON_NULL(stream_class
, "Stream class");
294 return stream_class
->packet_context_fc
;
297 struct bt_field_class
*
298 bt_stream_class_borrow_packet_context_field_class(
299 struct bt_stream_class
*stream_class
)
301 BT_ASSERT_PRE_DEV_NON_NULL(stream_class
, "Stream class");
302 return stream_class
->packet_context_fc
;
305 enum bt_stream_class_set_field_class_status
306 bt_stream_class_set_packet_context_field_class(
307 struct bt_stream_class
*stream_class
,
308 struct bt_field_class
*field_class
)
311 struct bt_resolve_field_path_context resolve_ctx
= {
312 .packet_context
= field_class
,
313 .event_common_context
= NULL
,
314 .event_specific_context
= NULL
,
315 .event_payload
= NULL
,
318 BT_ASSERT_PRE_NON_NULL(stream_class
, "Stream class");
319 BT_ASSERT_PRE(stream_class
->supports_packets
,
320 "Stream class does not support packets: %![sc-]+S",
322 BT_ASSERT_PRE_NON_NULL(field_class
, "Field class");
323 BT_ASSERT_PRE_DEV_STREAM_CLASS_HOT(stream_class
);
324 BT_ASSERT_PRE(bt_field_class_get_type(field_class
) ==
325 BT_FIELD_CLASS_TYPE_STRUCTURE
,
326 "Packet context field class is not a structure field class: %!+F",
328 ret
= bt_resolve_field_paths(field_class
, &resolve_ctx
);
331 * This is the only reason for which
332 * bt_resolve_field_paths() can fail: anything else
333 * would be because a precondition is not satisfied.
335 ret
= BT_FUNC_STATUS_MEMORY_ERROR
;
339 bt_field_class_make_part_of_trace_class(field_class
);
340 bt_object_put_ref(stream_class
->packet_context_fc
);
341 stream_class
->packet_context_fc
= field_class
;
342 bt_object_get_no_null_check(stream_class
->packet_context_fc
);
343 bt_field_class_freeze(field_class
);
344 BT_LIB_LOGD("Set stream class's packet context field class: %!+S",
351 const struct bt_field_class
*
352 bt_stream_class_borrow_event_common_context_field_class_const(
353 const struct bt_stream_class
*stream_class
)
355 BT_ASSERT_PRE_DEV_NON_NULL(stream_class
, "Stream class");
356 return stream_class
->event_common_context_fc
;
359 struct bt_field_class
*
360 bt_stream_class_borrow_event_common_context_field_class(
361 struct bt_stream_class
*stream_class
)
363 BT_ASSERT_PRE_DEV_NON_NULL(stream_class
, "Stream class");
364 return stream_class
->event_common_context_fc
;
367 enum bt_stream_class_set_field_class_status
368 bt_stream_class_set_event_common_context_field_class(
369 struct bt_stream_class
*stream_class
,
370 struct bt_field_class
*field_class
)
373 struct bt_resolve_field_path_context resolve_ctx
= {
374 .packet_context
= NULL
,
375 .event_common_context
= field_class
,
376 .event_specific_context
= NULL
,
377 .event_payload
= NULL
,
380 BT_ASSERT_PRE_NON_NULL(stream_class
, "Stream class");
381 BT_ASSERT_PRE_NON_NULL(field_class
, "Field class");
382 BT_ASSERT_PRE_DEV_STREAM_CLASS_HOT(stream_class
);
383 BT_ASSERT_PRE(bt_field_class_get_type(field_class
) ==
384 BT_FIELD_CLASS_TYPE_STRUCTURE
,
385 "Event common context field class is not a structure field class: %!+F",
387 resolve_ctx
.packet_context
= stream_class
->packet_context_fc
;
388 ret
= bt_resolve_field_paths(field_class
, &resolve_ctx
);
391 * This is the only reason for which
392 * bt_resolve_field_paths() can fail: anything else
393 * would be because a precondition is not satisfied.
395 ret
= BT_FUNC_STATUS_MEMORY_ERROR
;
399 bt_field_class_make_part_of_trace_class(field_class
);
400 bt_object_put_ref(stream_class
->event_common_context_fc
);
401 stream_class
->event_common_context_fc
= field_class
;
402 bt_object_get_no_null_check(stream_class
->event_common_context_fc
);
403 bt_field_class_freeze(field_class
);
404 BT_LIB_LOGD("Set stream class's event common context field class: %!+S",
412 void _bt_stream_class_freeze(const struct bt_stream_class
*stream_class
)
414 /* The field classes and default clock class are already frozen */
415 BT_ASSERT(stream_class
);
416 BT_LIB_LOGD("Freezing stream class's user attributes: %!+v",
417 stream_class
->user_attributes
);
418 bt_value_freeze(stream_class
->user_attributes
);
419 BT_LIB_LOGD("Freezing stream class: %!+S", stream_class
);
420 ((struct bt_stream_class
*) stream_class
)->frozen
= true;
423 enum bt_stream_class_set_default_clock_class_status
424 bt_stream_class_set_default_clock_class(
425 struct bt_stream_class
*stream_class
,
426 struct bt_clock_class
*clock_class
)
428 BT_ASSERT_PRE_NON_NULL(stream_class
, "Stream class");
429 BT_ASSERT_PRE_NON_NULL(clock_class
, "Clock class");
430 BT_ASSERT_PRE_DEV_STREAM_CLASS_HOT(stream_class
);
431 bt_object_put_ref(stream_class
->default_clock_class
);
432 stream_class
->default_clock_class
= clock_class
;
433 bt_object_get_no_null_check(stream_class
->default_clock_class
);
434 bt_clock_class_freeze(clock_class
);
435 BT_LIB_LOGD("Set stream class's default clock class: %!+S",
437 return BT_FUNC_STATUS_OK
;
440 struct bt_clock_class
*bt_stream_class_borrow_default_clock_class(
441 struct bt_stream_class
*stream_class
)
443 BT_ASSERT_PRE_DEV_NON_NULL(stream_class
, "Stream class");
444 return stream_class
->default_clock_class
;
447 const struct bt_clock_class
*bt_stream_class_borrow_default_clock_class_const(
448 const struct bt_stream_class
*stream_class
)
450 BT_ASSERT_PRE_DEV_NON_NULL(stream_class
, "Stream class");
451 return stream_class
->default_clock_class
;
454 bt_bool
bt_stream_class_assigns_automatic_event_class_id(
455 const struct bt_stream_class
*stream_class
)
457 BT_ASSERT_PRE_DEV_NON_NULL(stream_class
, "Stream class");
458 return (bt_bool
) stream_class
->assigns_automatic_event_class_id
;
461 void bt_stream_class_set_assigns_automatic_event_class_id(
462 struct bt_stream_class
*stream_class
,
465 BT_ASSERT_PRE_NON_NULL(stream_class
, "Stream class");
466 BT_ASSERT_PRE_DEV_STREAM_CLASS_HOT(stream_class
);
467 stream_class
->assigns_automatic_event_class_id
= (bool) value
;
468 BT_LIB_LOGD("Set stream class's automatic event class ID "
469 "assignment property: %!+S", stream_class
);
472 bt_bool
bt_stream_class_assigns_automatic_stream_id(
473 const struct bt_stream_class
*stream_class
)
475 BT_ASSERT_PRE_DEV_NON_NULL(stream_class
, "Stream class");
476 return (bt_bool
) stream_class
->assigns_automatic_stream_id
;
479 void bt_stream_class_set_supports_discarded_events(
480 struct bt_stream_class
*stream_class
,
481 bt_bool supports_discarded_events
,
482 bt_bool with_default_clock_snapshots
)
484 BT_ASSERT_PRE_NON_NULL(stream_class
, "Stream class");
485 BT_ASSERT_PRE_DEV_STREAM_CLASS_HOT(stream_class
);
486 BT_ASSERT_PRE(supports_discarded_events
||
487 !with_default_clock_snapshots
,
488 "Discarded events cannot have default clock snapshots when "
489 "not supported: %!+S", stream_class
);
490 BT_ASSERT_PRE(!with_default_clock_snapshots
||
491 stream_class
->default_clock_class
,
492 "Stream class has no default clock class: %!+S", stream_class
);
493 stream_class
->supports_discarded_events
=
494 (bool) supports_discarded_events
;
495 stream_class
->discarded_events_have_default_clock_snapshots
=
496 (bool) with_default_clock_snapshots
;
497 BT_LIB_LOGD("Set stream class's discarded events support property: "
498 "%!+S", stream_class
);
501 bt_bool
bt_stream_class_supports_discarded_events(
502 const struct bt_stream_class
*stream_class
)
504 BT_ASSERT_PRE_DEV_NON_NULL(stream_class
, "Stream class");
505 return (bt_bool
) stream_class
->supports_discarded_events
;
508 bt_bool
bt_stream_class_discarded_events_have_default_clock_snapshots(
509 const struct bt_stream_class
*stream_class
)
511 BT_ASSERT_PRE_DEV_NON_NULL(stream_class
, "Stream class");
512 return (bt_bool
) stream_class
->discarded_events_have_default_clock_snapshots
;
515 void bt_stream_class_set_supports_discarded_packets(
516 struct bt_stream_class
*stream_class
,
517 bt_bool supports_discarded_packets
,
518 bt_bool with_default_clock_snapshots
)
520 BT_ASSERT_PRE_NON_NULL(stream_class
, "Stream class");
521 BT_ASSERT_PRE_DEV_STREAM_CLASS_HOT(stream_class
);
522 BT_ASSERT_PRE(!supports_discarded_packets
||
523 stream_class
->supports_packets
,
524 "Stream class does not support packets: %!+S",
526 BT_ASSERT_PRE(supports_discarded_packets
||
527 !with_default_clock_snapshots
,
528 "Discarded packets cannot have default clock snapshots when "
529 "not supported: %!+S", stream_class
);
530 BT_ASSERT_PRE(!with_default_clock_snapshots
||
531 stream_class
->default_clock_class
,
532 "Stream class has no default clock class: %!+S", stream_class
);
533 stream_class
->supports_discarded_packets
=
534 (bool) supports_discarded_packets
;
535 stream_class
->discarded_packets_have_default_clock_snapshots
=
536 (bool) with_default_clock_snapshots
;
537 BT_LIB_LOGD("Set stream class's discarded packets support property: "
538 "%!+S", stream_class
);
541 bt_bool
bt_stream_class_supports_discarded_packets(
542 const struct bt_stream_class
*stream_class
)
544 BT_ASSERT_PRE_DEV_NON_NULL(stream_class
, "Stream class");
545 return (bt_bool
) stream_class
->supports_discarded_packets
;
548 bt_bool
bt_stream_class_discarded_packets_have_default_clock_snapshots(
549 const struct bt_stream_class
*stream_class
)
551 BT_ASSERT_PRE_DEV_NON_NULL(stream_class
, "Stream class");
552 return (bt_bool
) stream_class
->discarded_packets_have_default_clock_snapshots
;
555 void bt_stream_class_set_supports_packets(
556 struct bt_stream_class
*stream_class
,
557 bt_bool supports_packets
,
558 bt_bool with_beginning_default_clock_snapshot
,
559 bt_bool with_end_default_clock_snapshot
)
561 bt_bool with_default_clock_snapshot
=
562 with_beginning_default_clock_snapshot
||
563 with_end_default_clock_snapshot
;
564 BT_ASSERT_PRE_NON_NULL(stream_class
, "Stream class");
565 BT_ASSERT_PRE_DEV_STREAM_CLASS_HOT(stream_class
);
566 BT_ASSERT_PRE(supports_packets
||
567 !with_default_clock_snapshot
,
568 "Packets cannot have default clock snapshots when "
569 "not supported: %!+S", stream_class
);
570 BT_ASSERT_PRE(!with_default_clock_snapshot
||
571 stream_class
->default_clock_class
,
572 "Stream class has no default clock class: %!+S", stream_class
);
573 BT_ASSERT_PRE(supports_packets
|| !stream_class
->packet_context_fc
,
574 "Stream class already has a packet context field class: %!+S",
576 BT_ASSERT_PRE(supports_packets
||
577 !stream_class
->supports_discarded_packets
,
578 "Stream class already supports discarded packets: %!+S",
580 stream_class
->supports_packets
= (bool) supports_packets
;
581 stream_class
->packets_have_beginning_default_clock_snapshot
=
582 (bool) with_beginning_default_clock_snapshot
;
583 stream_class
->packets_have_end_default_clock_snapshot
=
584 (bool) with_end_default_clock_snapshot
;
585 BT_LIB_LOGD("Set stream class's packets support property: %!+S",
589 bt_bool
bt_stream_class_supports_packets(
590 const struct bt_stream_class
*stream_class
)
592 BT_ASSERT_PRE_NON_NULL(stream_class
, "Stream class");
593 return (bt_bool
) stream_class
->supports_packets
;
596 bt_bool
bt_stream_class_packets_have_beginning_default_clock_snapshot(
597 const struct bt_stream_class
*stream_class
)
599 BT_ASSERT_PRE_DEV_NON_NULL(stream_class
, "Stream class");
600 return (bt_bool
) stream_class
->packets_have_beginning_default_clock_snapshot
;
603 bt_bool
bt_stream_class_packets_have_end_default_clock_snapshot(
604 const struct bt_stream_class
*stream_class
)
606 BT_ASSERT_PRE_DEV_NON_NULL(stream_class
, "Stream class");
607 return (bt_bool
) stream_class
->packets_have_end_default_clock_snapshot
;
610 void bt_stream_class_set_assigns_automatic_stream_id(
611 struct bt_stream_class
*stream_class
,
614 BT_ASSERT_PRE_NON_NULL(stream_class
, "Stream class");
615 BT_ASSERT_PRE_DEV_STREAM_CLASS_HOT(stream_class
);
616 stream_class
->assigns_automatic_stream_id
= (bool) value
;
617 BT_LIB_LOGD("Set stream class's automatic stream ID "
618 "assignment property: %!+S", stream_class
);
621 const struct bt_value
*bt_stream_class_borrow_user_attributes_const(
622 const struct bt_stream_class
*stream_class
)
624 BT_ASSERT_PRE_DEV_NON_NULL(stream_class
, "Stream class");
625 return stream_class
->user_attributes
;
628 struct bt_value
*bt_stream_class_borrow_user_attributes(
629 struct bt_stream_class
*stream_class
)
631 return (void *) bt_stream_class_borrow_user_attributes_const(
632 (void *) stream_class
);
635 void bt_stream_class_set_user_attributes(
636 struct bt_stream_class
*stream_class
,
637 const struct bt_value
*user_attributes
)
639 BT_ASSERT_PRE_NON_NULL(stream_class
, "Stream class");
640 BT_ASSERT_PRE_NON_NULL(user_attributes
, "User attributes");
641 BT_ASSERT_PRE(user_attributes
->type
== BT_VALUE_TYPE_MAP
,
642 "User attributes object is not a map value object.");
643 BT_ASSERT_PRE_DEV_STREAM_CLASS_HOT(stream_class
);
644 bt_object_put_no_null_check(stream_class
->user_attributes
);
645 stream_class
->user_attributes
= (void *) user_attributes
;
646 bt_object_get_no_null_check(stream_class
->user_attributes
);
649 void bt_stream_class_get_ref(const struct bt_stream_class
*stream_class
)
651 bt_object_get_ref(stream_class
);
654 void bt_stream_class_put_ref(const struct bt_stream_class
*stream_class
)
656 bt_object_put_ref(stream_class
);