lib: graph: add "self" and some "private" APIs
[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
8deee039 28#include <babeltrace/assert-pre-internal.h>
108b91d0
PP
29#include <babeltrace/trace-ir/clock-class-internal.h>
30#include <babeltrace/trace-ir/event-class-internal.h>
939190b3 31#include <babeltrace/trace-ir/field-classes-internal.h>
108b91d0
PP
32#include <babeltrace/trace-ir/fields-internal.h>
33#include <babeltrace/trace-ir/stream-class-internal.h>
9e550e5f
PP
34#include <babeltrace/trace-ir/private-trace.h>
35#include <babeltrace/trace-ir/trace-internal.h>
108b91d0
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>
8138bfe1 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>
8b45963b 43#include <babeltrace/assert-internal.h>
7b33a0e0 44#include <babeltrace/property-internal.h>
dc3fffef 45#include <inttypes.h>
544d0515 46#include <stdint.h>
e011d2c1 47#include <stdbool.h>
11b0cdc8 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.");
8138bfe1 59 bt_object_put_ref(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);
d2f71f12
PP
64 }
65
7b33a0e0
PP
66 if (stream_class->name.str) {
67 g_string_free(stream_class->name.str, TRUE);
3ea33115
JG
68 }
69
939190b3 70 BT_LOGD_STR("Putting event header field classe.");
8138bfe1 71 bt_object_put_ref(stream_class->event_header_fc);
939190b3 72 BT_LOGD_STR("Putting packet context field classe.");
8138bfe1 73 bt_object_put_ref(stream_class->packet_context_fc);
939190b3 74 BT_LOGD_STR("Putting event common context field classe.");
8138bfe1 75 bt_object_put_ref(stream_class->event_common_context_fc);
a6918753
PP
76 bt_object_pool_finalize(&stream_class->event_header_field_pool);
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
90bool stream_class_id_is_unique(struct bt_trace *trace, uint64_t id)
91{
92 uint64_t i;
93 bool is_unique = true;
94
95 for (i = 0; i < trace->stream_classes->len; i++) {
96 struct bt_stream_class *sc =
97 trace->stream_classes->pdata[i];
98
99 if (sc->id == id) {
100 is_unique = false;
101 goto end;
102 }
103 }
104
105end:
106 return is_unique;
107}
108
109static
110struct bt_stream_class *create_stream_class_with_id(struct bt_trace *trace,
111 uint64_t id)
2f100782 112{
8deee039
PP
113 struct bt_stream_class *stream_class = NULL;
114 int ret;
2f100782 115
7b33a0e0
PP
116 BT_ASSERT(trace);
117 BT_ASSERT_PRE(stream_class_id_is_unique(trace, id),
118 "Duplicate stream class ID: %![trace-]+t, id=%" PRIu64,
119 trace, id);
120 BT_LIB_LOGD("Creating stream class object: %![trace-]+t, id=%" PRIu64,
121 trace, id);
8deee039 122 stream_class = g_new0(struct bt_stream_class, 1);
d2f71f12 123 if (!stream_class) {
8deee039
PP
124 BT_LOGE_STR("Failed to allocate one stream class.");
125 goto error;
d2f71f12
PP
126 }
127
7b33a0e0
PP
128 bt_object_init_shared_with_parent(&stream_class->base,
129 destroy_stream_class);
130
131 stream_class->name.str = g_string_new(NULL);
132 if (!stream_class->name.str) {
133 BT_LOGE_STR("Failed to allocate a GString.");
134 ret = -1;
135 goto end;
136 }
137
138 stream_class->id = id;
139 stream_class->assigns_automatic_event_class_id = true;
140 stream_class->assigns_automatic_stream_id = true;
141 stream_class->event_classes = g_ptr_array_new_with_free_func(
142 (GDestroyNotify) bt_object_try_spec_release);
143 if (!stream_class->event_classes) {
144 BT_LOGE_STR("Failed to allocate a GPtrArray.");
8deee039 145 goto error;
2f100782
JG
146 }
147
a6918753
PP
148 ret = bt_object_pool_initialize(&stream_class->event_header_field_pool,
149 (bt_object_pool_new_object_func) bt_field_wrapper_new,
150 (bt_object_pool_destroy_object_func) free_field_wrapper,
151 stream_class);
152 if (ret) {
153 BT_LOGE("Failed to initialize event header field pool: ret=%d",
154 ret);
155 goto error;
156 }
157
158 ret = bt_object_pool_initialize(&stream_class->packet_context_field_pool,
159 (bt_object_pool_new_object_func) bt_field_wrapper_new,
160 (bt_object_pool_destroy_object_func) free_field_wrapper,
161 stream_class);
162 if (ret) {
163 BT_LOGE("Failed to initialize packet context field pool: ret=%d",
164 ret);
165 goto error;
166 }
167
7b33a0e0
PP
168 bt_object_set_parent(&stream_class->base, &trace->base);
169 g_ptr_array_add(trace->stream_classes, stream_class);
170 bt_trace_freeze(trace);
171 BT_LIB_LOGD("Created stream class object: %!+S", stream_class);
a6918753
PP
172 goto end;
173
174error:
8138bfe1 175 BT_OBJECT_PUT_REF_AND_RESET(stream_class);
a6918753
PP
176
177end:
7b33a0e0 178 return stream_class;
a6918753
PP
179}
180
9e550e5f
PP
181struct bt_private_stream_class *bt_private_stream_class_create(
182 struct bt_private_trace *priv_trace)
a6918753 183{
9e550e5f
PP
184 struct bt_trace *trace = (void *) priv_trace;
185
7b33a0e0
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);
9e550e5f 190 return (void *) create_stream_class_with_id(trace,
7b33a0e0
PP
191 (uint64_t) trace->stream_classes->len);
192}
a6918753 193
9e550e5f
PP
194struct bt_private_stream_class *bt_private_stream_class_create_with_id(
195 struct bt_private_trace *priv_trace, uint64_t id)
7b33a0e0 196{
9e550e5f
PP
197 struct bt_trace *trace = (void *) priv_trace;
198
7b33a0e0
PP
199 BT_ASSERT_PRE_NON_NULL(trace, "Trace");
200 BT_ASSERT_PRE(!trace->assigns_automatic_stream_class_id,
201 "Trace automatically assigns stream class IDs: "
202 "%![sc-]+t", trace);
9e550e5f 203 return (void *) create_stream_class_with_id(trace, id);
a6918753
PP
204}
205
5fe68922 206struct bt_trace *bt_stream_class_borrow_trace(struct bt_stream_class *stream_class)
11b0cdc8 207{
7b33a0e0
PP
208 BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
209 return bt_stream_class_borrow_trace_inline(stream_class);
11b0cdc8
JG
210}
211
9e550e5f
PP
212struct bt_private_trace *bt_private_stream_class_borrow_trace(
213 struct bt_private_stream_class *stream_class)
214{
215 return (void *) bt_stream_class_borrow_trace((void *) stream_class);
216}
217
8deee039 218const char *bt_stream_class_get_name(struct bt_stream_class *stream_class)
2f100782 219{
18acc6f8 220 BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
7b33a0e0 221 return stream_class->name.value;
2f100782
JG
222}
223
9e550e5f
PP
224int bt_private_stream_class_set_name(
225 struct bt_private_stream_class *priv_stream_class,
8deee039 226 const char *name)
5ca83563 227{
9e550e5f
PP
228 struct bt_stream_class *stream_class = (void *) priv_stream_class;
229
7b33a0e0
PP
230 BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
231 BT_ASSERT_PRE_NON_NULL(name, "Name");
232 BT_ASSERT_PRE_STREAM_CLASS_HOT(stream_class);
233 g_string_assign(stream_class->name.str, name);
234 stream_class->name.value = stream_class->name.str->str;
235 BT_LIB_LOGV("Set stream class's name: %!+S", stream_class);
236 return 0;
5ca83563
JG
237}
238
7b33a0e0 239uint64_t bt_stream_class_get_id(struct bt_stream_class *stream_class)
2f100782 240{
18acc6f8 241 BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
7b33a0e0 242 return stream_class->id;
2f100782
JG
243}
244
7b33a0e0
PP
245uint64_t bt_stream_class_get_event_class_count(
246 struct bt_stream_class *stream_class)
29664b2a 247{
7b33a0e0
PP
248 BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
249 return (uint64_t) stream_class->event_classes->len;
29664b2a
PP
250}
251
7b33a0e0
PP
252struct bt_event_class *bt_stream_class_borrow_event_class_by_index(
253 struct bt_stream_class *stream_class, uint64_t index)
0d23acbe 254{
7b33a0e0
PP
255 BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
256 BT_ASSERT_PRE_VALID_INDEX(index, stream_class->event_classes->len);
257 return g_ptr_array_index(stream_class->event_classes, index);
0d23acbe
PP
258}
259
9e550e5f 260struct bt_private_event_class *
96854e6a 261bt_private_stream_class_borrow_event_class_by_index(
9e550e5f
PP
262 struct bt_private_stream_class *stream_class, uint64_t index)
263{
264 return (void *) bt_stream_class_borrow_event_class_by_index(
265 (void *) stream_class, index);
266}
267
7b33a0e0 268struct bt_event_class *bt_stream_class_borrow_event_class_by_id(
9e550e5f 269 struct bt_stream_class *stream_class, uint64_t id)
11b0cdc8 270{
7b33a0e0
PP
271 struct bt_event_class *event_class = NULL;
272 uint64_t i;
0b9ce69f 273
9e550e5f 274 BT_ASSERT_PRE_NON_NULL(stream_class, "Trace");
11b0cdc8 275
9e550e5f 276 for (i = 0; i < stream_class->event_classes->len; i++) {
7b33a0e0 277 struct bt_event_class *event_class_candidate =
9e550e5f 278 g_ptr_array_index(stream_class->event_classes, i);
e6a8e8e4 279
7b33a0e0
PP
280 if (event_class_candidate->id == id) {
281 event_class = event_class_candidate;
09840de5
PP
282 goto end;
283 }
69dc4535
JG
284 }
285
69dc4535 286end:
7b33a0e0 287 return event_class;
0863f950
PP
288}
289
9e550e5f 290struct bt_private_event_class *
96854e6a 291bt_private_stream_class_borrow_event_class_by_id(
9e550e5f
PP
292 struct bt_private_stream_class *stream_class, uint64_t id)
293{
294 return (void *) bt_stream_class_borrow_event_class_by_id(
295 (void *) stream_class, id);
296}
297
939190b3 298struct bt_field_class *bt_stream_class_borrow_packet_context_field_class(
839d52a5 299 struct bt_stream_class *stream_class)
12c8a1a3 300{
18acc6f8 301 BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
939190b3 302 return stream_class->packet_context_fc;
12c8a1a3
JG
303}
304
9e550e5f 305struct bt_private_field_class *
96854e6a 306bt_private_stream_class_borrow_packet_context_field_class(
9e550e5f
PP
307 struct bt_private_stream_class *stream_class)
308{
309 return (void *) bt_stream_class_borrow_packet_context_field_class(
310 (void *) stream_class);
311}
312
96854e6a 313int bt_private_stream_class_set_packet_context_field_class(
9e550e5f
PP
314 struct bt_private_stream_class *priv_stream_class,
315 struct bt_private_field_class *priv_field_class)
12c8a1a3 316{
7b33a0e0 317 int ret;
9e550e5f
PP
318 struct bt_stream_class *stream_class = (void *) priv_stream_class;
319 struct bt_field_class *field_class = (void *) priv_field_class;
7b33a0e0
PP
320 struct bt_resolve_field_path_context resolve_ctx = {
321 .packet_header = NULL,
939190b3 322 .packet_context = field_class,
7b33a0e0
PP
323 .event_header = NULL,
324 .event_common_context = NULL,
325 .event_specific_context = NULL,
326 .event_payload = NULL,
327 };
18acc6f8 328
7b33a0e0 329 BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
939190b3 330 BT_ASSERT_PRE_NON_NULL(field_class, "Field class");
7b33a0e0 331 BT_ASSERT_PRE_STREAM_CLASS_HOT(stream_class);
af0c18e3
PP
332 BT_ASSERT_PRE(bt_field_class_get_type(field_class) ==
333 BT_FIELD_CLASS_TYPE_STRUCTURE,
939190b3
PP
334 "Packet context field classe is not a structure field classe: %!+F",
335 field_class);
7b33a0e0 336 resolve_ctx.packet_header =
939190b3
PP
337 bt_stream_class_borrow_trace_inline(stream_class)->packet_header_fc;
338 ret = bt_resolve_field_paths(field_class, &resolve_ctx);
7b33a0e0 339 if (ret) {
18acc6f8
PP
340 goto end;
341 }
342
939190b3 343 bt_field_class_make_part_of_trace(field_class);
8138bfe1
PP
344 bt_object_put_ref(stream_class->packet_context_fc);
345 stream_class->packet_context_fc = bt_object_get_ref(field_class);
939190b3
PP
346 bt_field_class_freeze(field_class);
347 BT_LIB_LOGV("Set stream class's packet context field classe: %!+S",
7b33a0e0 348 stream_class);
18acc6f8
PP
349
350end:
351 return ret;
12c8a1a3
JG
352}
353
939190b3 354struct bt_field_class *bt_stream_class_borrow_event_header_field_class(
839d52a5 355 struct bt_stream_class *stream_class)
662e778c 356{
18acc6f8 357 BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
939190b3 358 return stream_class->event_header_fc;
662e778c
JG
359}
360
9e550e5f 361struct bt_private_field_class *
96854e6a 362bt_private_stream_class_borrow_event_header_field_class(
9e550e5f
PP
363 struct bt_private_stream_class *stream_class)
364{
365 return (void *) bt_stream_class_borrow_event_header_field_class(
366 (void *) stream_class);
367}
368
96854e6a 369int bt_private_stream_class_set_event_header_field_class(
9e550e5f
PP
370 struct bt_private_stream_class *priv_stream_class,
371 struct bt_private_field_class *priv_field_class)
662e778c 372{
7b33a0e0 373 int ret;
9e550e5f
PP
374 struct bt_stream_class *stream_class = (void *) priv_stream_class;
375 struct bt_field_class *field_class = (void *) priv_field_class;
7b33a0e0
PP
376 struct bt_resolve_field_path_context resolve_ctx = {
377 .packet_header = NULL,
378 .packet_context = NULL,
939190b3 379 .event_header = field_class,
7b33a0e0
PP
380 .event_common_context = NULL,
381 .event_specific_context = NULL,
382 .event_payload = NULL,
383 };
18acc6f8 384
7b33a0e0 385 BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
939190b3 386 BT_ASSERT_PRE_NON_NULL(field_class, "Field class");
7b33a0e0 387 BT_ASSERT_PRE_STREAM_CLASS_HOT(stream_class);
af0c18e3
PP
388 BT_ASSERT_PRE(bt_field_class_get_type(field_class) ==
389 BT_FIELD_CLASS_TYPE_STRUCTURE,
939190b3
PP
390 "Event header field classe is not a structure field classe: %!+F",
391 field_class);
7b33a0e0 392 resolve_ctx.packet_header =
939190b3
PP
393 bt_stream_class_borrow_trace_inline(stream_class)->packet_header_fc;
394 resolve_ctx.packet_context = stream_class->packet_context_fc;
395 ret = bt_resolve_field_paths(field_class, &resolve_ctx);
7b33a0e0 396 if (ret) {
18acc6f8
PP
397 goto end;
398 }
399
939190b3 400 bt_field_class_make_part_of_trace(field_class);
8138bfe1
PP
401 bt_object_put_ref(stream_class->event_header_fc);
402 stream_class->event_header_fc = bt_object_get_ref(field_class);
939190b3
PP
403 bt_field_class_freeze(field_class);
404 BT_LIB_LOGV("Set stream class's event header field classe: %!+S",
7b33a0e0 405 stream_class);
18acc6f8 406
18acc6f8
PP
407end:
408 return ret;
662e778c
JG
409}
410
939190b3 411struct bt_field_class *bt_stream_class_borrow_event_common_context_field_class(
839d52a5 412 struct bt_stream_class *stream_class)
af181248 413{
18acc6f8 414 BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
939190b3 415 return stream_class->event_common_context_fc;
af181248
JG
416}
417
9e550e5f 418struct bt_private_field_class *
96854e6a 419bt_private_stream_class_borrow_event_common_context_field_class(
9e550e5f
PP
420 struct bt_private_stream_class *stream_class)
421{
422 return (void *) bt_stream_class_borrow_event_common_context_field_class(
423 (void *) stream_class);
424}
425
96854e6a 426int bt_private_stream_class_set_event_common_context_field_class(
9e550e5f
PP
427 struct bt_private_stream_class *priv_stream_class,
428 struct bt_private_field_class *priv_field_class)
af181248 429{
7b33a0e0 430 int ret;
9e550e5f
PP
431 struct bt_stream_class *stream_class = (void *) priv_stream_class;
432 struct bt_field_class *field_class = (void *) priv_field_class;
7b33a0e0
PP
433 struct bt_resolve_field_path_context resolve_ctx = {
434 .packet_header = NULL,
435 .packet_context = NULL,
436 .event_header = NULL,
939190b3 437 .event_common_context = field_class,
7b33a0e0
PP
438 .event_specific_context = NULL,
439 .event_payload = NULL,
440 };
18acc6f8 441
7b33a0e0 442 BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
939190b3 443 BT_ASSERT_PRE_NON_NULL(field_class, "Field class");
7b33a0e0 444 BT_ASSERT_PRE_STREAM_CLASS_HOT(stream_class);
af0c18e3
PP
445 BT_ASSERT_PRE(bt_field_class_get_type(field_class) ==
446 BT_FIELD_CLASS_TYPE_STRUCTURE,
939190b3
PP
447 "Event common context field classe is not a structure field classe: %!+F",
448 field_class);
7b33a0e0 449 resolve_ctx.packet_header =
939190b3
PP
450 bt_stream_class_borrow_trace_inline(stream_class)->packet_header_fc;
451 resolve_ctx.packet_context = stream_class->packet_context_fc;
452 resolve_ctx.event_header = stream_class->event_header_fc;
453 ret = bt_resolve_field_paths(field_class, &resolve_ctx);
7b33a0e0 454 if (ret) {
18acc6f8
PP
455 goto end;
456 }
457
939190b3 458 bt_field_class_make_part_of_trace(field_class);
8138bfe1
PP
459 bt_object_put_ref(stream_class->event_common_context_fc);
460 stream_class->event_common_context_fc = bt_object_get_ref(field_class);
939190b3
PP
461 bt_field_class_freeze(field_class);
462 BT_LIB_LOGV("Set stream class's event common context field classe: %!+S",
7b33a0e0 463 stream_class);
18acc6f8 464
18acc6f8
PP
465end:
466 return ret;
11b0cdc8
JG
467}
468
7b33a0e0
PP
469BT_HIDDEN
470void _bt_stream_class_freeze(struct bt_stream_class *stream_class)
8bf65fbd 471{
939190b3 472 /* The field classes and default clock class are already frozen */
7b33a0e0
PP
473 BT_ASSERT(stream_class);
474 BT_LIB_LOGD("Freezing stream class: %!+S", stream_class);
475 stream_class->frozen = true;
8bf65fbd
JG
476}
477
9e550e5f
PP
478int bt_private_stream_class_set_default_clock_class(
479 struct bt_private_stream_class *priv_stream_class,
7b33a0e0 480 struct bt_clock_class *clock_class)
8bf65fbd 481{
9e550e5f
PP
482 struct bt_stream_class *stream_class = (void *) priv_stream_class;
483
7b33a0e0
PP
484 BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
485 BT_ASSERT_PRE_NON_NULL(clock_class, "Clock class");
486 BT_ASSERT_PRE_STREAM_CLASS_HOT(stream_class);
8138bfe1
PP
487 bt_object_put_ref(stream_class->default_clock_class);
488 stream_class->default_clock_class = bt_object_get_ref(clock_class);
7b33a0e0
PP
489 bt_clock_class_freeze(clock_class);
490 BT_LIB_LOGV("Set stream class's default clock class: %!+S",
491 stream_class);
492 return 0;
8bf65fbd
JG
493}
494
7b33a0e0
PP
495struct bt_clock_class *bt_stream_class_borrow_default_clock_class(
496 struct bt_stream_class *stream_class)
8bf65fbd 497{
7b33a0e0
PP
498 BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
499 return stream_class->default_clock_class;
500}
8bf65fbd 501
7b33a0e0
PP
502bt_bool bt_stream_class_assigns_automatic_event_class_id(
503 struct bt_stream_class *stream_class)
504{
505 BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
506 return (bt_bool) stream_class->assigns_automatic_event_class_id;
8bf65fbd
JG
507}
508
9e550e5f
PP
509int bt_private_stream_class_set_assigns_automatic_event_class_id(
510 struct bt_private_stream_class *priv_stream_class,
511 bt_bool value)
8bf65fbd 512{
9e550e5f
PP
513 struct bt_stream_class *stream_class = (void *) priv_stream_class;
514
7b33a0e0
PP
515 BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
516 BT_ASSERT_PRE_STREAM_CLASS_HOT(stream_class);
517 stream_class->assigns_automatic_event_class_id = (bool) value;
518 BT_LIB_LOGV("Set stream class's automatic event class ID "
519 "assignment property: %!+S", stream_class);
520 return 0;
521}
8bf65fbd 522
7b33a0e0
PP
523bt_bool bt_stream_class_assigns_automatic_stream_id(
524 struct bt_stream_class *stream_class)
525{
526 BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
527 return (bt_bool) stream_class->assigns_automatic_stream_id;
528}
8bf65fbd 529
9e550e5f
PP
530int bt_private_stream_class_set_assigns_automatic_stream_id(
531 struct bt_private_stream_class *priv_stream_class,
532 bt_bool value)
7b33a0e0 533{
9e550e5f
PP
534 struct bt_stream_class *stream_class = (void *) priv_stream_class;
535
7b33a0e0
PP
536 BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
537 BT_ASSERT_PRE_STREAM_CLASS_HOT(stream_class);
538 stream_class->assigns_automatic_stream_id = (bool) value;
539 BT_LIB_LOGV("Set stream class's automatic stream ID "
540 "assignment property: %!+S", stream_class);
541 return 0;
542}
8deee039 543
7b33a0e0
PP
544bt_bool bt_stream_class_packets_have_discarded_event_counter_snapshot(
545 struct bt_stream_class *stream_class)
546{
547 BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
548 return (bt_bool) stream_class->packets_have_discarded_event_counter_snapshot;
8bf65fbd
JG
549}
550
9e550e5f
PP
551int bt_private_stream_class_set_packets_have_discarded_event_counter_snapshot(
552 struct bt_private_stream_class *priv_stream_class,
553 bt_bool value)
11b0cdc8 554{
9e550e5f
PP
555 struct bt_stream_class *stream_class = (void *) priv_stream_class;
556
7b33a0e0
PP
557 BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
558 BT_ASSERT_PRE_STREAM_CLASS_HOT(stream_class);
559 stream_class->packets_have_discarded_event_counter_snapshot =
560 (bool) value;
561 BT_LIB_LOGV("Set stream class's "
562 "\"packets have discarded event counter snapshot\" property: "
563 "%!+S", stream_class);
564 return 0;
565}
11b0cdc8 566
7b33a0e0
PP
567bt_bool bt_stream_class_packets_have_packet_counter_snapshot(
568 struct bt_stream_class *stream_class)
569{
570 BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
571 return (bt_bool) stream_class->packets_have_packet_counter_snapshot;
11b0cdc8
JG
572}
573
9e550e5f
PP
574int bt_private_stream_class_set_packets_have_packet_counter_snapshot(
575 struct bt_private_stream_class *priv_stream_class,
576 bt_bool value)
8c4a29ba 577{
9e550e5f
PP
578 struct bt_stream_class *stream_class = (void *) priv_stream_class;
579
7b33a0e0
PP
580 BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
581 BT_ASSERT_PRE_STREAM_CLASS_HOT(stream_class);
582 stream_class->packets_have_packet_counter_snapshot =
583 (bool) value;
584 BT_LIB_LOGV("Set stream class's "
585 "\"packets have packet counter snapshot\" property: "
586 "%!+S", stream_class);
587 return 0;
588}
8c4a29ba 589
7b33a0e0
PP
590bt_bool bt_stream_class_packets_have_default_beginning_clock_value(
591 struct bt_stream_class *stream_class)
592{
593 BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
594 return (bt_bool) stream_class->packets_have_default_beginning_cv;
595}
8c4a29ba 596
9e550e5f
PP
597int bt_private_stream_class_set_packets_have_default_beginning_clock_value(
598 struct bt_private_stream_class *priv_stream_class,
599 bt_bool value)
7b33a0e0 600{
9e550e5f
PP
601 struct bt_stream_class *stream_class = (void *) priv_stream_class;
602
7b33a0e0
PP
603 BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
604 BT_ASSERT_PRE_STREAM_CLASS_HOT(stream_class);
605 BT_ASSERT_PRE(!value || stream_class->default_clock_class,
606 "Stream class does not have a default clock class: %!+S",
607 stream_class);
608 stream_class->packets_have_default_beginning_cv = (bool) value;
609 BT_LIB_LOGV("Set stream class's "
610 "\"packets have default beginning clock value\" property: "
611 "%!+S", stream_class);
612 return 0;
613}
8c4a29ba 614
7b33a0e0
PP
615bt_bool bt_stream_class_packets_have_default_end_clock_value(
616 struct bt_stream_class *stream_class)
617{
618 BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
619 return (bt_bool) stream_class->packets_have_default_end_cv;
620}
8c4a29ba 621
9e550e5f
PP
622int bt_private_stream_class_set_packets_have_default_end_clock_value(
623 struct bt_private_stream_class *priv_stream_class,
624 bt_bool value)
7b33a0e0 625{
9e550e5f
PP
626 struct bt_stream_class *stream_class = (void *) priv_stream_class;
627
7b33a0e0
PP
628 BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
629 BT_ASSERT_PRE_STREAM_CLASS_HOT(stream_class);
630 BT_ASSERT_PRE(!value || stream_class->default_clock_class,
631 "Stream class does not have a default clock class: %!+S",
632 stream_class);
633 stream_class->packets_have_default_end_cv = (bool) value;
634 BT_LIB_LOGV("Set stream class's "
635 "\"packets have default end clock value\" property: "
636 "%!+S", stream_class);
637 return 0;
638}
8c4a29ba 639
7b33a0e0
PP
640bt_bool bt_stream_class_default_clock_is_always_known(
641 struct bt_stream_class *stream_class)
642{
643 /* BT_CLOCK_VALUE_STATUS_UNKNOWN is not supported as of 2.0 */
644 return BT_TRUE;
8c4a29ba 645}
This page took 0.081201 seconds and 4 git commands to generate.