lib: move graph/message/iterator.h -> graph/iterator.h
authorSimon Marchi <simon.marchi@efficios.com>
Tue, 6 Feb 2024 17:35:10 +0000 (17:35 +0000)
committerSimon Marchi <simon.marchi@efficios.com>
Tue, 6 Feb 2024 18:10:19 +0000 (13:10 -0500)
This file doesn't belong in the `message` directory, move it up one
level, next to `iterator.c`.

Change-Id: I096d91d5afa32ebb304b5132cad067e820f2bb30
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11749
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
src/Makefile.am
src/lib/error.c
src/lib/graph/component-source.c
src/lib/graph/component.c
src/lib/graph/connection.c
src/lib/graph/connection.h
src/lib/graph/iterator.c
src/lib/graph/iterator.h [new file with mode: 0644]
src/lib/graph/message/iterator.h [deleted file]
src/lib/lib-logging.c

index 3427a88d7beae9dcb52a72dc21dc354bd36c97cf..e01f8734eb1710f480fec5ea2aa16507795b3cf3 100644 (file)
@@ -378,7 +378,6 @@ lib_libbabeltrace2_la_SOURCES = \
        lib/graph/message/event.h \
        lib/graph/message-iterator-class.c \
        lib/graph/message-iterator-class.h \
-       lib/graph/message/iterator.h \
        lib/graph/message/message.c \
        lib/graph/message/message.h \
        lib/graph/message/message-iterator-inactivity.c \
@@ -408,6 +407,7 @@ lib_libbabeltrace2_la_SOURCES = \
        lib/graph/interrupter.c \
        lib/graph/interrupter.h \
        lib/graph/iterator.c \
+       lib/graph/iterator.h \
        lib/graph/mip.c \
        lib/graph/port.c \
        lib/graph/port.h \
index ab794673a9fc47a1236b95a69dac1f24eacf250e..837bd41699738a2da649a42b0a8f4afcfb417344 100644 (file)
@@ -12,9 +12,9 @@
 #include <babeltrace2/babeltrace.h>
 
 #include "error.h"
-#include "graph/message/iterator.h"
 #include "graph/component.h"
 #include "graph/component-class.h"
+#include "graph/iterator.h"
 #include "common/assert.h"
 #include "lib/assert-cond.h"
 #include "lib/func-status.h"
index 096d24250a0c6d880d36a522d218eb38748f1dff..d7315dde2c608d438e41e3069472dfd67170f8d1 100644 (file)
@@ -18,7 +18,7 @@
 #include "component-source.h"
 #include "component.h"
 #include "port.h"
-#include "message/iterator.h"
+#include "iterator.h"
 #include "lib/func-status.h"
 
 struct bt_component *bt_component_source_create(void)
index 97fff9b68566c8636d1adb88c19fe8246ae70ecd..dcda049015af3052f27d30b736e76f6fe175b9fd 100644 (file)
@@ -27,7 +27,7 @@
 #include "component-sink.h"
 #include "connection.h"
 #include "graph.h"
-#include "message/iterator.h"
+#include "iterator.h"
 #include "port.h"
 #include "lib/func-status.h"
 
index da4429d038f639d3e74894c7f24d64ac42ea2da8..42accaa45efc1ea8a6b4d105120de34e2968ec97 100644 (file)
@@ -19,7 +19,7 @@
 #include "component.h"
 #include "connection.h"
 #include "graph.h"
-#include "message/iterator.h"
+#include "iterator.h"
 #include "port.h"
 
 static
index bc2513d5fb0689ecb6acefb9139fd436ff10be5c..dbc888e1a646c161f7ba9278415847ed2aab68ed 100644 (file)
@@ -14,7 +14,7 @@
 #include "common/macros.h"
 #include <stdbool.h>
 
-#include "message/iterator.h"
+#include "iterator.h"
 
 struct bt_graph;
 
index 73893ddb36e6d713fd0fb38e1df7aae89483f9a5..8da132829912f6c9f4501d1ae8276bf0d30ed875 100644 (file)
 #include "component.h"
 #include "connection.h"
 #include "graph.h"
+#include "iterator.h"
 #include "message-iterator-class.h"
 #include "message/discarded-items.h"
 #include "message/event.h"
-#include "message/iterator.h"
 #include "message/message.h"
 #include "message/message-iterator-inactivity.h"
 #include "message/stream.h"
