1 #ifndef BABELTRACE_GRAPH_GRAPH_H
2 #define BABELTRACE_GRAPH_GRAPH_H
5 * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
6 * Copyright 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
8 * Permission is hereby granted, free of charge, to any person obtaining a copy
9 * of this software and associated documentation files (the "Software"), to deal
10 * in the Software without restriction, including without limitation the rights
11 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 * copies of the Software, and to permit persons to whom the Software is
13 * furnished to do so, subject to the following conditions:
15 * The above copyright notice and this permission notice shall be included in
16 * all copies or substantial portions of the Software.
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28 #include <babeltrace/types.h>
30 /* For enum bt_graph_status */
31 #include <babeltrace/graph/graph-const.h>
38 struct bt_component_class
;
39 struct bt_component_class_filter
;
40 struct bt_component_class_sink
;
41 struct bt_component_class_source
;
42 struct bt_component_filter
;
43 struct bt_component_sink
;
44 struct bt_component_source
;
48 struct bt_port_output
;
51 typedef void (*bt_graph_filter_component_input_port_added_listener_func
)(
52 const struct bt_component_filter
*component
,
53 const struct bt_port_input
*port
, void *data
);
55 typedef void (*bt_graph_sink_component_input_port_added_listener_func
)(
56 const struct bt_component_sink
*component
,
57 const struct bt_port_input
*port
, void *data
);
59 typedef void (*bt_graph_source_component_output_port_added_listener_func
)(
60 const struct bt_component_source
*component
,
61 const struct bt_port_output
*port
, void *data
);
63 typedef void (*bt_graph_filter_component_output_port_added_listener_func
)(
64 const struct bt_component_filter
*component
,
65 const struct bt_port_output
*port
, void *data
);
67 typedef void (*bt_graph_filter_component_input_port_removed_listener_func
)(
68 const struct bt_component_filter
*component
,
69 const struct bt_port_input
*port
, void *data
);
71 typedef void (*bt_graph_sink_component_input_port_removed_listener_func
)(
72 const struct bt_component_sink
*component
,
73 const struct bt_port_input
*port
, void *data
);
75 typedef void (*bt_graph_source_component_output_port_removed_listener_func
)(
76 const struct bt_component_source
*component
,
77 const struct bt_port_output
*port
, void *data
);
79 typedef void (*bt_graph_filter_component_output_port_removed_listener_func
)(
80 const struct bt_component_filter
*component
,
81 const struct bt_port_output
*port
, void *data
);
83 typedef void (*bt_graph_source_filter_component_ports_connected_listener_func
)(
84 const struct bt_component_source
*source_component
,
85 const struct bt_component_filter
*filter_component
,
86 const struct bt_port_output
*upstream_port
,
87 const struct bt_port_input
*downstream_port
, void *data
);
89 typedef void (*bt_graph_source_sink_component_ports_connected_listener_func
)(
90 const struct bt_component_source
*source_component
,
91 const struct bt_component_sink
*sink_component
,
92 const struct bt_port_output
*upstream_port
,
93 const struct bt_port_input
*downstream_port
, void *data
);
95 typedef void (*bt_graph_filter_sink_component_ports_connected_listener_func
)(
96 const struct bt_component_filter
*filter_component
,
97 const struct bt_component_sink
*sink_component
,
98 const struct bt_port_output
*upstream_port
,
99 const struct bt_port_input
*downstream_port
, void *data
);
101 typedef void (*bt_graph_source_filter_component_ports_disconnected_listener_func
)(
102 const struct bt_component_source
*source_component
,
103 const struct bt_component_filter
*filter_component
,
104 const struct bt_port_output
*upstream_port
,
105 const struct bt_port_input
*downstream_port
,
108 typedef void (*bt_graph_source_sink_component_ports_disconnected_listener_func
)(
109 const struct bt_component_source
*source_component
,
110 const struct bt_component_sink
*sink_component
,
111 const struct bt_port_output
*upstream_port
,
112 const struct bt_port_input
*downstream_port
,
115 typedef void (*bt_graph_filter_sink_component_ports_disconnected_listener_func
)(
116 const struct bt_component_filter
*filter_component
,
117 const struct bt_component_sink
*sink_component
,
118 const struct bt_port_output
*upstream_port
,
119 const struct bt_port_input
*downstream_port
,
122 typedef void (* bt_graph_listener_removed_func
)(void *data
);
124 extern struct bt_graph
*bt_graph_create(void);
126 extern enum bt_graph_status
bt_graph_add_source_component(
127 struct bt_graph
*graph
,
128 const struct bt_component_class_source
*component_class
,
129 const char *name
, const struct bt_value
*params
,
130 const struct bt_component_source
**component
);
132 extern enum bt_graph_status
133 bt_graph_add_source_component_with_init_method_data(
134 struct bt_graph
*graph
,
135 const struct bt_component_class_source
*component_class
,
136 const char *name
, const struct bt_value
*params
,
137 void *init_method_data
,
138 const struct bt_component_source
**component
);
140 extern enum bt_graph_status
bt_graph_add_filter_component(
141 struct bt_graph
*graph
,
142 const struct bt_component_class_filter
*component_class
,
143 const char *name
, const struct bt_value
*params
,
144 const struct bt_component_filter
**component
);
146 extern enum bt_graph_status
147 bt_graph_add_filter_component_with_init_method_data(
148 struct bt_graph
*graph
,
149 const struct bt_component_class_filter
*component_class
,
150 const char *name
, const struct bt_value
*params
,
151 void *init_method_data
,
152 const struct bt_component_filter
**component
);
154 extern enum bt_graph_status
bt_graph_add_sink_component(
155 struct bt_graph
*graph
,
156 const struct bt_component_class_sink
*component_class
,
157 const char *name
, const struct bt_value
*params
,
158 const struct bt_component_sink
**component
);
160 extern enum bt_graph_status
161 bt_graph_add_sink_component_with_init_method_data(
162 struct bt_graph
*graph
,
163 const struct bt_component_class_sink
*component_class
,
164 const char *name
, const struct bt_value
*params
,
165 void *init_method_data
,
166 const struct bt_component_sink
**component
);
168 extern enum bt_graph_status
bt_graph_connect_ports(
169 struct bt_graph
*graph
,
170 const struct bt_port_output
*upstream
,
171 const struct bt_port_input
*downstream
,
172 const struct bt_connection
**connection
);
174 extern enum bt_graph_status
bt_graph_run(struct bt_graph
*graph
);
176 extern enum bt_graph_status
bt_graph_consume(
177 struct bt_graph
*graph
);
179 extern enum bt_graph_status
180 bt_graph_add_filter_component_input_port_added_listener(
181 struct bt_graph
*graph
,
182 bt_graph_filter_component_input_port_added_listener_func listener
,
183 bt_graph_listener_removed_func listener_removed
, void *data
,
186 extern enum bt_graph_status
187 bt_graph_add_sink_component_input_port_added_listener(
188 struct bt_graph
*graph
,
189 bt_graph_sink_component_input_port_added_listener_func listener
,
190 bt_graph_listener_removed_func listener_removed
, void *data
,
193 extern enum bt_graph_status
194 bt_graph_add_source_component_output_port_added_listener(
195 struct bt_graph
*graph
,
196 bt_graph_source_component_output_port_added_listener_func listener
,
197 bt_graph_listener_removed_func listener_removed
, void *data
,
200 extern enum bt_graph_status
201 bt_graph_add_filter_component_output_port_added_listener(
202 struct bt_graph
*graph
,
203 bt_graph_filter_component_output_port_added_listener_func listener
,
204 bt_graph_listener_removed_func listener_removed
, void *data
,
207 extern enum bt_graph_status
208 bt_graph_add_filter_component_input_port_removed_listener(
209 struct bt_graph
*graph
,
210 bt_graph_filter_component_input_port_removed_listener_func listener
,
211 bt_graph_listener_removed_func listener_removed
, void *data
,
214 extern enum bt_graph_status
215 bt_graph_add_sink_component_input_port_removed_listener(
216 struct bt_graph
*graph
,
217 bt_graph_sink_component_input_port_removed_listener_func listener
,
218 bt_graph_listener_removed_func listener_removed
, void *data
,
221 extern enum bt_graph_status
222 bt_graph_add_source_component_output_port_removed_listener(
223 struct bt_graph
*graph
,
224 bt_graph_source_component_output_port_removed_listener_func listener
,
225 bt_graph_listener_removed_func listener_removed
, void *data
,
228 extern enum bt_graph_status
229 bt_graph_add_filter_component_output_port_removed_listener(
230 struct bt_graph
*graph
,
231 bt_graph_filter_component_output_port_removed_listener_func listener
,
232 bt_graph_listener_removed_func listener_removed
, void *data
,
235 extern enum bt_graph_status
236 bt_graph_add_source_filter_component_ports_connected_listener(
237 struct bt_graph
*graph
,
238 bt_graph_source_filter_component_ports_connected_listener_func listener
,
239 bt_graph_listener_removed_func listener_removed
, void *data
,
242 extern enum bt_graph_status
243 bt_graph_add_source_sink_component_ports_connected_listener(
244 struct bt_graph
*graph
,
245 bt_graph_source_sink_component_ports_connected_listener_func listener
,
246 bt_graph_listener_removed_func listener_removed
, void *data
,
249 extern enum bt_graph_status
250 bt_graph_add_filter_sink_component_ports_connected_listener(
251 struct bt_graph
*graph
,
252 bt_graph_filter_sink_component_ports_connected_listener_func listener
,
253 bt_graph_listener_removed_func listener_removed
, void *data
,
256 extern enum bt_graph_status
257 bt_graph_add_source_filter_component_ports_disconnected_listener(
258 struct bt_graph
*graph
,
259 bt_graph_source_filter_component_ports_disconnected_listener_func listener
,
260 bt_graph_listener_removed_func listener_removed
, void *data
,
263 extern enum bt_graph_status
264 bt_graph_add_source_sink_component_ports_disconnected_listener(
265 struct bt_graph
*graph
,
266 bt_graph_source_sink_component_ports_disconnected_listener_func listener
,
267 bt_graph_listener_removed_func listener_removed
, void *data
,
270 extern enum bt_graph_status
271 bt_graph_add_filter_sink_component_ports_disconnected_listener(
272 struct bt_graph
*graph
,
273 bt_graph_filter_sink_component_ports_disconnected_listener_func listener
,
274 bt_graph_listener_removed_func listener_removed
, void *data
,
277 extern enum bt_graph_status
bt_graph_cancel(struct bt_graph
*graph
);
283 #endif /* BABELTRACE_GRAPH_GRAPH_H */