lib: update copyrights
[babeltrace.git] / lib / graph / notification / event.c
index a6c7b0ae2fa3e2fd8ec5da5a16f5e6ce6d484761..038da740f46a3cc8a1ceaa6764e3123907ec3600 100644 (file)
@@ -1,10 +1,7 @@
 /*
- * Babeltrace Plug-in Event Notification
- *
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
  * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
  *
- * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
  * in the Software without restriction, including without limitation the rights
 
 #include <babeltrace/compiler-internal.h>
 #include <babeltrace/object-internal.h>
-#include <babeltrace/ctf-ir/event.h>
-#include <babeltrace/ctf-ir/event-internal.h>
-#include <babeltrace/ctf-ir/event-class-internal.h>
-#include <babeltrace/ctf-ir/stream-class-internal.h>
-#include <babeltrace/ctf-ir/trace.h>
+#include <babeltrace/trace-ir/event.h>
+#include <babeltrace/trace-ir/event-internal.h>
+#include <babeltrace/trace-ir/event-class-internal.h>
+#include <babeltrace/trace-ir/stream-class-internal.h>
+#include <babeltrace/trace-ir/trace.h>
 #include <babeltrace/graph/graph-internal.h>
+#include <babeltrace/graph/notification-event-const.h>
+#include <babeltrace/graph/notification-event.h>
 #include <babeltrace/graph/notification-event-internal.h>
 #include <babeltrace/types.h>
 #include <babeltrace/assert-internal.h>
 #include <babeltrace/assert-pre-internal.h>
+#include <babeltrace/object.h>
 #include <stdbool.h>
 #include <inttypes.h>
 
@@ -49,11 +49,12 @@ static inline bool event_class_has_trace(struct bt_event_class *event_class)
 
        stream_class = bt_event_class_borrow_stream_class(event_class);
        BT_ASSERT(stream_class);
-       return bt_stream_class_borrow_trace(stream_class) != NULL;
+       return bt_stream_class_borrow_trace_class(stream_class) != NULL;
 }
 
 BT_HIDDEN
-struct bt_notification *bt_notification_event_new(struct bt_graph *graph)
+struct bt_notification *bt_notification_event_new(
+               struct bt_graph *graph)
 {
        struct bt_notification_event *notification = NULL;
 
@@ -68,34 +69,33 @@ struct bt_notification *bt_notification_event_new(struct bt_graph *graph)
        goto end;
 
 error:
-       BT_PUT(notification);
+       BT_OBJECT_PUT_REF_AND_RESET(notification);
 
 end:
        return (void *) notification;
 }
 
 struct bt_notification *bt_notification_event_create(
-               struct bt_graph *graph,
+               struct bt_self_notification_iterator *self_notif_iter,
                struct bt_event_class *event_class,
                struct bt_packet *packet)
 {
+       struct bt_self_component_port_input_notification_iterator *notif_iter =
+               (void *) self_notif_iter;
        struct bt_notification_event *notification = NULL;
        struct bt_event *event;
 
+       BT_ASSERT_PRE_NON_NULL(notif_iter, "Notification iterator");
        BT_ASSERT_PRE_NON_NULL(event_class, "Event class");
        BT_ASSERT_PRE_NON_NULL(packet, "Packet");
-       BT_LOGD("Creating event notification object: "
-               "event-class-addr=%p, "
-               "event-class-name=\"%s\", event-class-id=%" PRId64,
-               event_class,
-               bt_event_class_get_name(event_class),
-               bt_event_class_get_id(event_class));
        BT_ASSERT_PRE(event_class_has_trace(event_class),
                "Event class is not part of a trace: %!+E", event_class);
+       BT_LIB_LOGD("Creating event notification object: %![ec-]+E",
+               event_class);
        event = bt_event_create(event_class, packet);
        if (unlikely(!event)) {
                BT_LIB_LOGE("Cannot create event from event class: "
-                       "%![event-class-]+E", event_class);
+                       "%![ec-]+E", event_class);
                goto error;
        }
 
@@ -115,7 +115,7 @@ struct bt_notification *bt_notification_event_create(
         *   notification from its notification array.
         */
        notification = (void *) bt_notification_create_from_pool(
-               &graph->event_notif_pool, graph);
+               &notif_iter->graph->event_notif_pool, notif_iter->graph);
        if (unlikely(!notification)) {
                /* bt_notification_create_from_pool() logs errors */
                goto error;
@@ -123,14 +123,10 @@ struct bt_notification *bt_notification_event_create(
 
        BT_ASSERT(!notification->event);
        notification->event = event;
-       BT_LOGD("Created event notification object: "
-               "event-addr=%p, event-class-addr=%p, "
-               "event-class-name=\"%s\", event-class-id=%" PRId64 ", "
-               "notif-addr=%p",
-               notification->event, event_class,
-               bt_event_class_get_name(event_class),
-               bt_event_class_get_id(event_class),
-               notification);
+       bt_packet_set_is_frozen(packet, true);
+       bt_event_class_freeze(event_class);
+       BT_LIB_LOGD("Created event notification object: "
+               "%![notif-]+n, %![event-]+e", notification, event);
        goto end;
 
 error:
@@ -146,11 +142,12 @@ void bt_notification_event_destroy(struct bt_notification *notif)
 {
        struct bt_notification_event *event_notif = (void *) notif;
 
-       BT_LOGD("Destroying event notification: addr=%p", notif);
+       BT_LIB_LOGD("Destroying event notification: %!+n", notif);
 
        if (event_notif->event) {
-               BT_LOGD_STR("Recycling event.");
+               BT_LIB_LOGD("Recycling event: %!+e", event_notif->event);
                bt_event_recycle(event_notif->event);
+               event_notif->event = NULL;
        }
 
        g_free(notif);
@@ -169,10 +166,10 @@ void bt_notification_event_recycle(struct bt_notification *notif)
                return;
        }
 
-       BT_LOGD("Recycling event notification: addr=%p", notif);
+       BT_LIB_LOGD("Recycling event notification: %![notif-]+n, %![event-]+e",
+               notif, event_notif->event);
        bt_notification_reset(notif);
        BT_ASSERT(event_notif->event);
-       BT_LOGD_STR("Recycling event.");
        bt_event_recycle(event_notif->event);
        event_notif->event = NULL;
        graph = notif->graph;
@@ -180,8 +177,8 @@ void bt_notification_event_recycle(struct bt_notification *notif)
        bt_object_pool_recycle_object(&graph->event_notif_pool, notif);
 }
 
-struct bt_event *bt_notification_event_borrow_event(
-               struct bt_notification *notification)
+static inline
+struct bt_event *borrow_event(struct bt_notification *notification)
 {
        struct bt_notification_event *event_notification;
 
@@ -191,3 +188,15 @@ struct bt_event *bt_notification_event_borrow_event(
                        struct bt_notification_event, parent);
        return event_notification->event;
 }
+
+struct bt_event *bt_notification_event_borrow_event(
+               struct bt_notification *notification)
+{
+       return borrow_event(notification);
+}
+
+const struct bt_event *bt_notification_event_borrow_event_const(
+               const struct bt_notification *notification)
+{
+       return borrow_event((void *) notification);
+}
This page took 0.02553 seconds and 4 git commands to generate.