lib: remove "unknown clock snapshot" concept
[babeltrace.git] / lib / graph / message / discarded-items.c
index 9393f6caa6523bcc26d9fe0b96e82c38f6334703..82f0039244c2bacb89e0da28b6fc8c9db5ace4a5 100644 (file)
@@ -74,6 +74,15 @@ struct bt_message *create_discarded_items_message(
        BT_ASSERT_PRE_NON_NULL(stream, "Stream");
        stream_class = bt_stream_borrow_class(stream);
        BT_ASSERT(stream_class);
+       BT_ASSERT_PRE((with_cs && stream_class->default_clock_class) ||
+               (!with_cs && !stream_class->default_clock_class),
+               "Creating a message with a default clock snapshot, but without "
+               "a default clock class, or without a default clock snapshot, "
+               "but with a default clock class: ",
+               "type=%s, %![stream-]+s, %![sc-]+S, with-cs=%d, "
+               "cs-begin-val=%" PRIu64 ", cs-end-val=%" PRIu64,
+               bt_message_type_string(type), stream, stream_class,
+               with_cs, beginning_raw_value, end_raw_value);
        BT_LIB_LOGD("Creating discarded items message object: "
                "type=%s, %![stream-]+s, %![sc-]+S, with-cs=%d, "
                "cs-begin-val=%" PRIu64 ", cs-end-val=%" PRIu64,
@@ -91,6 +100,7 @@ struct bt_message *create_discarded_items_message(
        bt_object_get_no_null_check(message->stream);
 
        if (with_cs) {
+               BT_ASSERT(stream_class->default_clock_class);
                message->default_begin_cs = bt_clock_snapshot_create(
                        stream_class->default_clock_class);
                if (!message->default_begin_cs) {
@@ -156,10 +166,9 @@ enum bt_property_availability get_discarded_items_message_count(
 }
 
 static inline
-enum bt_clock_snapshot_state
+const struct bt_clock_snapshot *
 borrow_discarded_items_message_default_beginning_clock_snapshot_const(
-               const struct bt_message *message,
-               const struct bt_clock_snapshot **snapshot)
+               const struct bt_message *message)
 {
        struct bt_message_discarded_items *disc_items_msg = (void *) message;
 
@@ -168,16 +177,13 @@ borrow_discarded_items_message_default_beginning_clock_snapshot_const(
                "Message's stream's class has no default clock class: "
                "%![msg-]+n, %![sc-]+S",
                message, disc_items_msg->stream->class);
-       BT_ASSERT_PRE_NON_NULL(snapshot, "Clock snapshot (output)");
-       *snapshot = disc_items_msg->default_begin_cs;
-       return BT_CLOCK_SNAPSHOT_STATE_KNOWN;
+       return disc_items_msg->default_begin_cs;
 }
 
 static inline
-enum bt_clock_snapshot_state
+const struct bt_clock_snapshot *
 borrow_discarded_items_message_default_end_clock_snapshot_const(
-               const struct bt_message *message,
-               const struct bt_clock_snapshot **snapshot)
+               const struct bt_message *message)
 {
        struct bt_message_discarded_items *disc_items_msg = (void *) message;
 
@@ -186,27 +192,25 @@ borrow_discarded_items_message_default_end_clock_snapshot_const(
                "Message's stream's class has no default clock class: "
                "%![msg-]+n, %![sc-]+S",
                message, disc_items_msg->stream->class);
-       BT_ASSERT_PRE_NON_NULL(snapshot, "Clock snapshot (output)");
-       *snapshot = disc_items_msg->default_end_cs;
-       return BT_CLOCK_SNAPSHOT_STATE_KNOWN;
+       return disc_items_msg->default_end_cs;
 }
 
 struct bt_message *bt_message_discarded_events_create(
                struct bt_self_message_iterator *message_iterator,
-               struct bt_stream *stream)
+               const struct bt_stream *stream)
 {
        return create_discarded_items_message(message_iterator,
-               BT_MESSAGE_TYPE_DISCARDED_EVENTS, stream,
+               BT_MESSAGE_TYPE_DISCARDED_EVENTS, (void *) stream,
                false, 0, 0);
 }
 
 struct bt_message *bt_message_discarded_events_create_with_default_clock_snapshots(
                struct bt_self_message_iterator *message_iterator,
-               struct bt_stream *stream, uint64_t beginning_raw_value,
+               const struct bt_stream *stream, uint64_t beginning_raw_value,
                uint64_t end_raw_value)
 {
        return create_discarded_items_message(message_iterator,
-               BT_MESSAGE_TYPE_DISCARDED_EVENTS, stream,
+               BT_MESSAGE_TYPE_DISCARDED_EVENTS, (void *) stream,
                true, beginning_raw_value, end_raw_value);
 }
 
@@ -226,26 +230,24 @@ void bt_message_discarded_events_set_count(struct bt_message *message,
        set_discarded_items_message_count(message, count);
 }
 
-enum bt_clock_snapshot_state
+const struct bt_clock_snapshot *
 bt_message_discarded_events_borrow_default_beginning_clock_snapshot_const(
-               const struct bt_message *msg,
-               const struct bt_clock_snapshot **snapshot)
+               const struct bt_message *msg)
 {
        BT_ASSERT_PRE_NON_NULL(msg, "Message");
        BT_ASSERT_PRE_MSG_IS_TYPE(msg, BT_MESSAGE_TYPE_DISCARDED_EVENTS);
        return borrow_discarded_items_message_default_beginning_clock_snapshot_const(
-               msg, snapshot);
+               msg);
 }
 
