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
3dca2276 28#include <babeltrace/assert-pre-internal.h>
56e18c4c
PP
29#include <babeltrace/trace-ir/clock-class-internal.h>
30#include <babeltrace/trace-ir/event-class-internal.h>
5cd6d0e5 31#include <babeltrace/trace-ir/field-classes-internal.h>
56e18c4c
PP
32#include <babeltrace/trace-ir/fields-internal.h>
33#include <babeltrace/trace-ir/stream-class-internal.h>
e5be10ef
PP
34#include <babeltrace/trace-ir/private-trace.h>
35#include <babeltrace/trace-ir/trace-internal.h>
56e18c4c
PP
36#include <babeltrace/trace-ir/utils-internal.h>
37#include <babeltrace/trace-ir/field-wrapper-internal.h>
38#include <babeltrace/trace-ir/resolve-field-path-internal.h>
65300d60 39#include <babeltrace/object.h>
3d9990ac
PP
40#include <babeltrace/compiler-internal.h>
41#include <babeltrace/align-internal.h>
42#include <babeltrace/endian-internal.h>
f6ccaed9 43#include <babeltrace/assert-internal.h>
44c440bc 44#include <babeltrace/property-internal.h>
dc3fffef 45#include <inttypes.h>
544d0515 46#include <stdint.h>
e011d2c1 47#include <stdbool.h>
11b0cdc8 48
44c440bc
PP
49#define BT_ASSERT_PRE_STREAM_CLASS_HOT(_sc) \
50 BT_ASSERT_PRE_HOT((_sc), "Stream class", ": %!+S", (_sc))
142c5610 51
cb6f1f7d 52static
44c440bc 53void destroy_stream_class(struct bt_object *obj)
3ea33115 54{
cb6f1f7d
PP
55 struct bt_stream_class *stream_class = (void *) obj;
56
44c440bc
PP
57 BT_LIB_LOGD("Destroying stream class: %!+S", stream_class);
58 BT_LOGD_STR("Putting default clock class.");
65300d60 59 bt_object_put_ref(stream_class->default_clock_class);
3ea33115 60
3dca2276
PP
61 if (stream_class->event_classes) {
62 BT_LOGD_STR("Destroying event classes.");
63 g_ptr_array_free(stream_class->event_classes, TRUE);
d2f71f12
PP
64 }
65
44c440bc
PP
66 if (stream_class->name.str) {
67 g_string_free(stream_class->name.str, TRUE);
3ea33115
JG
68 }
69
5cd6d0e5 70 BT_LOGD_STR("Putting event header field classe.");
65300d60 71 bt_object_put_ref(stream_class->event_header_fc);
5cd6d0e5 72 BT_LOGD_STR("Putting packet context field classe.");
65300d60 73 bt_object_put_ref(stream_class->packet_context_fc);
5cd6d0e5 74 BT_LOGD_STR("Putting event common context field classe.");
65300d60 75 bt_object_put_ref(stream_class->event_common_context_fc);
312c056a
PP
76 bt_object_pool_finalize(&stream_class->event_header_field_pool);
77 bt_object_pool_finalize(&stream_class->packet_context_field_pool);
3dca2276 78 g_free(stream_class);
3ea33115
JG
79}
80
312c056a
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
44c440bc
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{
3dca2276
PP
113 struct bt_stream_class *stream_class = NULL;
114 int ret;
2f100782 115
44c440bc
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);
3dca2276 122 stream_class = g_new0(struct bt_stream_class, 1);
d2f71f12 123 if (!stream_class) {
3dca2276
PP
124 BT_LOGE_STR("Failed to allocate one stream class.");
125 goto error;
d2f71f12
PP
126 }
127
44c440bc
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.");
3dca2276 145 goto error;
2f100782
JG
146 }
147
312c056a
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
44c440bc
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);
312c056a
PP
172 goto end;
173
174error:
65300d60 175 BT_OBJECT_PUT_REF_AND_RESET(stream_class);
312c056a
PP
176
177end:
44c440bc 178 return stream_class;
312c056a
PP
179}
180
e5be10ef
PP
181struct bt_private_stream_class *bt_private_stream_class_create(
182 struct bt_private_trace *priv_trace)
312c056a 183{
e5be10ef
PP
184 struct bt_trace *trace = (void *) priv_trace;
185
44c440bc
PP
186 BT_ASSERT_PRE_NON_NULL(trace, "Trace");
187 BT_ASSERT_PRE(trace->assigns_automatic_stream_class_id,
188 "Trace does not automatically assigns stream class IDs: "
189 "%![sc-]+t", trace);
e5be10ef 190 return (void *) create_stream_class_with_id(trace,
44c440bc
PP
191 (uint64_t) trace->stream_classes->len);
192}
312c056a 193
e5be10ef
PP
194struct bt_private_stream_class *bt_private_stream_class_create_with_id(
195 struct bt_private_trace *priv_trace, uint64_t id)
44c440bc 196{
e5be10ef
PP
197 struct bt_trace *trace = (void *) priv_trace;
198
44c440bc
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);
e5be10ef 203 return (void *) create_stream_class_with_id(trace, id);
312c056a
PP
204}
205
094ff7c0 206struct bt_trace *bt_stream_class_borrow_trace(struct bt_stream_class *stream_class)
11b0cdc8 207{
44c440bc
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
e5be10ef
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
3dca2276 218const char *bt_stream_class_get_name(struct bt_stream_class *stream_class)
2f100782 219{
cb6f1f7d 220 BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
44c440bc 221 return stream_class->name.value;
2f100782
JG
222}
223
e5be10ef
PP
224int bt_private_stream_class_set_name(
225 struct bt_private_stream_class *priv_stream_class,
3dca2276 226 const char *name)
5ca83563 227{
e5be10ef
PP
228 struct bt_stream_class *stream_class = (void *) priv_stream_class;
229
44c440bc
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
44c440bc 239uint64_t bt_stream_class_get_id(struct bt_stream_class *stream_class)
2f100782 240{
cb6f1f7d 241 BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
44c440bc 242 return stream_class->id;
2f100782
JG
243}
244
44c440bc
PP
245uint64_t bt_stream_class_get_event_class_count(
246 struct bt_stream_class *stream_class)
29664b2a 247{
44c440bc
PP
248 BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
249 return (uint64_t) stream_class->event_classes->len;
29664b2a
PP
250}
251
44c440bc
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{
44c440bc
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
e5be10ef 260struct bt_private_event_class *
28e6ca8b 261bt_private_stream_class_borrow_event_class_by_index(
e5be10ef
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
44c440bc 268struct bt_event_class *bt_stream_class_borrow_event_class_by_id(
e5be10ef 269 struct bt_stream_class *stream_class, uint64_t id)
11b0cdc8 270{
44c440bc
PP
271 struct bt_event_class *event_class = NULL;
272 uint64_t i;
0b9ce69f 273
e5be10ef 274 BT_ASSERT_PRE_NON_NULL(stream_class, "Trace");
11b0cdc8 275
e5be10ef 276 for (i = 0; i < stream_class->event_classes->len; i++) {
44c440bc 277 struct bt_event_class *event_class_candidate =
e5be10ef 278 g_ptr_array_index(stream_class->event_classes, i);
e6a8e8e4 279
44c440bc
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:
44c440bc 287 return event_class;
0863f950
PP
288}
289
e5be10ef 290struct bt_private_event_class *
28e6ca8b 291bt_private_stream_class_borrow_event_class_by_id(
e5be10ef
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
5cd6d0e5 298struct bt_field_class *bt_stream_class_borrow_packet_context_field_class(
50842bdc 299 struct bt_stream_class *stream_class)
12c8a1a3 300{
cb6f1f7d 301 BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
5cd6d0e5 302 return stream_class->packet_context_fc;
12c8a1a3
JG
303}
304
e5be10ef 305struct bt_private_field_class *
28e6ca8b 306bt_private_stream_class_borrow_packet_context_field_class(
e5be10ef
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
28e6ca8b 313int bt_private_stream_class_set_packet_context_field_class(
e5be10ef
PP
314 struct bt_private_stream_class *priv_stream_class,
315 struct bt_private_field_class *priv_field_class)
12c8a1a3 316{
44c440bc 317 int ret;
e5be10ef
PP
318 struct bt_stream_class *stream_class = (void *) priv_stream_class;
319 struct bt_field_class *field_class = (void *) priv_field_class;
44c440bc
PP
320 struct bt_resolve_field_path_context resolve_ctx = {
321 .packet_header = NULL,
5cd6d0e5 322 .packet_context = field_class,
44c440bc
PP
323 .event_header = NULL,
324 .event_common_context = NULL,
325 .event_specific_context = NULL,
326 .event_payload = NULL,
327 };
cb6f1f7d 328
44c440bc 329 BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
5cd6d0e5 330 BT_ASSERT_PRE_NON_NULL(field_class, "Field class");
44c440bc 331 BT_ASSERT_PRE_STREAM_CLASS_HOT(stream_class);
864cad70
PP
332 BT_ASSERT_PRE(bt_field_class_get_type(field_class) ==
333 BT_FIELD_CLASS_TYPE_STRUCTURE,
5cd6d0e5
PP
334 "Packet context field classe is not a structure field classe: %!+F",
335 field_class);
44c440bc 336 resolve_ctx.packet_header =
5cd6d0e5
PP
337 bt_stream_class_borrow_trace_inline(stream_class)->packet_header_fc;
338 ret = bt_resolve_field_paths(field_class, &resolve_ctx);
44c440bc 339 if (ret) {
cb6f1f7d
PP
340 goto end;
341 }
342
5cd6d0e5 343 bt_field_class_make_part_of_trace(field_class);
65300d60
PP
344 bt_object_put_ref(stream_class->packet_context_fc);
345 stream_class->packet_context_fc = bt_object_get_ref(field_class);
5cd6d0e5
PP
346 bt_field_class_freeze(field_class);
347 BT_LIB_LOGV("Set stream class's packet context field classe: %!+S",
44c440bc 348 stream_class);
cb6f1f7d
PP
349
350end:
351 return ret;
12c8a1a3
JG
352}
353
5cd6d0e5 354struct bt_field_class *bt_stream_class_borrow_event_header_field_class(
50842bdc 355 struct bt_stream_class *stream_class)
662e778c 356{
cb6f1f7d 357 BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
5cd6d0e5 358 return stream_class->event_header_fc;
662e778c
JG
359}
360
e5be10ef 361struct bt_private_field_class *
28e6ca8b 362bt_private_stream_class_borrow_event_header_field_class(
e5be10ef
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
28e6ca8b 369int bt_private_stream_class_set_event_header_field_class(
e5be10ef
PP
370 struct bt_private_stream_class *priv_stream_class,
371 struct bt_private_field_class *priv_field_class)
662e778c 372{
44c440bc 373 int ret;
e5be10ef
PP
374 struct bt_stream_class *stream_class = (void *) priv_stream_class;
375 struct bt_field_class *field_class = (void *) priv_field_class;
44c440bc
PP
376 struct bt_resolve_field_path_context resolve_ctx = {
377 .packet_header = NULL,
378 .packet_context = NULL,
5cd6d0e5 379 .event_header = field_class,
44c440bc
PP
380 .event_common_context = NULL,
381 .event_specific_context = NULL,
382 .event_payload = NULL,
383 };
cb6f1f7d 384
44c440bc 385 BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
5cd6d0e5 386 BT_ASSERT_PRE_NON_NULL(field_class, "Field class");
44c440bc 387 BT_ASSERT_PRE_STREAM_CLASS_HOT(stream_class);
864cad70
PP
388 BT_ASSERT_PRE(bt_field_class_get_type(field_class) ==
389 BT_FIELD_CLASS_TYPE_STRUCTURE,
5cd6d0e5
PP
390 "Event header field classe is not a structure field classe: %!+F",
391 field_class);
44c440bc 392 resolve_ctx.packet_header =
5cd6d0e5
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);
44c440bc 396 if (ret) {
cb6f1f7d
PP
397 goto end;
398 }
399
5cd6d0e5 400 bt_field_class_make_part_of_trace(field_class);
65300d60
PP
401 bt_object_put_ref(stream_class->event_header_fc);
402 stream_class->event_header_fc = bt_object_get_ref(field_class);
5cd6d0e5
PP
403 bt_field_class_freeze(field_class);
404 BT_LIB_LOGV("Set stream class's event header field classe: %!+S",
44c440bc 405 stream_class);
cb6f1f7d 406
cb6f1f7d
PP
407end:
408 return ret;
662e778c
JG
409}
410
5cd6d0e5 411struct bt_field_class *bt_stream_class_borrow_event_common_context_field_class(
50842bdc 412 struct bt_stream_class *stream_class)
af181248 413{
cb6f1f7d 414 BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
5cd6d0e5 415 return stream_class->event_common_context_fc;
af181248
JG
416}
417
e5be10ef 418struct bt_private_field_class *
28e6ca8b 419bt_private_stream_class_borrow_event_common_context_field_class(
e5be10ef
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
28e6ca8b 426int bt_private_stream_class_set_event_common_context_field_class(
e5be10ef
PP
427 struct bt_private_stream_class *priv_stream_class,
428 struct bt_private_field_class *priv_field_class)
af181248 429{
44c440bc 430 int ret;
e5be10ef
PP
431 struct bt_stream_class *stream_class = (void *) priv_stream_class;
432 struct bt_field_class *field_class = (void *) priv_field_class;
44c440bc
PP
433 struct bt_resolve_field_path_context resolve_ctx = {
434 .packet_header = NULL,
435 .packet_context = NULL,
436 .event_header = NULL,
5cd6d0e5 437 .event_common_context = field_class,
44c440bc
PP
438 .event_specific_context = NULL,
439 .event_payload = NULL,
440 };
cb6f1f7d 441
44c440bc 442 BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
5cd6d0e5 443 BT_ASSERT_PRE_NON_NULL(field_class, "Field class");
44c440bc 444 BT_ASSERT_PRE_STREAM_CLASS_HOT(stream_class);
864cad70
PP
445 BT_ASSERT_PRE(bt_field_class_get_type(field_class) ==
446 BT_FIELD_CLASS_TYPE_STRUCTURE,
5cd6d0e5
PP
447 "Event common context field classe is not a structure field classe: %!+F",
448 field_class);
44c440bc 449 resolve_ctx.packet_header =
5cd6d0e5
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);
44c440bc 454 if (ret) {
cb6f1f7d
PP
455 goto end;
456 }
457
5cd6d0e5 458 bt_field_class_make_part_of_trace(field_class);
65300d60
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);
5cd6d0e5
PP
461 bt_field_class_freeze(field_class);
462 BT_LIB_LOGV("Set stream class's event common context field classe: %!+S",
44c440bc 463 stream_class);
cb6f1f7d 464
cb6f1f7d
PP
465end:
466 return ret;
11b0cdc8
JG
467}
468
44c440bc
PP
469BT_HIDDEN
470void _bt_stream_class_freeze(struct bt_stream_class *stream_class)
8bf65fbd 471{
5cd6d0e5 472 /* The field classes and default clock class are already frozen */
44c440bc
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
e5be10ef
PP
478int bt_private_stream_class_set_default_clock_class(
479 struct bt_private_stream_class *priv_stream_class,
44c440bc 480 struct bt_clock_class *clock_class)
8bf65fbd 481{
e5be10ef
PP
482 struct bt_stream_class *stream_class = (void *) priv_stream_class;
483
44c440bc
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);
65300d60
PP
487 bt_object_put_ref(stream_class->default_clock_class);
488 stream_class->default_clock_class = bt_object_get_ref(clock_class);
44c440bc
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
44c440bc
PP
495struct bt_clock_class *bt_stream_class_borrow_default_clock_class(
496 struct bt_stream_class *stream_class)
8bf65fbd 497{
44c440bc
PP
498 BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
499 return stream_class->default_clock_class;
500}
8bf65fbd 501
44c440bc
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
e5be10ef
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{
e5be10ef
PP
513 struct bt_stream_class *stream_class = (void *) priv_stream_class;
514
44c440bc
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
44c440bc
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
e5be10ef
PP
530int bt_private_stream_class_set_assigns_automatic_stream_id(
531 struct bt_private_stream_class *priv_stream_class,
532 bt_bool value)
44c440bc 533{
e5be10ef
PP
534 struct bt_stream_class *stream_class = (void *) priv_stream_class;
535
44c440bc
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}
3dca2276 543
44c440bc
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
e5be10ef
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{
e5be10ef
PP
555 struct bt_stream_class *stream_class = (void *) priv_stream_class;
556
44c440bc
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
44c440bc
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
e5be10ef
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)
2a3ced3c 577{
e5be10ef
PP
578 struct bt_stream_class *stream_class = (void *) priv_stream_class;
579
44c440bc
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}
2a3ced3c 589
44c440bc
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}
2a3ced3c 596
e5be10ef
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)
44c440bc 600{
e5be10ef
PP
601 struct bt_stream_class *stream_class = (void *) priv_stream_class;
602
44c440bc
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}
2a3ced3c 614
44c440bc
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}
2a3ced3c 621
e5be10ef
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)
44c440bc 625{
e5be10ef
PP
626 struct bt_stream_class *stream_class = (void *) priv_stream_class;
627
44c440bc
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}
2a3ced3c 639
44c440bc
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;
2a3ced3c 645}
This page took 0.08494 seconds and 4 git commands to generate.