diff --git a/src/lib/graph/iterator.h b/src/lib/graph/iterator.h
new file mode 100644 (file)
index 0000000..ed09363
--- /dev/null
@@ -0,0 +1,219 @@
+/*
+ * SPDX-License-Identifier: MIT
+ *
+ * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
+ * Copyright 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ */
+
+#ifndef BABELTRACE_GRAPH_MESSAGE_ITERATOR_INTERNAL_H
+#define BABELTRACE_GRAPH_MESSAGE_ITERATOR_INTERNAL_H
+
+#include "common/macros.h"
+#include "lib/object.h"
+#include <babeltrace2/graph/connection.h>
+#include <babeltrace2/graph/message.h>
+#include <babeltrace2/types.h>
+#include "common/assert.h"
+#include <stdbool.h>
+#include "common/uuid.h"
+
+struct bt_port;
+struct bt_graph;
+
+enum bt_message_iterator_state {
+       /* Iterator is not initialized */
+       BT_MESSAGE_ITERATOR_STATE_NON_INITIALIZED,
+
+       /* Iterator is active, not at the end yet, and not finalized */
+       BT_MESSAGE_ITERATOR_STATE_ACTIVE,
+
+       /*
+        * Iterator is ended, not finalized yet: the "next" method
+        * returns BT_MESSAGE_ITERATOR_STATUS_END.
+        */
+       BT_MESSAGE_ITERATOR_STATE_ENDED,
+
+       /* Iterator is currently being finalized */
+       BT_MESSAGE_ITERATOR_STATE_FINALIZING,
+
+       /* Iterator is finalized */
+       BT_MESSAGE_ITERATOR_STATE_FINALIZED,
+
+       /* Iterator is seeking */
+       BT_MESSAGE_ITERATOR_STATE_SEEKING,
+
+       /* Iterator did seek, but returned `BT_MESSAGE_ITERATOR_STATUS_AGAIN` */
+       BT_MESSAGE_ITERATOR_STATE_LAST_SEEKING_RETURNED_AGAIN,
+
+       /* Iterator did seek, but returned error status */
+       BT_MESSAGE_ITERATOR_STATE_LAST_SEEKING_RETURNED_ERROR,
+};
+
+typedef enum bt_message_iterator_class_next_method_status
+(*bt_message_iterator_next_method)(
+               void *, bt_message_array_const, uint64_t, uint64_t *);
+
+typedef enum bt_message_iterator_class_seek_ns_from_origin_method_status
+(*bt_message_iterator_seek_ns_from_origin_method)(
+               void *, int64_t);
+
+typedef enum bt_message_iterator_class_seek_beginning_method_status
+(*bt_message_iterator_seek_beginning_method)(
+               void *);
+
+typedef enum bt_message_iterator_class_can_seek_ns_from_origin_method_status
+(*bt_message_iterator_can_seek_ns_from_origin_method)(
+               void *, int64_t, bt_bool *);
+
+typedef enum bt_message_iterator_class_can_seek_beginning_method_status
+(*bt_message_iterator_can_seek_beginning_method)(
+               void *, bt_bool *);
+
+struct bt_self_message_iterator_configuration {
+       bool frozen;
+       bool can_seek_forward;
+};
+
+struct bt_message_iterator {
+       struct bt_object base;
+       GPtrArray *msgs;
+       struct bt_component *upstream_component; /* Weak */
+       struct bt_port *upstream_port; /* Weak */
+       struct bt_connection *connection; /* Weak */
+       struct bt_graph *graph; /* Weak */
+       struct bt_self_message_iterator_configuration config;
+
+       /*
+        * Array of
+        * `struct bt_message_iterator *`
+        * (weak).
+        *
+        * This is an array of upstream message iterators on which this
+        * iterator depends. The references are weak: an upstream
+        * message iterator is responsible for removing its entry within
+        * this array on finalization/destruction.
+        */
+       GPtrArray *upstream_msg_iters;
+
+       /*
+        * Downstream message iterator which depends on this message
+        * iterator (weak).
+        *
+        * This can be `NULL` if this message iterator's owner is a sink
+        * component.
+        */
+       struct bt_message_iterator *downstream_msg_iter;
+
+       struct {
+               bt_message_iterator_next_method next;
+
+               /* These two are always both set or both unset. */
+               bt_message_iterator_seek_ns_from_origin_method seek_ns_from_origin;
+               bt_message_iterator_can_seek_ns_from_origin_method can_seek_ns_from_origin;
+
+               /* These two are always both set or both unset. */
+               bt_message_iterator_seek_beginning_method seek_beginning;
+               bt_message_iterator_can_seek_beginning_method can_seek_beginning;
+       } methods;
+
+       enum bt_message_iterator_state state;
+
+       /*
+        * Timestamp of the last received message (or INT64_MIN in the
+        * beginning, or after a seek to beginning).
+        */
+       int64_t last_ns_from_origin;
+
+       struct {
+               enum {
+                       /* We haven't recorded clock properties yet. */
+                       CLOCK_EXPECTATION_UNSET,
+
+                       /* Expect to have no clock. */
+                       CLOCK_EXPECTATION_NONE,
+
+                       /* Clock with origin_is_unix_epoch true.*/
+                       CLOCK_EXPECTATION_ORIGIN_UNIX,
+
+                       /* Clock with origin_is_unix_epoch false, with a UUID.*/
+                       CLOCK_EXPECTATION_ORIGIN_OTHER_UUID,
+
+                       /* Clock with origin_is_unix_epoch false, without a UUID.*/
+                       CLOCK_EXPECTATION_ORIGIN_OTHER_NO_UUID,
+               } type;
+
+               /*
+                * Expected UUID of the clock, if `type`is CLOCK_EXPECTATION_ORIGIN_OTHER_UUID.
+                *
+                * If the clock's origin is the unix epoch, the UUID is
+                * irrelevant (as the clock will be correlatable with other
+                * clocks having the same origin).
+                */
+               bt_uuid_t uuid;
+       } clock_expectation;
+
+       BT_IF_DEV_MODE(GHashTable *per_stream_state);
+
+       /*
+        * Data necessary for auto seek (the seek-to-beginning then fast-forward
+        * seek strategy).
+        */
+       struct {
+               /*
+                * Queue of `const bt_message *` (owned by this queue).
+                *
+                * When fast-forwarding, we get the messages from upstream in
+                * batches. Once we have found the first message with timestamp
+                * greater or equal to the seek time, we put it and all of the
+                * following message of the batch in this queue.  They will be
+                * sent on the next "next" call on this iterator.
+                *
+                * The messages are in chronological order (i.e. the first to
+                * send is the first of the queue).
+                */
+               GQueue *msgs;
+
+               /*
+                * After auto-seeking, we replace the iterator's `next` callback
+                * with our own, which returns the contents of the `msgs` queue.
+                * This field is where we save the original callback, so we can
+                * restore it.
+                */
+               void *original_next_callback;
+       } auto_seek;
+
+       void *user_data;
+};
+
+void bt_message_iterator_try_finalize(
+               struct bt_message_iterator *iterator);
+
+void bt_message_iterator_set_connection(
+               struct bt_message_iterator *iterator,
+               struct bt_connection *connection);
+
+static inline
+const char *bt_message_iterator_state_string(
+               enum bt_message_iterator_state state)
+{
+       switch (state) {
+       case BT_MESSAGE_ITERATOR_STATE_ACTIVE:
+               return "ACTIVE";
+       case BT_MESSAGE_ITERATOR_STATE_ENDED:
+               return "ENDED";
+       case BT_MESSAGE_ITERATOR_STATE_FINALIZING:
+               return "FINALIZING";
+       case BT_MESSAGE_ITERATOR_STATE_FINALIZED:
+               return "FINALIZED";
+       case BT_MESSAGE_ITERATOR_STATE_SEEKING:
+               return "SEEKING";
+       case BT_MESSAGE_ITERATOR_STATE_LAST_SEEKING_RETURNED_AGAIN:
+               return "LAST_SEEKING_RETURNED_AGAIN";
+       case BT_MESSAGE_ITERATOR_STATE_LAST_SEEKING_RETURNED_ERROR:
+               return "LAST_SEEKING_RETURNED_ERROR";
+       default:
+               return "(unknown)";
+       }
+};
+
+#endif /* BABELTRACE_GRAPH_MESSAGE_ITERATOR_INTERNAL_H */
diff --git a/src/lib/graph/message/iterator.h b/src/lib/graph/message/iterator.h
deleted file mode 100644 (file)
index ed09363..0000000
+++ /dev/null
@@ -1,219 +0,0 @@
-/*
- * SPDX-License-Identifier: MIT
- *
- * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
- * Copyright 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- */
-
-#ifndef BABELTRACE_GRAPH_MESSAGE_ITERATOR_INTERNAL_H
-#define BABELTRACE_GRAPH_MESSAGE_ITERATOR_INTERNAL_H
-
-#include "common/macros.h"
-#include "lib/object.h"
-#include <babeltrace2/graph/connection.h>
-#include <babeltrace2/graph/message.h>
-#include <babeltrace2/types.h>
-#include "common/assert.h"
-#include <stdbool.h>
-#include "common/uuid.h"
-
-struct bt_port;
-struct bt_graph;
-
-enum bt_message_iterator_state {
-       /* Iterator is not initialized */
-       BT_MESSAGE_ITERATOR_STATE_NON_INITIALIZED,
-
-       /* Iterator is active, not at the end yet, and not finalized */
-       BT_MESSAGE_ITERATOR_STATE_ACTIVE,
-
-       /*
-        * Iterator is ended, not finalized yet: the "next" method
-        * returns BT_MESSAGE_ITERATOR_STATUS_END.
-        */
-       BT_MESSAGE_ITERATOR_STATE_ENDED,
-
-       /* Iterator is currently being finalized */
-       BT_MESSAGE_ITERATOR_STATE_FINALIZING,
-
-       /* Iterator is finalized */
-       BT_MESSAGE_ITERATOR_STATE_FINALIZED,
-
-       /* Iterator is seeking */
-       BT_MESSAGE_ITERATOR_STATE_SEEKING,
-
-       /* Iterator did seek, but returned `BT_MESSAGE_ITERATOR_STATUS_AGAIN` */
-       BT_MESSAGE_ITERATOR_STATE_LAST_SEEKING_RETURNED_AGAIN,
-
-       /* Iterator did seek, but returned error status */
-       BT_MESSAGE_ITERATOR_STATE_LAST_SEEKING_RETURNED_ERROR,
-};
-
-typedef enum bt_message_iterator_class_next_method_status
-(*bt_message_iterator_next_method)(
-               void *, bt_message_array_const, uint64_t, uint64_t *);
-
-typedef enum bt_message_iterator_class_seek_ns_from_origin_method_status
-(*bt_message_iterator_seek_ns_from_origin_method)(
-               void *, int64_t);
-
-typedef enum bt_message_iterator_class_seek_beginning_method_status
-(*bt_message_iterator_seek_beginning_method)(
-               void *);
-
-typedef enum bt_message_iterator_class_can_seek_ns_from_origin_method_status
-(*bt_message_iterator_can_seek_ns_from_origin_method)(
-               void *, int64_t, bt_bool *);
-
-typedef enum bt_message_iterator_class_can_seek_beginning_method_status
-(*bt_message_iterator_can_seek_beginning_method)(
-               void *, bt_bool *);
-
-struct bt_self_message_iterator_configuration {
-       bool frozen;
-       bool can_seek_forward;
-};
-
-struct bt_message_iterator {
-       struct bt_object base;
-       GPtrArray *msgs;
-       struct bt_component *upstream_component; /* Weak */
-       struct bt_port *upstream_port; /* Weak */
-       struct bt_connection *connection; /* Weak */
-       struct bt_graph *graph; /* Weak */
-       struct bt_self_message_iterator_configuration config;
-
-       /*
-        * Array of
-        * `struct bt_message_iterator *`
-        * (weak).
-        *
-        * This is an array of upstream message iterators on which this
-        * iterator depends. The references are weak: an upstream
-        * message iterator is responsible for removing its entry within
-        * this array on finalization/destruction.
-        */
-       GPtrArray *upstream_msg_iters;
-
-       /*
-        * Downstream message iterator which depends on this message
-        * iterator (weak).
-        *
-        * This can be `NULL` if this message iterator's owner is a sink
-        * component.
-        */
-       struct bt_message_iterator *downstream_msg_iter;
-
-       struct {
-               bt_message_iterator_next_method next;
-
-               /* These two are always both set or both unset. */
-               bt_message_iterator_seek_ns_from_origin_method seek_ns_from_origin;
-               bt_message_iterator_can_seek_ns_from_origin_method can_seek_ns_from_origin;
-
-               /* These two are always both set or both unset. */
-               bt_message_iterator_seek_beginning_method seek_beginning;
-               bt_message_iterator_can_seek_beginning_method can_seek_beginning;
-       } methods;
-
-       enum bt_message_iterator_state state;
-
-       /*
-        * Timestamp of the last received message (or INT64_MIN in the
-        * beginning, or after a seek to beginning).
-        */
-       int64_t last_ns_from_origin;
-
-       struct {
-               enum {
-                       /* We haven't recorded clock properties yet. */
-                       CLOCK_EXPECTATION_UNSET,
-
-                       /* Expect to have no clock. */
-                       CLOCK_EXPECTATION_NONE,
-
-                       /* Clock with origin_is_unix_epoch true.*/
-                       CLOCK_EXPECTATION_ORIGIN_UNIX,
-
-                       /* Clock with origin_is_unix_epoch false, with a UUID.*/
-                       CLOCK_EXPECTATION_ORIGIN_OTHER_UUID,
-
-                       /* Clock with origin_is_unix_epoch false, without a UUID.*/
-                       CLOCK_EXPECTATION_ORIGIN_OTHER_NO_UUID,
-               } type;
-
-               /*
-                * Expected UUID of the clock, if `type`is CLOCK_EXPECTATION_ORIGIN_OTHER_UUID.
-                *
-                * If the clock's origin is the unix epoch, the UUID is
-                * irrelevant (as the clock will be correlatable with other
-                * clocks having the same origin).
-                */
-               bt_uuid_t uuid;
-       } clock_expectation;
-
-       BT_IF_DEV_MODE(GHashTable *per_stream_state);
-
-       /*
-        * Data necessary for auto seek (the seek-to-beginning then fast-forward
-        * seek strategy).
-        */
-       struct {
-               /*
-                * Queue of `const bt_message *` (owned by this queue).
-                *
-                * When fast-forwarding, we get the messages from upstream in
-                * batches. Once we have found the first message with timestamp
-                * greater or equal to the seek time, we put it and all of the
-                * following message of the batch in this queue.  They will be
-                * sent on the next "next" call on this iterator.
-                *
-                * The messages are in chronological order (i.e. the first to
-                * send is the first of the queue).
-                */
-               GQueue *msgs;
-
-               /*
-                * After auto-seeking, we replace the iterator's `next` callback
-                * with our own, which returns the contents of the `msgs` queue.
-                * This field is where we save the original callback, so we can
-                * restore it.
-                */
-               void *original_next_callback;
-       } auto_seek;
-
-       void *user_data;
-};
-
-void bt_message_iterator_try_finalize(
-               struct bt_message_iterator *iterator);
-
-void bt_message_iterator_set_connection(
-               struct bt_message_iterator *iterator,
-               struct bt_connection *connection);
-
-static inline
-const char *bt_message_iterator_state_string(
-               enum bt_message_iterator_state state)
-{
-       switch (state) {
-       case BT_MESSAGE_ITERATOR_STATE_ACTIVE:
-               return "ACTIVE";
-       case BT_MESSAGE_ITERATOR_STATE_ENDED:
-               return "ENDED";
-       case BT_MESSAGE_ITERATOR_STATE_FINALIZING:
-               return "FINALIZING";
-       case BT_MESSAGE_ITERATOR_STATE_FINALIZED:
-               return "FINALIZED";
-       case BT_MESSAGE_ITERATOR_STATE_SEEKING:
-               return "SEEKING";
-       case BT_MESSAGE_ITERATOR_STATE_LAST_SEEKING_RETURNED_AGAIN:
-               return "LAST_SEEKING_RETURNED_AGAIN";
-       case BT_MESSAGE_ITERATOR_STATE_LAST_SEEKING_RETURNED_ERROR:
-               return "LAST_SEEKING_RETURNED_ERROR";
-       default:
-               return "(unknown)";
-       }
-};
-
-#endif /* BABELTRACE_GRAPH_MESSAGE_ITERATOR_INTERNAL_H */
index bf70f468a39168f1a63eb8179a32cc59627cffe7..82558067bfb2e5b78b9ed9272a6506edcd76b434 100644 (file)
@@ -30,9 +30,9 @@
 #include "graph/component.h"
 #include "graph/connection.h"
 #include "graph/graph.h"
+#include "graph/iterator.h"
 #include "graph/message/discarded-items.h"
 #include "graph/message/event.h"
-#include "graph/message/iterator.h"
 #include "graph/message/message.h"
 #include "graph/message/packet.h"
 #include "graph/message/stream.h"
This page took 0.033786 seconds and 4 git commands to generate.