Commit | Line | Data |
---|---|---|
1ca80abd PP |
1 | #ifndef BABELTRACE_GRAPH_GRAPH_H |
2 | #define BABELTRACE_GRAPH_GRAPH_H | |
c0418dd9 JG |
3 | |
4 | /* | |
f60c8b34 | 5 | * BabelTrace - Babeltrace Graph Interface |
c0418dd9 | 6 | * |
f60c8b34 | 7 | * Copyright 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com> |
c0418dd9 JG |
8 | * |
9 | * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com> | |
10 | * | |
11 | * Permission is hereby granted, free of charge, to any person obtaining a copy | |
12 | * of this software and associated documentation files (the "Software"), to deal | |
13 | * in the Software without restriction, including without limitation the rights | |
14 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
15 | * copies of the Software, and to permit persons to whom the Software is | |
16 | * furnished to do so, subject to the following conditions: | |
17 | * | |
18 | * The above copyright notice and this permission notice shall be included in | |
19 | * all copies or substantial portions of the Software. | |
20 | * | |
21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
22 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
23 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
24 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
25 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
26 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | |
27 | * SOFTWARE. | |
28 | */ | |
29 | ||
b2e0c907 | 30 | #include <babeltrace/graph/component.h> |
202a3a13 | 31 | #include <babeltrace/types.h> |
c0418dd9 JG |
32 | |
33 | #ifdef __cplusplus | |
34 | extern "C" { | |
35 | #endif | |
36 | ||
f60c8b34 JG |
37 | struct bt_port; |
38 | struct bt_connection; | |
c0418dd9 | 39 | |
f60c8b34 | 40 | enum bt_graph_status { |
72b913fb | 41 | /** No sink can consume at the moment. */ |
fe8ad2b6 | 42 | BT_GRAPH_STATUS_AGAIN = 11, |
f60c8b34 JG |
43 | /** Downstream component does not support multiple inputs. */ |
44 | BT_GRAPH_STATUS_END = 1, | |
45 | BT_GRAPH_STATUS_OK = 0, | |
f60c8b34 JG |
46 | /** Component is already part of another graph. */ |
47 | BT_GRAPH_STATUS_ALREADY_IN_A_GRAPH = -2, | |
48 | /** Invalid arguments. */ | |
fe8ad2b6 | 49 | BT_GRAPH_STATUS_INVALID = -22, |
f60c8b34 | 50 | /** No sink in graph. */ |
fe8ad2b6 | 51 | BT_GRAPH_STATUS_NO_SINK = -6, |
f60c8b34 | 52 | /** General error. */ |
fe8ad2b6 | 53 | BT_GRAPH_STATUS_ERROR = -1, |
202a3a13 PP |
54 | /** Canceled. */ |
55 | BT_GRAPH_STATUS_CANCELED = -125, | |
f60c8b34 | 56 | }; |
c0418dd9 | 57 | |
1bf957a0 PP |
58 | typedef void (*bt_graph_port_added_listener)(struct bt_port *port, |
59 | void *data); | |
60 | typedef void (*bt_graph_port_removed_listener)(struct bt_component *component, | |
61 | struct bt_port *port, void *data); | |
f345f8bb PP |
62 | typedef void (*bt_graph_ports_connected_listener)(struct bt_port *upstream_port, |
63 | struct bt_port *downstream_port, void *data); | |
64 | typedef void (*bt_graph_ports_disconnected_listener)( | |
65 | struct bt_component *upstream_component, | |
66 | struct bt_component *downstream_component, | |
67 | struct bt_port *upstream_port, struct bt_port *downstream_port, | |
1bf957a0 PP |
68 | void *data); |
69 | ||
f60c8b34 | 70 | extern struct bt_graph *bt_graph_create(void); |
c0418dd9 JG |
71 | |
72 | /** | |
f60c8b34 JG |
73 | * Creates a connection between two components using the two ports specified |
74 | * and adds the connection and components (if not already added) to the graph. | |
c0418dd9 | 75 | */ |
77a54f99 | 76 | extern struct bt_connection *bt_graph_connect_ports(struct bt_graph *graph, |
f60c8b34 JG |
77 | struct bt_port *upstream, |
78 | struct bt_port *downstream); | |
c0418dd9 JG |
79 | |
80 | /** | |
81 | * Add a component as a "sibling" of the origin component. Sibling share | |
82 | * connections equivalent to each other at the time of connection (same | |
f60c8b34 | 83 | * upstream and downstream ports). |
c0418dd9 | 84 | */ |
f60c8b34 JG |
85 | extern enum bt_graph_status bt_graph_add_component_as_sibling( |
86 | struct bt_graph *graph, struct bt_component *origin, | |
c0418dd9 JG |
87 | struct bt_component *new_component); |
88 | ||
89 | /** | |
f60c8b34 JG |
90 | * Run graph to completion or until a single sink is left and "AGAIN" is received. |
91 | * | |
c0418dd9 | 92 | * Runs "bt_component_sink_consume()" on all sinks in round-robin until they all |
f60c8b34 JG |
93 | * indicate that the end is reached or that an error occured. |
94 | */ | |
72b913fb | 95 | extern enum bt_graph_status bt_graph_run(struct bt_graph *graph); |
f60c8b34 JG |
96 | |
97 | /** | |
98 | * Runs "bt_component_sink_consume()" on the graph's sinks. Each invokation will | |
99 | * invoke "bt_component_sink_consume()" on the next sink, in round-robin, until | |
100 | * they all indicated that the end is reached. | |
c0418dd9 | 101 | */ |
72b913fb | 102 | extern enum bt_graph_status bt_graph_consume(struct bt_graph *graph); |
c0418dd9 | 103 | |
1bf957a0 PP |
104 | extern enum bt_graph_status bt_graph_add_port_added_listener( |
105 | struct bt_graph *graph, | |
106 | bt_graph_port_added_listener listener, void *data); | |
107 | ||
108 | extern enum bt_graph_status bt_graph_add_port_removed_listener( | |
109 | struct bt_graph *graph, | |
110 | bt_graph_port_removed_listener listener, void *data); | |
111 | ||
f345f8bb | 112 | extern enum bt_graph_status bt_graph_add_ports_connected_listener( |
1bf957a0 | 113 | struct bt_graph *graph, |
f345f8bb | 114 | bt_graph_ports_connected_listener listener, void *data); |
1bf957a0 | 115 | |
f345f8bb | 116 | extern enum bt_graph_status bt_graph_add_ports_disconnected_listener( |
1bf957a0 | 117 | struct bt_graph *graph, |
f345f8bb | 118 | bt_graph_ports_disconnected_listener listener, void *data); |
1bf957a0 | 119 | |
202a3a13 PP |
120 | extern enum bt_graph_status bt_graph_cancel(struct bt_graph *graph); |
121 | extern bt_bool bt_graph_is_canceled(struct bt_graph *graph); | |
122 | ||
c0418dd9 JG |
123 | #ifdef __cplusplus |
124 | } | |
125 | #endif | |
126 | ||
1ca80abd | 127 | #endif /* BABELTRACE_GRAPH_GRAPH_H */ |