/*
- * stream-class.c
- *
- * Babeltrace trace IR - Stream Class
- *
* Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
*
* Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
#include <babeltrace/trace-ir/field-classes-internal.h>
#include <babeltrace/trace-ir/fields-internal.h>
#include <babeltrace/trace-ir/stream-class-internal.h>
+#include <babeltrace/trace-ir/private-trace.h>
+#include <babeltrace/trace-ir/trace-internal.h>
#include <babeltrace/trace-ir/utils-internal.h>
#include <babeltrace/trace-ir/field-wrapper-internal.h>
#include <babeltrace/trace-ir/resolve-field-path-internal.h>
BT_LIB_LOGD("Destroying stream class: %!+S", stream_class);
BT_LOGD_STR("Putting default clock class.");
- bt_object_put_ref(stream_class->default_clock_class);
+ BT_OBJECT_PUT_REF_AND_RESET(stream_class->default_clock_class);
if (stream_class->event_classes) {
BT_LOGD_STR("Destroying event classes.");
g_ptr_array_free(stream_class->event_classes, TRUE);
+ stream_class->event_classes = NULL;
}
if (stream_class->name.str) {
g_string_free(stream_class->name.str, TRUE);
+ stream_class->name.str = NULL;
+ stream_class->name.value = NULL;
}
BT_LOGD_STR("Putting event header field classe.");
- bt_object_put_ref(stream_class->event_header_fc);
+ BT_OBJECT_PUT_REF_AND_RESET(stream_class->event_header_fc);
BT_LOGD_STR("Putting packet context field classe.");
- bt_object_put_ref(stream_class->packet_context_fc);
+ BT_OBJECT_PUT_REF_AND_RESET(stream_class->packet_context_fc);
BT_LOGD_STR("Putting event common context field classe.");
- bt_object_put_ref(stream_class->event_common_context_fc);
+ BT_OBJECT_PUT_REF_AND_RESET(stream_class->event_common_context_fc);
bt_object_pool_finalize(&stream_class->event_header_field_pool);
bt_object_pool_finalize(&stream_class->packet_context_field_pool);
g_free(stream_class);
return stream_class;
}
-struct bt_stream_class *bt_stream_class_create(struct bt_trace *trace)
+struct bt_private_stream_class *bt_private_stream_class_create(
+ struct bt_private_trace *priv_trace)
{
+ struct bt_trace *trace = (void *) priv_trace;
+
BT_ASSERT_PRE_NON_NULL(trace, "Trace");
BT_ASSERT_PRE(trace->assigns_automatic_stream_class_id,
"Trace does not automatically assigns stream class IDs: "
"%![sc-]+t", trace);
- return create_stream_class_with_id(trace,
+ return (void *) create_stream_class_with_id(trace,
(uint64_t) trace->stream_classes->len);
}
-struct bt_stream_class *bt_stream_class_create_with_id(
- struct bt_trace *trace, uint64_t id)
+struct bt_private_stream_class *bt_private_stream_class_create_with_id(
+ struct bt_private_trace *priv_trace, uint64_t id)
{
+ struct bt_trace *trace = (void *) priv_trace;
+
BT_ASSERT_PRE_NON_NULL(trace, "Trace");
BT_ASSERT_PRE(!trace->assigns_automatic_stream_class_id,
"Trace automatically assigns stream class IDs: "
"%![sc-]+t", trace);
- return create_stream_class_with_id(trace, id);
+ return (void *) create_stream_class_with_id(trace, id);
}
struct bt_trace *bt_stream_class_borrow_trace(struct bt_stream_class *stream_class)
return bt_stream_class_borrow_trace_inline(stream_class);
}
+struct bt_private_trace *bt_private_stream_class_borrow_trace(
+ struct bt_private_stream_class *stream_class)
+{
+ return (void *) bt_stream_class_borrow_trace((void *) stream_class);
+}
+
const char *bt_stream_class_get_name(struct bt_stream_class *stream_class)
{
BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
return stream_class->name.value;
}
-int bt_stream_class_set_name(struct bt_stream_class *stream_class,
+int bt_private_stream_class_set_name(
+ struct bt_private_stream_class *priv_stream_class,
const char *name)
{
+ struct bt_stream_class *stream_class = (void *) priv_stream_class;
+
BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
BT_ASSERT_PRE_NON_NULL(name, "Name");
BT_ASSERT_PRE_STREAM_CLASS_HOT(stream_class);
return g_ptr_array_index(stream_class->event_classes, index);
}
+struct bt_private_event_class *
+bt_private_stream_class_borrow_event_class_by_index(
+ struct bt_private_stream_class *stream_class, uint64_t index)
+{
+ return (void *) bt_stream_class_borrow_event_class_by_index(
+ (void *) stream_class, index);
+}
+
struct bt_event_class *bt_stream_class_borrow_event_class_by_id(
- struct bt_stream_class *trace, uint64_t id)
+ struct bt_stream_class *stream_class, uint64_t id)
{
struct bt_event_class *event_class = NULL;
uint64_t i;
- BT_ASSERT_PRE_NON_NULL(trace, "Trace");
+ BT_ASSERT_PRE_NON_NULL(stream_class, "Trace");
- for (i = 0; i < trace->event_classes->len; i++) {
+ for (i = 0; i < stream_class->event_classes->len; i++) {
struct bt_event_class *event_class_candidate =
- g_ptr_array_index(trace->event_classes, i);
+ g_ptr_array_index(stream_class->event_classes, i);
if (event_class_candidate->id == id) {
event_class = event_class_candidate;
return event_class;
}
+struct bt_private_event_class *
+bt_private_stream_class_borrow_event_class_by_id(
+ struct bt_private_stream_class *stream_class, uint64_t id)
+{
+ return (void *) bt_stream_class_borrow_event_class_by_id(
+ (void *) stream_class, id);
+}
+
struct bt_field_class *bt_stream_class_borrow_packet_context_field_class(
struct bt_stream_class *stream_class)
{
return stream_class->packet_context_fc;
}
-int bt_stream_class_set_packet_context_field_class(
- struct bt_stream_class *stream_class,
- struct bt_field_class *field_class)
+struct bt_private_field_class *
+bt_private_stream_class_borrow_packet_context_field_class(
+ struct bt_private_stream_class *stream_class)
+{
+ return (void *) bt_stream_class_borrow_packet_context_field_class(
+ (void *) stream_class);
+}
+
+int bt_private_stream_class_set_packet_context_field_class(
+ struct bt_private_stream_class *priv_stream_class,
+ struct bt_private_field_class *priv_field_class)
{
int ret;
+ struct bt_stream_class *stream_class = (void *) priv_stream_class;
+ struct bt_field_class *field_class = (void *) priv_field_class;
struct bt_resolve_field_path_context resolve_ctx = {
.packet_header = NULL,
.packet_context = field_class,
bt_field_class_make_part_of_trace(field_class);
bt_object_put_ref(stream_class->packet_context_fc);
- stream_class->packet_context_fc = bt_object_get_ref(field_class);
+ stream_class->packet_context_fc = field_class;
+ bt_object_get_no_null_check(stream_class->packet_context_fc);
bt_field_class_freeze(field_class);
BT_LIB_LOGV("Set stream class's packet context field classe: %!+S",
stream_class);
return stream_class->event_header_fc;
}
-int bt_stream_class_set_event_header_field_class(
- struct bt_stream_class *stream_class,
- struct bt_field_class *field_class)
+struct bt_private_field_class *
+bt_private_stream_class_borrow_event_header_field_class(
+ struct bt_private_stream_class *stream_class)
+{
+ return (void *) bt_stream_class_borrow_event_header_field_class(
+ (void *) stream_class);
+}
+
+int bt_private_stream_class_set_event_header_field_class(
+ struct bt_private_stream_class *priv_stream_class,
+ struct bt_private_field_class *priv_field_class)
{
int ret;
+ struct bt_stream_class *stream_class = (void *) priv_stream_class;
+ struct bt_field_class *field_class = (void *) priv_field_class;
struct bt_resolve_field_path_context resolve_ctx = {
.packet_header = NULL,
.packet_context = NULL,
bt_field_class_make_part_of_trace(field_class);
bt_object_put_ref(stream_class->event_header_fc);
- stream_class->event_header_fc = bt_object_get_ref(field_class);
+ stream_class->event_header_fc = field_class;
+ bt_object_get_no_null_check(stream_class->event_header_fc);
bt_field_class_freeze(field_class);
BT_LIB_LOGV("Set stream class's event header field classe: %!+S",
stream_class);
return stream_class->event_common_context_fc;
}
-int bt_stream_class_set_event_common_context_field_class(
- struct bt_stream_class *stream_class,
- struct bt_field_class *field_class)
+struct bt_private_field_class *
+bt_private_stream_class_borrow_event_common_context_field_class(
+ struct bt_private_stream_class *stream_class)
+{
+ return (void *) bt_stream_class_borrow_event_common_context_field_class(
+ (void *) stream_class);
+}
+
+int bt_private_stream_class_set_event_common_context_field_class(
+ struct bt_private_stream_class *priv_stream_class,
+ struct bt_private_field_class *priv_field_class)
{
int ret;
+ struct bt_stream_class *stream_class = (void *) priv_stream_class;
+ struct bt_field_class *field_class = (void *) priv_field_class;
struct bt_resolve_field_path_context resolve_ctx = {
.packet_header = NULL,
.packet_context = NULL,
bt_field_class_make_part_of_trace(field_class);
bt_object_put_ref(stream_class->event_common_context_fc);
- stream_class->event_common_context_fc = bt_object_get_ref(field_class);
+ stream_class->event_common_context_fc = field_class;
+ bt_object_get_no_null_check(stream_class->event_common_context_fc);
bt_field_class_freeze(field_class);
BT_LIB_LOGV("Set stream class's event common context field classe: %!+S",
stream_class);
stream_class->frozen = true;
}
-int bt_stream_class_set_default_clock_class(
- struct bt_stream_class *stream_class,
+int bt_private_stream_class_set_default_clock_class(
+ struct bt_private_stream_class *priv_stream_class,
struct bt_clock_class *clock_class)
{
+ struct bt_stream_class *stream_class = (void *) priv_stream_class;
+
BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
BT_ASSERT_PRE_NON_NULL(clock_class, "Clock class");
BT_ASSERT_PRE_STREAM_CLASS_HOT(stream_class);
bt_object_put_ref(stream_class->default_clock_class);
- stream_class->default_clock_class = bt_object_get_ref(clock_class);
+ stream_class->default_clock_class = clock_class;
+ bt_object_get_no_null_check(stream_class->default_clock_class);
bt_clock_class_freeze(clock_class);
BT_LIB_LOGV("Set stream class's default clock class: %!+S",
stream_class);
return (bt_bool) stream_class->assigns_automatic_event_class_id;
}
-int bt_stream_class_set_assigns_automatic_event_class_id(
- struct bt_stream_class *stream_class, bt_bool value)
+void bt_private_stream_class_set_assigns_automatic_event_class_id(
+ struct bt_private_stream_class *priv_stream_class,
+ bt_bool value)
{
+ struct bt_stream_class *stream_class = (void *) priv_stream_class;
+
BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
BT_ASSERT_PRE_STREAM_CLASS_HOT(stream_class);
stream_class->assigns_automatic_event_class_id = (bool) value;
BT_LIB_LOGV("Set stream class's automatic event class ID "
"assignment property: %!+S", stream_class);
- return 0;
}
bt_bool bt_stream_class_assigns_automatic_stream_id(
return (bt_bool) stream_class->assigns_automatic_stream_id;
}
-int bt_stream_class_set_assigns_automatic_stream_id(
- struct bt_stream_class *stream_class, bt_bool value)
+void bt_private_stream_class_set_assigns_automatic_stream_id(
+ struct bt_private_stream_class *priv_stream_class,
+ bt_bool value)
{
+ struct bt_stream_class *stream_class = (void *) priv_stream_class;
+
BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
BT_ASSERT_PRE_STREAM_CLASS_HOT(stream_class);
stream_class->assigns_automatic_stream_id = (bool) value;
BT_LIB_LOGV("Set stream class's automatic stream ID "
"assignment property: %!+S", stream_class);
- return 0;
}
bt_bool bt_stream_class_packets_have_discarded_event_counter_snapshot(
return (bt_bool) stream_class->packets_have_discarded_event_counter_snapshot;
}
-int bt_stream_class_set_packets_have_discarded_event_counter_snapshot(
- struct bt_stream_class *stream_class, bt_bool value)
+void bt_private_stream_class_set_packets_have_discarded_event_counter_snapshot(
+ struct bt_private_stream_class *priv_stream_class,
+ bt_bool value)
{
+ struct bt_stream_class *stream_class = (void *) priv_stream_class;
+
BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
BT_ASSERT_PRE_STREAM_CLASS_HOT(stream_class);
stream_class->packets_have_discarded_event_counter_snapshot =
BT_LIB_LOGV("Set stream class's "
"\"packets have discarded event counter snapshot\" property: "
"%!+S", stream_class);
- return 0;
}
bt_bool bt_stream_class_packets_have_packet_counter_snapshot(
return (bt_bool) stream_class->packets_have_packet_counter_snapshot;
}
-int bt_stream_class_set_packets_have_packet_counter_snapshot(
- struct bt_stream_class *stream_class, bt_bool value)
+void bt_private_stream_class_set_packets_have_packet_counter_snapshot(
+ struct bt_private_stream_class *priv_stream_class,
+ bt_bool value)
{
+ struct bt_stream_class *stream_class = (void *) priv_stream_class;
+
BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
BT_ASSERT_PRE_STREAM_CLASS_HOT(stream_class);
stream_class->packets_have_packet_counter_snapshot =
BT_LIB_LOGV("Set stream class's "
"\"packets have packet counter snapshot\" property: "
"%!+S", stream_class);
- return 0;
}
bt_bool bt_stream_class_packets_have_default_beginning_clock_value(
return (bt_bool) stream_class->packets_have_default_beginning_cv;
}
-int bt_stream_class_set_packets_have_default_beginning_clock_value(
- struct bt_stream_class *stream_class, bt_bool value)
+void bt_private_stream_class_set_packets_have_default_beginning_clock_value(
+ struct bt_private_stream_class *priv_stream_class,
+ bt_bool value)
{
+ struct bt_stream_class *stream_class = (void *) priv_stream_class;
+
BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
BT_ASSERT_PRE_STREAM_CLASS_HOT(stream_class);
BT_ASSERT_PRE(!value || stream_class->default_clock_class,
BT_LIB_LOGV("Set stream class's "
"\"packets have default beginning clock value\" property: "
"%!+S", stream_class);
- return 0;
}
bt_bool bt_stream_class_packets_have_default_end_clock_value(
return (bt_bool) stream_class->packets_have_default_end_cv;
}
-int bt_stream_class_set_packets_have_default_end_clock_value(
- struct bt_stream_class *stream_class, bt_bool value)
+void bt_private_stream_class_set_packets_have_default_end_clock_value(
+ struct bt_private_stream_class *priv_stream_class,
+ bt_bool value)
{
+ struct bt_stream_class *stream_class = (void *) priv_stream_class;
+
BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
BT_ASSERT_PRE_STREAM_CLASS_HOT(stream_class);
BT_ASSERT_PRE(!value || stream_class->default_clock_class,
BT_LIB_LOGV("Set stream class's "
"\"packets have default end clock value\" property: "
"%!+S", stream_class);
- return 0;
}
bt_bool bt_stream_class_default_clock_is_always_known(