bt_clock_class_create(): accept mandatory trace class
[babeltrace.git] / lib / trace-ir / stream-class.c
index 49a3f350cdc7295271d4a981a7f2e401a3831b67..5fe060c278b80554297a3a97098be47236f46d20 100644 (file)
@@ -35,7 +35,6 @@
 #include <babeltrace/trace-ir/utils-internal.h>
 #include <babeltrace/trace-ir/field-wrapper-internal.h>
 #include <babeltrace/trace-ir/resolve-field-path-internal.h>
-#include <babeltrace/object.h>
 #include <babeltrace/compiler-internal.h>
 #include <babeltrace/align-internal.h>
 #include <babeltrace/endian-internal.h>
@@ -218,7 +217,7 @@ const char *bt_stream_class_get_name(const struct bt_stream_class *stream_class)
        return stream_class->name.value;
 }
 
-int bt_stream_class_set_name(
+enum bt_stream_class_status bt_stream_class_set_name(
                struct bt_stream_class *stream_class,
                const char *name)
 {
@@ -228,7 +227,7 @@ int bt_stream_class_set_name(
        g_string_assign(stream_class->name.str, name);
        stream_class->name.value = stream_class->name.str->str;
        BT_LIB_LOGV("Set stream class's name: %!+S", stream_class);
-       return 0;
+       return BT_STREAM_CLASS_STATUS_OK;
 }
 
 uint64_t bt_stream_class_get_id(const struct bt_stream_class *stream_class)
@@ -298,7 +297,7 @@ bt_stream_class_borrow_packet_context_field_class_const(
        return stream_class->packet_context_fc;
 }
 
-int bt_stream_class_set_packet_context_field_class(
+enum bt_stream_class_status bt_stream_class_set_packet_context_field_class(
                struct bt_stream_class *stream_class,
                struct bt_field_class *field_class)
 {
@@ -323,6 +322,12 @@ int bt_stream_class_set_packet_context_field_class(
                bt_stream_class_borrow_trace_class_inline(stream_class)->packet_header_fc;
        ret = bt_resolve_field_paths(field_class, &resolve_ctx);
        if (ret) {
+               /*
+                * This is the only reason for which
+                * bt_resolve_field_paths() can fail: anything else
+                * would be because a precondition is not satisfied.
+                */
+               ret = BT_STREAM_CLASS_STATUS_NOMEM;
                goto end;
        }
 
@@ -345,7 +350,7 @@ const struct bt_field_class *bt_stream_class_borrow_event_header_field_class_con
        return stream_class->event_header_fc;
 }
 
-int bt_stream_class_set_event_header_field_class(
+enum bt_stream_class_status bt_stream_class_set_event_header_field_class(
                struct bt_stream_class *stream_class,
                struct bt_field_class *field_class)
 {
@@ -371,6 +376,12 @@ int bt_stream_class_set_event_header_field_class(
        resolve_ctx.packet_context = stream_class->packet_context_fc;
        ret = bt_resolve_field_paths(field_class, &resolve_ctx);
        if (ret) {
+               /*
+                * This is the only reason for which
+                * bt_resolve_field_paths() can fail: anything else
+                * would be because a precondition is not satisfied.
+                */
+               ret = BT_STREAM_CLASS_STATUS_NOMEM;
                goto end;
        }
 
@@ -394,7 +405,8 @@ bt_stream_class_borrow_event_common_context_field_class_const(
        return stream_class->event_common_context_fc;
 }
 
-int bt_stream_class_set_event_common_context_field_class(
+enum bt_stream_class_status
+bt_stream_class_set_event_common_context_field_class(
                struct bt_stream_class *stream_class,
                struct bt_field_class *field_class)
 {
@@ -421,6 +433,12 @@ int bt_stream_class_set_event_common_context_field_class(
        resolve_ctx.event_header = stream_class->event_header_fc;
        ret = bt_resolve_field_paths(field_class, &resolve_ctx);
        if (ret) {
+               /*
+                * This is the only reason for which
+                * bt_resolve_field_paths() can fail: anything else
+                * would be because a precondition is not satisfied.
+                */
+               ret = BT_STREAM_CLASS_STATUS_NOMEM;
                goto end;
        }
 
@@ -445,7 +463,7 @@ void _bt_stream_class_freeze(const struct bt_stream_class *stream_class)
        ((struct bt_stream_class *) stream_class)->frozen = true;
 }
 
-int bt_stream_class_set_default_clock_class(
+enum bt_stream_class_status bt_stream_class_set_default_clock_class(
                struct bt_stream_class *stream_class,
                struct bt_clock_class *clock_class)
 {
@@ -458,7 +476,7 @@ int bt_stream_class_set_default_clock_class(
        bt_clock_class_freeze(clock_class);
        BT_LIB_LOGV("Set stream class's default clock class: %!+S",
                stream_class);
-       return 0;
+       return BT_STREAM_CLASS_STATUS_OK;
 }
 
 struct bt_clock_class *bt_stream_class_borrow_default_clock_class(
@@ -551,14 +569,14 @@ void bt_stream_class_set_packets_have_packet_counter_snapshot(
                "%!+S", stream_class);
 }
 
-bt_bool bt_stream_class_packets_have_default_beginning_clock_value(
+bt_bool bt_stream_class_packets_have_default_beginning_clock_snapshot(
                const struct bt_stream_class *stream_class)
 {
        BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
-       return (bt_bool) stream_class->packets_have_default_beginning_cv;
+       return (bt_bool) stream_class->packets_have_default_beginning_cs;
 }
 
-void bt_stream_class_set_packets_have_default_beginning_clock_value(
+void bt_stream_class_set_packets_have_default_beginning_clock_snapshot(
                struct bt_stream_class *stream_class,
                bt_bool value)
 {
@@ -567,20 +585,20 @@ void bt_stream_class_set_packets_have_default_beginning_clock_value(
        BT_ASSERT_PRE(!value || stream_class->default_clock_class,
                "Stream class does not have a default clock class: %!+S",
                stream_class);
-       stream_class->packets_have_default_beginning_cv = (bool) value;
+       stream_class->packets_have_default_beginning_cs = (bool) value;
        BT_LIB_LOGV("Set stream class's "
-               "\"packets have default beginning clock value\" property: "
+               "\"packets have default beginning clock snapshot\" property: "
                "%!+S", stream_class);
 }
 
-bt_bool bt_stream_class_packets_have_default_end_clock_value(
+bt_bool bt_stream_class_packets_have_default_end_clock_snapshot(
                const struct bt_stream_class *stream_class)
 {
        BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
-       return (bt_bool) stream_class->packets_have_default_end_cv;
+       return (bt_bool) stream_class->packets_have_default_end_cs;
 }
 
-void bt_stream_class_set_packets_have_default_end_clock_value(
+void bt_stream_class_set_packets_have_default_end_clock_snapshot(
                struct bt_stream_class *stream_class,
                bt_bool value)
 {
@@ -589,15 +607,25 @@ void bt_stream_class_set_packets_have_default_end_clock_value(
        BT_ASSERT_PRE(!value || stream_class->default_clock_class,
                "Stream class does not have a default clock class: %!+S",
                stream_class);
-       stream_class->packets_have_default_end_cv = (bool) value;
+       stream_class->packets_have_default_end_cs = (bool) value;
        BT_LIB_LOGV("Set stream class's "
-               "\"packets have default end clock value\" property: "
+               "\"packets have default end clock snapshot\" property: "
                "%!+S", stream_class);
 }
 
 bt_bool bt_stream_class_default_clock_is_always_known(
                const struct bt_stream_class *stream_class)
 {
-       /* BT_CLOCK_VALUE_STATUS_UNKNOWN is not supported as of 2.0 */
+       /* BT_CLOCK_SNAPSHOT_STATE_UNKNOWN is not supported as of 2.0 */
        return BT_TRUE;
 }
+
+void bt_stream_class_get_ref(const struct bt_stream_class *stream_class)
+{
+       bt_object_get_ref(stream_class);
+}
+
+void bt_stream_class_put_ref(const struct bt_stream_class *stream_class)
+{
+       bt_object_put_ref(stream_class);
+}
This page took 0.026046 seconds and 4 git commands to generate.