Make bt_private_connection_create_notification_iterator() return a status code
[babeltrace.git] / include / babeltrace / graph / connection-internal.h
index d22c7eea04e8af898f647957c1a9086ee687b95c..13e7d9ee65ad95aa0460819131a9e0dfb3b83347 100644 (file)
@@ -28,6 +28,7 @@
  */
 
 #include <babeltrace/graph/connection.h>
+#include <babeltrace/graph/notification-iterator.h>
 #include <babeltrace/graph/private-connection.h>
 #include <babeltrace/object-internal.h>
 
@@ -48,6 +49,12 @@ struct bt_connection {
        struct bt_port *downstream_port;
        /* Upstream port. */
        struct bt_port *upstream_port;
+
+       /*
+        * Weak references to all the notification iterators that were
+        * created on this connection.
+        */
+       GPtrArray *iterators;
 };
 
 static inline
@@ -70,7 +77,41 @@ struct bt_connection *bt_connection_create(struct bt_graph *graph,
                struct bt_port *downstream_port);
 
 BT_HIDDEN
-void bt_connection_disconnect_ports(struct bt_connection *conn,
-               struct bt_component *comp);
+void bt_connection_disconnect_ports(struct bt_connection *conn);
+
+BT_HIDDEN
+void bt_connection_remove_iterator(struct bt_connection *conn,
+               struct bt_notification_iterator *iterator);
+
+static inline
+enum bt_connection_status
+bt_connection_status_from_notification_iterator_status(
+               enum bt_notification_iterator_status iter_status)
+{
+       switch (iter_status) {
+       case BT_NOTIFICATION_ITERATOR_STATUS_CANCELED:
+               return BT_CONNECTION_STATUS_ERROR;
+       case BT_NOTIFICATION_ITERATOR_STATUS_AGAIN:
+               return BT_CONNECTION_STATUS_ERROR;
+       case BT_NOTIFICATION_ITERATOR_STATUS_END:
+               return BT_CONNECTION_STATUS_ERROR;
+       case BT_NOTIFICATION_ITERATOR_STATUS_OK:
+               return BT_CONNECTION_STATUS_OK;
+       case BT_NOTIFICATION_ITERATOR_STATUS_INVALID:
+               return BT_CONNECTION_STATUS_INVALID;
+       case BT_NOTIFICATION_ITERATOR_STATUS_ERROR:
+               return BT_CONNECTION_STATUS_ERROR;
+       case BT_NOTIFICATION_ITERATOR_STATUS_NOMEM:
+               return BT_CONNECTION_STATUS_NOMEM;
+       case BT_NOTIFICATION_ITERATOR_STATUS_UNSUPPORTED:
+               return BT_CONNECTION_STATUS_ERROR;
+       default:
+#ifdef BT_LOGF
+               BT_LOGF("Unknown notification iterator status: status=%d",
+                       iter_status);
+#endif
+               abort();
+       }
+}
 
 #endif /* BABELTRACE_COMPONENT_CONNECTION_INTERNAL_H */
This page took 0.029293 seconds and 4 git commands to generate.