lib: update copyrights
[babeltrace.git] / include / babeltrace / graph / notification-iterator-internal.h
index ebbd01fcbceb74c442a27cc54cb7eaacf09795c7..28a322f1162f35c172d4b56dffe233ffe29f1119 100644 (file)
@@ -1,11 +1,9 @@
-#ifndef BABELTRACE_COMPONENT_NOTIFICATION_ITERATOR_INTERNAL_H
-#define BABELTRACE_COMPONENT_NOTIFICATION_ITERATOR_INTERNAL_H
+#ifndef BABELTRACE_GRAPH_NOTIFICATION_ITERATOR_INTERNAL_H
+#define BABELTRACE_GRAPH_NOTIFICATION_ITERATOR_INTERNAL_H
 
 /*
- * BabelTrace - Notification Iterator Internal
- *
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
  * Copyright 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- * Copyright 2017 Philippe Proulx <pproulx@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
 
 #include <babeltrace/babeltrace-internal.h>
 #include <babeltrace/object-internal.h>
-#include <babeltrace/ref-internal.h>
-#include <babeltrace/graph/connection.h>
-#include <babeltrace/graph/notification.h>
+#include <babeltrace/graph/connection-const.h>
+#include <babeltrace/graph/notification-const.h>
 #include <babeltrace/graph/notification-iterator.h>
-#include <babeltrace/graph/private-notification-iterator.h>
 #include <babeltrace/types.h>
+#include <babeltrace/assert-internal.h>
+#include <stdbool.h>
 
 struct bt_port;
+struct bt_graph;
 
-enum bt_notification_iterator_notif_type {
-       BT_NOTIFICATION_ITERATOR_NOTIF_TYPE_EVENT =             (1U << 0),
-       BT_NOTIFICATION_ITERATOR_NOTIF_TYPE_INACTIVITY =        (1U << 1),
-       BT_NOTIFICATION_ITERATOR_NOTIF_TYPE_STREAM_BEGIN =      (1U << 2),
-       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),
+enum bt_notification_iterator_type {
+       BT_NOTIFICATION_ITERATOR_TYPE_SELF_COMPONENT_PORT_INPUT,
+       BT_NOTIFICATION_ITERATOR_TYPE_PORT_OUTPUT,
 };
 
-enum bt_notification_iterator_state {
+enum bt_self_component_port_input_notification_iterator_state {
+       /* Iterator is not initialized. */
+       BT_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_STATE_NON_INITIALIZED,
+
        /* Iterator is active, not at the end yet, and not finalized. */
-       BT_NOTIFICATION_ITERATOR_STATE_ACTIVE,
+       BT_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_STATE_ACTIVE,
 
        /*
         * Iterator is ended, not finalized yet: the "next" method
         * returns BT_NOTIFICATION_ITERATOR_STATUS_END.
         */
-       BT_NOTIFICATION_ITERATOR_STATE_ENDED,
+       BT_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_STATE_ENDED,
 
        /*
         * Iterator is finalized, but not at the end yet. This means
@@ -62,106 +60,71 @@ enum bt_notification_iterator_state {
         * before returning the BT_NOTIFICATION_ITERATOR_STATUS_CANCELED
         * status.
         */
-       BT_NOTIFICATION_ITERATOR_STATE_FINALIZED,
+       BT_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_STATE_FINALIZED,
 
        /*
         * Iterator is finalized and ended: the "next" method always
         * returns BT_NOTIFICATION_ITERATOR_STATUS_CANCELED.
         */
-       BT_NOTIFICATION_ITERATOR_STATE_FINALIZED_AND_ENDED,
+       BT_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_STATE_FINALIZED_AND_ENDED,
 };
 
 struct bt_notification_iterator {
        struct bt_object base;
+       enum bt_notification_iterator_type type;
+       GPtrArray *notifs;
+};
+
+struct bt_self_component_port_input_notification_iterator {
+       struct bt_notification_iterator base;
        struct bt_component *upstream_component; /* Weak */
        struct bt_port *upstream_port; /* Weak */
        struct bt_connection *connection; /* Weak */
-       struct bt_notification *current_notification; /* owned by this */
-       GQueue *queue; /* struct bt_notification * (owned by this) */
+       struct bt_graph *graph; /* Weak */
 
        /*
         * This hash table keeps the state of a stream as viewed by
-        * this notification iterator. This is used to:
+        * this notification iterator. This is used to, in developer
+        * mode:
         *
         * * Automatically enqueue "stream begin", "packet begin",
         *   "packet end", and "stream end" notifications depending
         *   on the stream's state and on the next notification returned
         *   by the upstream component.
         *
-        * * Make sure that, once the notification iterator has seen
-        *   a "stream end" notification for a given stream, that no
-        *   other notifications which refer to this stream can be
-        *   delivered by this iterator.
+        * * Make sure that, once the notification iterator has seen a
+        *   "stream end" notification for a given stream, no other
+        *   notifications which refer to this stream can be delivered
+        *   by this iterator.
         *
-        * The key (struct bt_ctf_stream *) is not owned by this. The
+        * The key (struct bt_stream *) is not owned by this. The
         * value is an allocated state structure.
         */
        GHashTable *stream_states;
 
-       /*
-        * This is an array of actions which can be rolled back. It's
-        * similar to the memento pattern, but it's not exactly that. It
-        * is allocated once and reset for each notification to process.
-        * More details near the implementation.
-        */
-       GArray *actions;
-
-       /*
-        * This is a mask of notifications to which the user of this
-        * iterator is subscribed
-        * (see enum bt_notification_iterator_notif_type above).
-        */
-       uint32_t subscription_mask;
-
-       enum bt_notification_iterator_state state;
+       enum bt_self_component_port_input_notification_iterator_state state;
        void *user_data;
 };
 
