#include <babeltrace/graph/clock-class-priority-map-internal.h>
#include <babeltrace/graph/notification-internal.h>
#include <babeltrace/graph/notification-discarded-elements-internal.h>
+#include <babeltrace/assert-pre-internal.h>
#include <stdint.h>
#include <inttypes.h>
BT_HIDDEN
struct bt_notification *bt_notification_discarded_elements_create(
enum bt_notification_type type,
- struct bt_ctf_stream *stream,
- struct bt_ctf_clock_value *begin_clock_value,
- struct bt_ctf_clock_value *end_clock_value,
+ struct bt_stream *stream,
+ struct bt_clock_value *begin_clock_value,
+ struct bt_clock_value *end_clock_value,
uint64_t count)
{
struct bt_notification_discarded_elements *notification;
struct bt_notification *ret_notif = NULL;
- if (!stream) {
- BT_LOGW_STR("Invalid parameter: stream is NULL.");
- }
-
+ BT_ASSERT_PRE_NON_NULL(stream, "Stream");
BT_LOGD("Creating discarded elements notification object: "
"type=%s, stream-addr=%p, stream-name=\"%s\", "
"begin-clock-value-addr=%p, end-clock-value-addr=%p, "
"count=%" PRIu64,
bt_notification_type_string(type), stream,
- bt_ctf_stream_get_name(stream), begin_clock_value,
+ bt_stream_get_name(stream), begin_clock_value,
end_clock_value, count);
notification = g_new0(struct bt_notification_discarded_elements, 1);
if (!notification) {
"begin-clock-value-addr=%p, end-clock-value-addr=%p, "
"count=%" PRIu64 ", addr=%p",
bt_notification_type_string(type), stream,
- bt_ctf_stream_get_name(stream), begin_clock_value,
+ bt_stream_get_name(stream), begin_clock_value,
end_clock_value, count, ret_notif);
goto end;
}
BT_HIDDEN
-struct bt_ctf_clock_value *
+struct bt_clock_value *
bt_notification_discarded_elements_get_begin_clock_value(
enum bt_notification_type type,
struct bt_notification *notification)
{
- struct bt_ctf_clock_value *clock_value = NULL;
struct bt_notification_discarded_elements *discarded_elems_notif;
- if (!notification) {
- BT_LOGW_STR("Invalid parameter: notification is NULL.");
- goto end;
- }
-
- if (bt_notification_get_type(notification) !=
- BT_NOTIFICATION_TYPE_DISCARDED_EVENTS) {
- BT_LOGW("Invalid parameter: notification has not the expected type: "
- "addr%p, expected-type=%s, notif-type=%s",
- notification, bt_notification_type_string(type),
- bt_notification_type_string(
- bt_notification_get_type(notification)));
- goto end;
- }
-
+ BT_ASSERT_PRE_NON_NULL(notification, "Notification");
+ BT_ASSERT_PRE_NOTIF_IS_TYPE(notification, type);
discarded_elems_notif = container_of(notification,
struct bt_notification_discarded_elements, parent);
- clock_value = bt_get(discarded_elems_notif->begin_clock_value);
-
-end:
- return clock_value;
+ return bt_get(discarded_elems_notif->begin_clock_value);
}
BT_HIDDEN
-struct bt_ctf_clock_value *
+struct bt_clock_value *
bt_notification_discarded_elements_get_end_clock_value(
enum bt_notification_type type,
struct bt_notification *notification)
{
- struct bt_ctf_clock_value *clock_value = NULL;
struct bt_notification_discarded_elements *discarded_elems_notif;
- if (!notification) {
- BT_LOGW_STR("Invalid parameter: notification is NULL.");
- goto end;
- }
-
- if (bt_notification_get_type(notification) !=
- BT_NOTIFICATION_TYPE_DISCARDED_EVENTS) {
- BT_LOGW("Invalid parameter: notification has not the expected type: "
- "addr%p, expected-type=%s, notif-type=%s",
- notification, bt_notification_type_string(type),
- bt_notification_type_string(
- bt_notification_get_type(notification)));
- goto end;
- }
-
+ BT_ASSERT_PRE_NON_NULL(notification, "Notification");
+ BT_ASSERT_PRE_NOTIF_IS_TYPE(notification, type);
discarded_elems_notif = container_of(notification,
struct bt_notification_discarded_elements, parent);
- clock_value = bt_get(discarded_elems_notif->end_clock_value);
-
-end:
- return clock_value;
+ return bt_get(discarded_elems_notif->end_clock_value);
}
BT_HIDDEN
enum bt_notification_type type,
struct bt_notification *notification)
{
- int64_t count = (int64_t) -1;
struct bt_notification_discarded_elements *discarded_elems_notif;
- if (!notification) {
- BT_LOGW_STR("Invalid parameter: notification is NULL.");
- goto end;
- }
-
- if (bt_notification_get_type(notification) !=
- BT_NOTIFICATION_TYPE_DISCARDED_EVENTS) {
- BT_LOGW("Invalid parameter: notification has not the expected type: "
- "addr%p, expected-type=%s, notif-type=%s",
- notification, bt_notification_type_string(type),
- bt_notification_type_string(
- bt_notification_get_type(notification)));
- goto end;
- }
-
+ BT_ASSERT_PRE_NON_NULL(notification, "Notification");
+ BT_ASSERT_PRE_NOTIF_IS_TYPE(notification, type);
discarded_elems_notif = container_of(notification,
struct bt_notification_discarded_elements, parent);
- count = discarded_elems_notif->count;
-
-end:
- return count;
+ return discarded_elems_notif->count;
}
BT_HIDDEN
-struct bt_ctf_stream *bt_notification_discarded_elements_get_stream(
+struct bt_stream *bt_notification_discarded_elements_get_stream(
enum bt_notification_type type,
struct bt_notification *notification)
{
- struct bt_ctf_stream *stream = NULL;
struct bt_notification_discarded_elements *discarded_elems_notif;
- if (!notification) {
- BT_LOGW_STR("Invalid parameter: notification is NULL.");
- goto end;
- }
-
- if (bt_notification_get_type(notification) !=
- BT_NOTIFICATION_TYPE_DISCARDED_EVENTS) {
- BT_LOGW("Invalid parameter: notification has not the expected type: "
- "addr%p, expected-type=%s, notif-type=%s",
- notification, bt_notification_type_string(type),
- bt_notification_type_string(
- bt_notification_get_type(notification)));
- goto end;
- }
-
+ BT_ASSERT_PRE_NON_NULL(notification, "Notification");
+ BT_ASSERT_PRE_NOTIF_IS_TYPE(notification, type);
discarded_elems_notif = container_of(notification,
struct bt_notification_discarded_elements, parent);
- stream = bt_get(discarded_elems_notif->stream);
-
-end:
- return stream;
+ return bt_get(discarded_elems_notif->stream);
}