lib: strictly type function return status enumerations
[babeltrace.git] / src / lib / trace-ir / stream-class.c
CommitLineData
11b0cdc8 1/*
f2b0325d 2 * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
de9dd397 3 * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
11b0cdc8 4 *
11b0cdc8
JG
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:
11 *
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
14 *
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
21 * SOFTWARE.
22 */
23
b03487ab 24#define BT_LOG_TAG "LIB/STREAM-CLASS"
1633ef46 25#include "lib/logging.h"
d2f71f12 26
57952005 27#include "lib/assert-pre.h"
71c5da58 28#include <babeltrace2/trace-ir/trace-const.h>
57952005
MJ
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"
dc3fffef 34#include <inttypes.h>
544d0515 35#include <stdint.h>
e011d2c1 36#include <stdbool.h>
11b0cdc8 37
57952005
MJ
38#include "clock-class.h"
39#include "event-class.h"
40#include "field-class.h"
41#include "field.h"
42#include "field-wrapper.h"
43#include "resolve-field-path.h"
44#include "stream-class.h"
45#include "trace.h"
46#include "utils.h"
fb25b9e3 47#include "lib/func-status.h"
57952005 48
7b33a0e0
PP
49#define BT_ASSERT_PRE_STREAM_CLASS_HOT(_sc) \
50 BT_ASSERT_PRE_HOT((_sc), "Stream class", ": %!+S", (_sc))
142c5610 51
18acc6f8 52static
7b33a0e0 53void destroy_stream_class(struct bt_object *obj)
3ea33115 54{
18acc6f8
PP
55 struct bt_stream_class *stream_class = (void *) obj;
56
7b33a0e0
PP
57 BT_LIB_LOGD("Destroying stream class: %!+S", stream_class);
58 BT_LOGD_STR("Putting default clock class.");
1248f5ea 59 BT_OBJECT_PUT_REF_AND_RESET(stream_class->default_clock_class);
3ea33115 60
8deee039
PP
61 if (stream_class->event_classes) {
62 BT_LOGD_STR("Destroying event classes.");
63 g_ptr_array_free(stream_class->event_classes, TRUE);
1248f5ea 64 stream_class->event_classes = NULL;
d2f71f12
PP
65 }
66
7b33a0e0
PP
67 if (stream_class->name.str) {
68 g_string_free(stream_class->name.str, TRUE);
1248f5ea
PP
69 stream_class->name.str = NULL;
70 stream_class->name.value = NULL;
3ea33115
JG
71 }
72
66fd07a5 73 BT_LOGD_STR("Putting packet context field class.");
1248f5ea 74 BT_OBJECT_PUT_REF_AND_RESET(stream_class->packet_context_fc);
66fd07a5 75 BT_LOGD_STR("Putting event common context field class.");
1248f5ea 76 BT_OBJECT_PUT_REF_AND_RESET(stream_class->event_common_context_fc);
a6918753 77 bt_object_pool_finalize(&stream_class->packet_context_field_pool);
8deee039 78 g_free(stream_class);
3ea33115
JG
79}
80
a6918753
PP
81static
82void free_field_wrapper(struct bt_field_wrapper *field_wrapper,
83 struct bt_stream_class *stream_class)
84{
85 bt_field_wrapper_destroy((void *) field_wrapper);
86}
87
7b33a0e0
PP
88BT_ASSERT_PRE_FUNC
89static
10b7a2e4 90bool stream_class_id_is_unique(const struct bt_trace_class *tc, uint64_t id)
7b33a0e0
PP
91{
92 uint64_t i;
93 bool is_unique = true;
94
10b7a2e4 95 for (i = 0; i < tc->stream_classes->len; i++) {
78cf9df6 96 const struct bt_stream_class *sc =
10b7a2e4 97 tc->stream_classes->pdata[i];
7b33a0e0
PP
98
99 if (sc->id == id) {
100 is_unique = false;
101 goto end;
102 }
103 }
104
105end:
106 return is_unique;
107}
108
109static
10b7a2e4
PP
110struct bt_stream_class *create_stream_class_with_id(
111 struct bt_trace_class *tc, uint64_t id)
2f100782 112{
8deee039
PP
113 struct bt_stream_class *stream_class = NULL;
114 int ret;
2f100782 115
10b7a2e4
PP
116 BT_ASSERT(tc);
117 BT_ASSERT_PRE(stream_class_id_is_unique(tc, id),
118 "Duplicate stream class ID: %![tc-]+T, id=%" PRIu64, tc, id);
119 BT_LIB_LOGD("Creating stream class object: %![tc-]+T, id=%" PRIu64,
120 tc, id);
8deee039 121 stream_class = g_new0(struct bt_stream_class, 1);
d2f71f12 122 if (!stream_class) {
8deee039
PP
123 BT_LOGE_STR("Failed to allocate one stream class.");
124 goto error;
d2f71f12
PP
125 }
126
7b33a0e0
PP
127 bt_object_init_shared_with_parent(&stream_class->base,
128 destroy_stream_class);
129
130 stream_class->name.str = g_string_new(NULL);
131 if (!stream_class->name.str) {
132 BT_LOGE_STR("Failed to allocate a GString.");
133 ret = -1;
134 goto end;
135 }
136
137 stream_class->id = id;
138 stream_class->assigns_automatic_event_class_id = true;
139 stream_class->assigns_automatic_stream_id = true;
140 stream_class->event_classes = g_ptr_array_new_with_free_func(
141 (GDestroyNotify) bt_object_try_spec_release);
142 if (!stream_class->event_classes) {
143 BT_LOGE_STR("Failed to allocate a GPtrArray.");
8deee039 144 goto error;
2f100782
JG
145 }
146
a6918753
PP
147 ret = bt_object_pool_initialize(&stream_class->packet_context_field_pool,
148 (bt_object_pool_new_object_func) bt_field_wrapper_new,
149 (bt_object_pool_destroy_object_func) free_field_wrapper,
150 stream_class);
151 if (ret) {
152 BT_LOGE("Failed to initialize packet context field pool: ret=%d",
153 ret);
154 goto error;
155 }
156
10b7a2e4
PP
157 bt_object_set_parent(&stream_class->base, &tc->base);
158 g_ptr_array_add(tc->stream_classes, stream_class);
159 bt_trace_class_freeze(tc);
7b33a0e0 160 BT_LIB_LOGD("Created stream class object: %!+S", stream_class);
a6918753
PP
161 goto end;
162
163error:
8138bfe1 164 BT_OBJECT_PUT_REF_AND_RESET(stream_class);
a6918753
PP
165
166end:
7b33a0e0 167 return stream_class;
a6918753
PP
168}
169
10b7a2e4 170struct bt_stream_class *bt_stream_class_create(struct bt_trace_class *tc)
a6918753 171{
10b7a2e4
PP
172 BT_ASSERT_PRE_NON_NULL(tc, "Trace class");
173 BT_ASSERT_PRE(tc->assigns_automatic_stream_class_id,
174 "Trace class does not automatically assigns stream class IDs: "
175 "%![sc-]+T", tc);
176 return create_stream_class_with_id(tc,
177 (uint64_t) tc->stream_classes->len);
7b33a0e0 178}
a6918753 179
78cf9df6 180struct bt_stream_class *bt_stream_class_create_with_id(
10b7a2e4 181 struct bt_trace_class *tc, uint64_t id)
7b33a0e0 182{
10b7a2e4
PP
183 BT_ASSERT_PRE_NON_NULL(tc, "Trace class");
184 BT_ASSERT_PRE(!tc->assigns_automatic_stream_class_id,
185 "Trace class automatically assigns stream class IDs: "
186 "%![sc-]+T", tc);
187 return create_stream_class_with_id(tc, id);
a6918753
PP
188}
189
10b7a2e4 190struct bt_trace_class *bt_stream_class_borrow_trace_class(
78cf9df6 191 struct bt_stream_class *stream_class)
11b0cdc8 192{
7b33a0e0 193 BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
10b7a2e4 194 return bt_stream_class_borrow_trace_class_inline(stream_class);
11b0cdc8
JG
195}
196
10b7a2e4 197const struct bt_trace_class *bt_stream_class_borrow_trace_class_const(
78cf9df6 198 const struct bt_stream_class *stream_class)
9e550e5f 199{
10b7a2e4 200 return bt_stream_class_borrow_trace_class((void *) stream_class);
9e550e5f
PP
201}
202
78cf9df6 203const char *bt_stream_class_get_name(const struct bt_stream_class *stream_class)
2f100782 204{
18acc6f8 205 BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
7b33a0e0 206 return stream_class->name.value;
2f100782
JG
207}
208
fb25b9e3 209enum bt_stream_class_set_name_status bt_stream_class_set_name(
78cf9df6 210 struct bt_stream_class *stream_class,
8deee039 211 const char *name)
5ca83563 212{
7b33a0e0
PP
213 BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
214 BT_ASSERT_PRE_NON_NULL(name, "Name");
215 BT_ASSERT_PRE_STREAM_CLASS_HOT(stream_class);
216 g_string_assign(stream_class->name.str, name);
217 stream_class->name.value = stream_class->name.str->str;
a684a357 218 BT_LIB_LOGD("Set stream class's name: %!+S", stream_class);
fb25b9e3 219 return BT_FUNC_STATUS_OK;
5ca83563
JG
220}
221
78cf9df6 222uint64_t bt_stream_class_get_id(const struct bt_stream_class *stream_class)
2f100782 223{
18acc6f8 224 BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
7b33a0e0 225 return stream_class->id;
2f100782
JG
226}
227
7b33a0e0 228uint64_t bt_stream_class_get_event_class_count(
78cf9df6 229 const struct bt_stream_class *stream_class)
29664b2a 230{
7b33a0e0
PP
231 BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
232 return (uint64_t) stream_class->event_classes->len;
29664b2a
PP
233}
234
7b33a0e0
PP
235struct bt_event_class *bt_stream_class_borrow_event_class_by_index(
236 struct bt_stream_class *stream_class, uint64_t index)
0d23acbe 237{
7b33a0e0
PP
238 BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
239 BT_ASSERT_PRE_VALID_INDEX(index, stream_class->event_classes->len);
240 return g_ptr_array_index(stream_class->event_classes, index);
0d23acbe
PP
241}
242
78cf9df6
PP
243const struct bt_event_class *
244bt_stream_class_borrow_event_class_by_index_const(
245 const struct bt_stream_class *stream_class, uint64_t index)
9e550e5f 246{
78cf9df6 247 return bt_stream_class_borrow_event_class_by_index(
9e550e5f
PP
248 (void *) stream_class, index);
249}
250
7b33a0e0 251struct bt_event_class *bt_stream_class_borrow_event_class_by_id(
9e550e5f 252 struct bt_stream_class *stream_class, uint64_t id)
11b0cdc8 253{
7b33a0e0
PP
254 struct bt_event_class *event_class = NULL;
255 uint64_t i;
0b9ce69f 256
10b7a2e4 257 BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
11b0cdc8 258
9e550e5f 259 for (i = 0; i < stream_class->event_classes->len; i++) {
7b33a0e0 260 struct bt_event_class *event_class_candidate =
9e550e5f 261 g_ptr_array_index(stream_class->event_classes, i);
e6a8e8e4 262
7b33a0e0
PP
263 if (event_class_candidate->id == id) {
264 event_class = event_class_candidate;
09840de5
PP
265 goto end;
266 }
69dc4535
JG
267 }
268
69dc4535 269end:
7b33a0e0 270 return event_class;
0863f950
PP
271}
272
78cf9df6
PP
273const struct bt_event_class *
274bt_stream_class_borrow_event_class_by_id_const(
275 const struct bt_stream_class *stream_class, uint64_t id)
9e550e5f 276{
78cf9df6 277 return bt_stream_class_borrow_event_class_by_id(
9e550e5f
PP
278 (void *) stream_class, id);
279}
280
78cf9df6
PP
281const struct bt_field_class *
282bt_stream_class_borrow_packet_context_field_class_const(
283 const struct bt_stream_class *stream_class)
12c8a1a3 284{
18acc6f8 285 BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
939190b3 286 return stream_class->packet_context_fc;
12c8a1a3
JG
287}
288
909d0a89
PP
289struct bt_field_class *
290bt_stream_class_borrow_packet_context_field_class(
291 struct bt_stream_class *stream_class)
292{
293 BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
294 return stream_class->packet_context_fc;
295}
296
fb25b9e3
PP
297enum bt_stream_class_set_field_class_status
298bt_stream_class_set_packet_context_field_class(
78cf9df6
PP
299 struct bt_stream_class *stream_class,
300 struct bt_field_class *field_class)
12c8a1a3 301{
7b33a0e0
PP
302 int ret;
303 struct bt_resolve_field_path_context resolve_ctx = {
939190b3 304 .packet_context = field_class,
7b33a0e0
PP
305 .event_common_context = NULL,
306 .event_specific_context = NULL,
307 .event_payload = NULL,
308 };
18acc6f8 309
7b33a0e0 310 BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
939190b3 311 BT_ASSERT_PRE_NON_NULL(field_class, "Field class");
7b33a0e0 312 BT_ASSERT_PRE_STREAM_CLASS_HOT(stream_class);
af0c18e3
PP
313 BT_ASSERT_PRE(bt_field_class_get_type(field_class) ==
314 BT_FIELD_CLASS_TYPE_STRUCTURE,
66fd07a5 315 "Packet context field class is not a structure field class: %!+F",
939190b3 316 field_class);
939190b3 317 ret = bt_resolve_field_paths(field_class, &resolve_ctx);
7b33a0e0 318 if (ret) {
36a28778
PP
319 /*
320 * This is the only reason for which
321 * bt_resolve_field_paths() can fail: anything else
322 * would be because a precondition is not satisfied.
323 */
fb25b9e3 324 ret = BT_FUNC_STATUS_MEMORY_ERROR;
18acc6f8
PP
325 goto end;
326 }
327
10b7a2e4 328 bt_field_class_make_part_of_trace_class(field_class);
8138bfe1 329 bt_object_put_ref(stream_class->packet_context_fc);
4b70020d
PP
330 stream_class->packet_context_fc = field_class;
331 bt_object_get_no_null_check(stream_class->packet_context_fc);
939190b3 332 bt_field_class_freeze(field_class);
a684a357 333 BT_LIB_LOGD("Set stream class's packet context field class: %!+S",
7b33a0e0 334 stream_class);
18acc6f8
PP
335
336end:
337 return ret;
12c8a1a3
JG
338}
339
78cf9df6
PP
340const struct bt_field_class *
341bt_stream_class_borrow_event_common_context_field_class_const(
342 const struct bt_stream_class *stream_class)
af181248 343{
18acc6f8 344 BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
939190b3 345 return stream_class->event_common_context_fc;
af181248
JG
346}
347
909d0a89
PP
348struct bt_field_class *
349bt_stream_class_borrow_event_common_context_field_class(
350 struct bt_stream_class *stream_class)
351{
352 BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
353 return stream_class->event_common_context_fc;
354}
355
fb25b9e3 356enum bt_stream_class_set_field_class_status
36a28778 357bt_stream_class_set_event_common_context_field_class(
78cf9df6
PP
358 struct bt_stream_class *stream_class,
359 struct bt_field_class *field_class)
af181248 360{
7b33a0e0
PP
361 int ret;
362 struct bt_resolve_field_path_context resolve_ctx = {
7b33a0e0 363 .packet_context = NULL,
939190b3 364 .event_common_context = field_class,
7b33a0e0
PP
365 .event_specific_context = NULL,
366 .event_payload = NULL,
367 };
18acc6f8 368
7b33a0e0 369 BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
939190b3 370 BT_ASSERT_PRE_NON_NULL(field_class, "Field class");
7b33a0e0 371 BT_ASSERT_PRE_STREAM_CLASS_HOT(stream_class);
af0c18e3
PP
372 BT_ASSERT_PRE(bt_field_class_get_type(field_class) ==
373 BT_FIELD_CLASS_TYPE_STRUCTURE,
66fd07a5 374 "Event common context field class is not a structure field class: %!+F",
939190b3 375 field_class);
939190b3 376 resolve_ctx.packet_context = stream_class->packet_context_fc;
939190b3 377 ret = bt_resolve_field_paths(field_class, &resolve_ctx);
7b33a0e0 378 if (ret) {
36a28778
PP
379 /*
380 * This is the only reason for which
381 * bt_resolve_field_paths() can fail: anything else
382 * would be because a precondition is not satisfied.
383 */
fb25b9e3 384 ret = BT_FUNC_STATUS_MEMORY_ERROR;
18acc6f8
PP
385 goto end;
386 }
387
10b7a2e4 388 bt_field_class_make_part_of_trace_class(field_class);
8138bfe1 389 bt_object_put_ref(stream_class->event_common_context_fc);
4b70020d
PP
390 stream_class->event_common_context_fc = field_class;
391 bt_object_get_no_null_check(stream_class->event_common_context_fc);
939190b3 392 bt_field_class_freeze(field_class);
a684a357 393 BT_LIB_LOGD("Set stream class's event common context field class: %!+S",
7b33a0e0 394 stream_class);
18acc6f8 395
18acc6f8
PP
396end:
397 return ret;
11b0cdc8
JG
398}
399
7b33a0e0 400BT_HIDDEN
78cf9df6 401void _bt_stream_class_freeze(const struct bt_stream_class *stream_class)
8bf65fbd 402{
939190b3 403 /* The field classes and default clock class are already frozen */
7b33a0e0
PP
404 BT_ASSERT(stream_class);
405 BT_LIB_LOGD("Freezing stream class: %!+S", stream_class);
78cf9df6 406 ((struct bt_stream_class *) stream_class)->frozen = true;
8bf65fbd
JG
407}
408
fb25b9e3
PP
409enum bt_stream_class_set_default_clock_class_status
410bt_stream_class_set_default_clock_class(
78cf9df6 411 struct bt_stream_class *stream_class,
7b33a0e0 412 struct bt_clock_class *clock_class)
8bf65fbd 413{
7b33a0e0
PP
414 BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
415 BT_ASSERT_PRE_NON_NULL(clock_class, "Clock class");
416 BT_ASSERT_PRE_STREAM_CLASS_HOT(stream_class);
8138bfe1 417 bt_object_put_ref(stream_class->default_clock_class);
4b70020d
PP
418 stream_class->default_clock_class = clock_class;
419 bt_object_get_no_null_check(stream_class->default_clock_class);
7b33a0e0 420 bt_clock_class_freeze(clock_class);
a684a357 421 BT_LIB_LOGD("Set stream class's default clock class: %!+S",
7b33a0e0 422 stream_class);
fb25b9e3 423 return BT_FUNC_STATUS_OK;
8bf65fbd
JG
424}
425
7b33a0e0
PP
426struct bt_clock_class *bt_stream_class_borrow_default_clock_class(
427 struct bt_stream_class *stream_class)
8bf65fbd 428{
7b33a0e0
PP
429 BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
430 return stream_class->default_clock_class;
431}
8bf65fbd 432
78cf9df6
PP
433const struct bt_clock_class *bt_stream_class_borrow_default_clock_class_const(
434 const struct bt_stream_class *stream_class)
435{
436 BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
437 return stream_class->default_clock_class;
438}
439
7b33a0e0 440bt_bool bt_stream_class_assigns_automatic_event_class_id(
78cf9df6 441 const struct bt_stream_class *stream_class)
7b33a0e0
PP
442{
443 BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
444 return (bt_bool) stream_class->assigns_automatic_event_class_id;
8bf65fbd
JG
445}
446
78cf9df6
PP
447void bt_stream_class_set_assigns_automatic_event_class_id(
448 struct bt_stream_class *stream_class,
9e550e5f 449 bt_bool value)
8bf65fbd 450{
7b33a0e0
PP
451 BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
452 BT_ASSERT_PRE_STREAM_CLASS_HOT(stream_class);
453 stream_class->assigns_automatic_event_class_id = (bool) value;
a684a357 454 BT_LIB_LOGD("Set stream class's automatic event class ID "
7b33a0e0 455 "assignment property: %!+S", stream_class);
7b33a0e0 456}
8bf65fbd 457
5ef34326 458bt_bool bt_stream_class_packets_have_beginning_default_clock_snapshot(
34e13c22
PP
459 const struct bt_stream_class *stream_class)
460{
461 BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
5ef34326 462 return (bt_bool) stream_class->packets_have_beginning_default_clock_snapshot;
34e13c22
PP
463}
464
5ef34326 465void bt_stream_class_set_packets_have_beginning_default_clock_snapshot(
34e13c22
PP
466 struct bt_stream_class *stream_class, bt_bool value)
467{
468 BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
469 BT_ASSERT_PRE_STREAM_CLASS_HOT(stream_class);
470 BT_ASSERT_PRE(!value || stream_class->default_clock_class,
471 "Stream class has no default clock class: %!+S", stream_class);
5ef34326 472 stream_class->packets_have_beginning_default_clock_snapshot =
34e13c22 473 (bool) value;
a684a357 474 BT_LIB_LOGD("Set stream class's \"packets have default beginning "
34e13c22
PP
475 "clock snapshot\" property: %!+S", stream_class);
476}
477
5ef34326 478bt_bool bt_stream_class_packets_have_end_default_clock_snapshot(
34e13c22
PP
479 const struct bt_stream_class *stream_class)
480{
481 BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
5ef34326 482 return (bt_bool) stream_class->packets_have_end_default_clock_snapshot;
34e13c22
PP
483}
484
5ef34326 485void bt_stream_class_set_packets_have_end_default_clock_snapshot(
34e13c22
PP
486 struct bt_stream_class *stream_class, bt_bool value)
487{
488 BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
489 BT_ASSERT_PRE_STREAM_CLASS_HOT(stream_class);
490 BT_ASSERT_PRE(!value || stream_class->default_clock_class,
491 "Stream class has no default clock class: %!+S", stream_class);
5ef34326 492 stream_class->packets_have_end_default_clock_snapshot =
34e13c22 493 (bool) value;
a684a357 494 BT_LIB_LOGD("Set stream class's \"packets have default end "
34e13c22
PP
495 "clock snapshot\" property: %!+S", stream_class);
496}
497
7b33a0e0 498bt_bool bt_stream_class_assigns_automatic_stream_id(
78cf9df6 499 const struct bt_stream_class *stream_class)
7b33a0e0
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
77037b2b
PP
505void bt_stream_class_set_supports_discarded_events(
506 struct bt_stream_class *stream_class,
507 bt_bool supports_discarded_events,
508 bt_bool with_default_clock_snapshots)
509{
510 BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
511 BT_ASSERT_PRE_STREAM_CLASS_HOT(stream_class);
512 BT_ASSERT_PRE(supports_discarded_events ||
513 !with_default_clock_snapshots,
514 "Discarded events cannot have default clock snapshots when "
515 "not supported: %!+S", stream_class);
516 BT_ASSERT_PRE(!with_default_clock_snapshots ||
517 stream_class->default_clock_class,
518 "Stream class has no default clock class: %!+S", stream_class);
519 stream_class->supports_discarded_events =
520 (bool) supports_discarded_events;
521 stream_class->discarded_events_have_default_clock_snapshots =
522 (bool) with_default_clock_snapshots;
a684a357 523 BT_LIB_LOGD("Set stream class's discarded events support property: "
77037b2b
PP
524 "%!+S", stream_class);
525}
526
527bt_bool bt_stream_class_supports_discarded_events(
528 const struct bt_stream_class *stream_class)
529{
530 BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
531 return (bt_bool) stream_class->supports_discarded_events;
532}
533
534bt_bool bt_stream_class_discarded_events_have_default_clock_snapshots(
535 const struct bt_stream_class *stream_class)
536{
537 BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
538 return (bt_bool) stream_class->discarded_events_have_default_clock_snapshots;
539}
540
541void bt_stream_class_set_supports_discarded_packets(
542 struct bt_stream_class *stream_class,
543 bt_bool supports_discarded_packets,
544 bt_bool with_default_clock_snapshots)
545{
546 BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
547 BT_ASSERT_PRE_STREAM_CLASS_HOT(stream_class);
548 BT_ASSERT_PRE(supports_discarded_packets ||
549 !with_default_clock_snapshots,
550 "Discarded packets cannot have default clock snapshots when "
551 "not supported: %!+S", stream_class);
552 BT_ASSERT_PRE(!with_default_clock_snapshots ||
553 stream_class->default_clock_class,
554 "Stream class has no default clock class: %!+S", stream_class);
555 stream_class->supports_discarded_packets =
556 (bool) supports_discarded_packets;
557 stream_class->discarded_packets_have_default_clock_snapshots =
558 (bool) with_default_clock_snapshots;
a684a357 559 BT_LIB_LOGD("Set stream class's discarded packets support property: "
77037b2b
PP
560 "%!+S", stream_class);
561}
562
563bt_bool bt_stream_class_supports_discarded_packets(
564 const struct bt_stream_class *stream_class)
565{
566 BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
567 return (bt_bool) stream_class->supports_discarded_packets;
568}
569
570bt_bool bt_stream_class_discarded_packets_have_default_clock_snapshots(
571 const struct bt_stream_class *stream_class)
572{
573 BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
574 return (bt_bool) stream_class->discarded_packets_have_default_clock_snapshots;
575}
576
78cf9df6
PP
577void bt_stream_class_set_assigns_automatic_stream_id(
578 struct bt_stream_class *stream_class,
9e550e5f 579 bt_bool value)
7b33a0e0
PP
580{
581 BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
582 BT_ASSERT_PRE_STREAM_CLASS_HOT(stream_class);
583 stream_class->assigns_automatic_stream_id = (bool) value;
a684a357 584 BT_LIB_LOGD("Set stream class's automatic stream ID "
7b33a0e0 585 "assignment property: %!+S", stream_class);
7b33a0e0 586}
8deee039 587
8c6884d9
PP
588void bt_stream_class_get_ref(const struct bt_stream_class *stream_class)
589{
590 bt_object_get_ref(stream_class);
591}
592
593void bt_stream_class_put_ref(const struct bt_stream_class *stream_class)
594{
595 bt_object_put_ref(stream_class);
596}
This page took 0.104908 seconds and 4 git commands to generate.