lib: do not finalize a non-initialized notification iterator
[babeltrace.git] / include / babeltrace / graph / notification-iterator-internal.h
index 7b748e7bff10fd4c78b4181b2a5b5325eb489203..567c47387f8136075b5bf50530e7d649cb83551d 100644 (file)
@@ -34,6 +34,7 @@
 #include <babeltrace/graph/notification-iterator.h>
 #include <babeltrace/graph/private-notification-iterator.h>
 #include <babeltrace/types.h>
+#include <stdbool.h>
 
 struct bt_port;
 
@@ -44,9 +45,14 @@ enum bt_notification_iterator_notif_type {
        BT_NOTIFICATION_ITERATOR_NOTIF_TYPE_STREAM_END =        (1U << 3),
        BT_NOTIFICATION_ITERATOR_NOTIF_TYPE_PACKET_BEGIN =      (1U << 4),
        BT_NOTIFICATION_ITERATOR_NOTIF_TYPE_PACKET_END =        (1U << 5),
+       BT_NOTIFICATION_ITERATOR_NOTIF_TYPE_DISCARDED_EVENTS =  (1U << 6),
+       BT_NOTIFICATION_ITERATOR_NOTIF_TYPE_DISCARDED_PACKETS = (1U << 7),
 };
 
 enum bt_notification_iterator_state {
+       /* Iterator is not initialized. */
+       BT_NOTIFICATION_ITERATOR_STATE_NON_INITIALIZED,
+
        /* Iterator is active, not at the end yet, and not finalized. */
        BT_NOTIFICATION_ITERATOR_STATE_ACTIVE,
 
@@ -132,18 +138,13 @@ bt_private_notification_iterator_from_notification_iterator(
        return (void *) notification_iterator;
 }
 
-/**
- * Allocate a notification iterator.
- *
- * @param component            Component instance
- * @returns                    A notification iterator instance
- */
 BT_HIDDEN
-struct bt_notification_iterator *bt_notification_iterator_create(
-               struct bt_component *upstream_component,
+enum bt_connection_status bt_notification_iterator_create(
+               struct bt_component *upstream_comp,
                struct bt_port *upstream_port,
                const enum bt_notification_type *notification_types,
-               struct bt_connection *connection);
+               struct bt_connection *connection,
+               struct bt_notification_iterator **iterator);
 
 BT_HIDDEN
 void bt_notification_iterator_finalize(
@@ -180,4 +181,22 @@ const char *bt_notification_iterator_status_string(
        }
 };
 
+static inline
+const char *bt_notification_iterator_state_string(
+               enum bt_notification_iterator_state state)
+{
+       switch (state) {
+       case BT_NOTIFICATION_ITERATOR_STATE_ACTIVE:
+               return "BT_NOTIFICATION_ITERATOR_STATE_ACTIVE";
+       case BT_NOTIFICATION_ITERATOR_STATE_ENDED:
+               return "BT_NOTIFICATION_ITERATOR_STATE_ENDED";
+       case BT_NOTIFICATION_ITERATOR_STATE_FINALIZED:
+               return "BT_NOTIFICATION_ITERATOR_STATE_FINALIZED";
+       case BT_NOTIFICATION_ITERATOR_STATE_FINALIZED_AND_ENDED:
+               return "BT_NOTIFICATION_ITERATOR_STATE_FINALIZED_AND_ENDED";
+       default:
+               return "(unknown)";
+       }
+};
+
 #endif /* BABELTRACE_COMPONENT_NOTIFICATION_ITERATOR_INTERNAL_H */
This page took 0.023941 seconds and 4 git commands to generate.