-enum bt_clock_snapshot_state
+const struct bt_clock_snapshot *
 bt_message_discarded_events_borrow_default_end_clock_snapshot_const(
-               const struct bt_message *msg,
-               const struct bt_clock_snapshot **snapshot)
+               const struct bt_message *msg)
 {
        BT_ASSERT_PRE_NON_NULL(msg, "Message");
        BT_ASSERT_PRE_MSG_IS_TYPE(msg, BT_MESSAGE_TYPE_DISCARDED_EVENTS);
        return borrow_discarded_items_message_default_end_clock_snapshot_const(
-               msg, snapshot);
+               msg);
 }
 
 const struct bt_stream *
@@ -265,20 +267,20 @@ enum bt_property_availability bt_message_discarded_events_get_count(
 
 struct bt_message *bt_message_discarded_packets_create(
                struct bt_self_message_iterator *message_iterator,
-               struct bt_stream *stream)
+               const struct bt_stream *stream)
 {
        return create_discarded_items_message(message_iterator,
-               BT_MESSAGE_TYPE_DISCARDED_PACKETS, stream,
+               BT_MESSAGE_TYPE_DISCARDED_PACKETS, (void *) stream,
                false, 0, 0);
 }
 
 struct bt_message *bt_message_discarded_packets_create_with_default_clock_snapshots(
                struct bt_self_message_iterator *message_iterator,
-               struct bt_stream *stream, uint64_t beginning_raw_value,
+               const struct bt_stream *stream, uint64_t beginning_raw_value,
                uint64_t end_raw_value)
 {
        return create_discarded_items_message(message_iterator,
-               BT_MESSAGE_TYPE_DISCARDED_PACKETS, stream,
+               BT_MESSAGE_TYPE_DISCARDED_PACKETS, (void *) stream,
                true, beginning_raw_value, end_raw_value);
 }
 
@@ -298,26 +300,24 @@ void bt_message_discarded_packets_set_count(struct bt_message *message,
        set_discarded_items_message_count(message, count);
 }
 
-enum bt_clock_snapshot_state
+const struct bt_clock_snapshot *
 bt_message_discarded_packets_borrow_default_beginning_clock_snapshot_const(
-               const struct bt_message *msg,
-               const struct bt_clock_snapshot **snapshot)
+               const struct bt_message *msg)
 {
        BT_ASSERT_PRE_NON_NULL(msg, "Message");
        BT_ASSERT_PRE_MSG_IS_TYPE(msg, BT_MESSAGE_TYPE_DISCARDED_PACKETS);
        return borrow_discarded_items_message_default_beginning_clock_snapshot_const(
-               msg, snapshot);
+               msg);
 }
 
-enum bt_clock_snapshot_state
+const struct bt_clock_snapshot *
 bt_message_discarded_packets_borrow_default_end_clock_snapshot_const(
-               const struct bt_message *msg,
-               const struct bt_clock_snapshot **snapshot)
+               const struct bt_message *msg)
 {
        BT_ASSERT_PRE_NON_NULL(msg, "Message");
        BT_ASSERT_PRE_MSG_IS_TYPE(msg, BT_MESSAGE_TYPE_DISCARDED_PACKETS);
        return borrow_discarded_items_message_default_end_clock_snapshot_const(
-               msg, snapshot);
+               msg);
 }
 
 const struct bt_stream *
@@ -334,3 +334,34 @@ enum bt_property_availability bt_message_discarded_packets_get_count(
        BT_ASSERT_PRE_MSG_IS_TYPE(message, BT_MESSAGE_TYPE_DISCARDED_PACKETS);
        return get_discarded_items_message_count(message, count);
 }
+
+static inline
+const struct bt_clock_class *
+borrow_discarded_items_message_stream_class_default_clock_class(
+               const struct bt_message *msg)
+{
+       struct bt_message_discarded_items *disc_items_msg = (void *) msg;
+
+       BT_ASSERT(msg);
+       return disc_items_msg->stream->class->default_clock_class;
+}
+
+const struct bt_clock_class *
+bt_message_discarded_events_borrow_stream_class_default_clock_class_const(
+               const struct bt_message *msg)
+{
+       BT_ASSERT_PRE_NON_NULL(msg, "Message");
+       BT_ASSERT_PRE_MSG_IS_TYPE(msg, BT_MESSAGE_TYPE_DISCARDED_EVENTS);
+       return borrow_discarded_items_message_stream_class_default_clock_class(
+               msg);
+}
+
+const struct bt_clock_class *
+bt_message_discarded_packets_borrow_stream_class_default_clock_class_const(
+               const struct bt_message *msg)
+{
+       BT_ASSERT_PRE_NON_NULL(msg, "Message");
+       BT_ASSERT_PRE_MSG_IS_TYPE(msg, BT_MESSAGE_TYPE_DISCARDED_PACKETS);
+       return borrow_discarded_items_message_stream_class_default_clock_class(
+               msg);
+}
This page took 0.026123 seconds and 4 git commands to generate.