-static inline
-struct bt_notification_iterator *bt_notification_iterator_from_private(
-               struct bt_private_notification_iterator *private_notification_iterator)
-{
-       return (void *) private_notification_iterator;
-}
-
-static inline
-struct bt_private_notification_iterator *
-bt_private_notification_iterator_from_notification_iterator(
-               struct bt_notification_iterator *notification_iterator)
-{
-       return (void *) notification_iterator;
-}
+struct bt_port_output_notification_iterator {
+       struct bt_notification_iterator base;
+       struct bt_graph *graph; /* Owned by this */
+       struct bt_component_sink *colander; /* Owned by this */
 
-/**
- * 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,
-               struct bt_port *upstream_port,
-               const enum bt_notification_type *notification_types,
-               struct bt_connection *connection);
-
-/**
- * Validate a notification iterator.
- *
- * @param iterator             Notification iterator instance
- * @returns                    One of #bt_component_status values
- */
-BT_HIDDEN
-enum bt_notification_iterator_status bt_notification_iterator_validate(
-               struct bt_notification_iterator *iterator);
+       /*
+        * Only used temporarily as a bridge between a colander sink and
+        * the user.
+        */
+       uint64_t count;
+};
 
 BT_HIDDEN
-void bt_notification_iterator_finalize(
-               struct bt_notification_iterator *iterator);
+void bt_self_component_port_input_notification_iterator_finalize(
+               struct bt_self_component_port_input_notification_iterator *iterator);
 
 BT_HIDDEN
-void bt_notification_iterator_set_connection(
-               struct bt_notification_iterator *iterator,
+void bt_self_component_port_input_notification_iterator_set_connection(
+               struct bt_self_component_port_input_notification_iterator *iterator,
                struct bt_connection *connection);
 
 static inline
@@ -177,17 +140,31 @@ const char *bt_notification_iterator_status_string(
                return "BT_NOTIFICATION_ITERATOR_STATUS_END";
        case BT_NOTIFICATION_ITERATOR_STATUS_OK:
                return "BT_NOTIFICATION_ITERATOR_STATUS_OK";
-       case BT_NOTIFICATION_ITERATOR_STATUS_INVALID:
-               return "BT_NOTIFICATION_ITERATOR_STATUS_INVALID";
        case BT_NOTIFICATION_ITERATOR_STATUS_ERROR:
                return "BT_NOTIFICATION_ITERATOR_STATUS_ERROR";
        case BT_NOTIFICATION_ITERATOR_STATUS_NOMEM:
                return "BT_NOTIFICATION_ITERATOR_STATUS_NOMEM";
-       case BT_NOTIFICATION_ITERATOR_STATUS_UNSUPPORTED:
-               return "BT_NOTIFICATION_ITERATOR_STATUS_UNSUPPORTED";
        default:
                return "(unknown)";
        }
 };
 
-#endif /* BABELTRACE_COMPONENT_NOTIFICATION_ITERATOR_INTERNAL_H */
+static inline
+const char *bt_self_component_port_input_notification_iterator_state_string(
+               enum bt_self_component_port_input_notification_iterator_state state)
+{
+       switch (state) {
+       case BT_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_STATE_ACTIVE:
+               return "BT_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_STATE_ACTIVE";
+       case BT_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_STATE_ENDED:
+               return "BT_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_STATE_ENDED";
+       case BT_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_STATE_FINALIZED:
+               return "BT_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_STATE_FINALIZED";
+       case BT_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_STATE_FINALIZED_AND_ENDED:
+               return "BT_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_STATE_FINALIZED_AND_ENDED";
+       default:
+               return "(unknown)";
+       }
+};
+
+#endif /* BABELTRACE_GRAPH_NOTIFICATION_ITERATOR_INTERNAL_H */
This page took 0.025802 seconds and 4 git commands to generate.