Move to kernel style SPDX license identifiers
[babeltrace.git] / src / lib / graph / connection.h
1 /*
2 * SPDX-License-Identifier: MIT
3 *
4 * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
5 * Copyright 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 */
7
8 #ifndef BABELTRACE_GRAPH_CONNECTION_INTERNAL_H
9 #define BABELTRACE_GRAPH_CONNECTION_INTERNAL_H
10
11 #include <babeltrace2/graph/connection.h>
12 #include "lib/object.h"
13 #include "common/assert.h"
14 #include "common/macros.h"
15 #include <stdbool.h>
16
17 #include "message/iterator.h"
18
19 struct bt_graph;
20
21 struct bt_connection {
22 /*
23 * The graph is a connection's parent and the connection is the parent
24 * of all iterators it has created.
25 */
26 struct bt_object base;
27 /*
28 * Weak references are held to both ports. Their existence is guaranteed
29 * by the existence of the graph and thus, of their respective
30 * components.
31 */
32 /* Downstream port. */
33 struct bt_port *downstream_port;
34 /* Upstream port. */
35 struct bt_port *upstream_port;
36
37 /*
38 * Weak references to all the message iterators that were
39 * created on this connection.
40 */
41 GPtrArray *iterators;
42
43 bool notified_upstream_port_connected;
44 bool notified_downstream_port_connected;
45 bool notified_graph_ports_connected;
46 };
47
48 BT_HIDDEN
49 struct bt_connection *bt_connection_create(struct bt_graph *graph,
50 struct bt_port *upstream_port,
51 struct bt_port *downstream_port);
52
53 BT_HIDDEN
54 void bt_connection_end(struct bt_connection *conn, bool try_remove_from_graph);
55
56 BT_HIDDEN
57 void bt_connection_remove_iterator(struct bt_connection *conn,
58 struct bt_message_iterator *iterator);
59
60 static inline
61 struct bt_graph *bt_connection_borrow_graph(struct bt_connection *conn)
62 {
63 BT_ASSERT_DBG(conn);
64 return (void *) conn->base.parent;
65 }
66
67 #endif /* BABELTRACE_GRAPH_CONNECTION_INTERNAL_H */
This page took 0.030748 seconds and 4 git commands to generate.