1 #ifndef BABELTRACE_GRAPH_GRAPH_H
2 #define BABELTRACE_GRAPH_GRAPH_H
5 * Copyright 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
7 * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
9 * Permission is hereby granted, free of charge, to any person obtaining a copy
10 * of this software and associated documentation files (the "Software"), to deal
11 * in the Software without restriction, including without limitation the rights
12 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 * copies of the Software, and to permit persons to whom the Software is
14 * furnished to do so, subject to the following conditions:
16 * The above copyright notice and this permission notice shall be included in
17 * all copies or substantial portions of the Software.
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29 #include <babeltrace/types.h>
31 /* For enum bt_graph_status */
32 #include <babeltrace/graph/graph-const.h>
39 struct bt_component_class
;
40 struct bt_component_class_filter
;
41 struct bt_component_class_sink
;
42 struct bt_component_class_source
;
43 struct bt_component_filter
;
44 struct bt_component_sink
;
45 struct bt_component_source
;
49 struct bt_port_output
;
52 typedef void (*bt_graph_filter_component_input_port_added_listener_func
)(
53 const struct bt_component_filter
*component
,
54 const struct bt_port_input
*port
, void *data
);
56 typedef void (*bt_graph_sink_component_input_port_added_listener_func
)(
57 const struct bt_component_sink
*component
,
58 const struct bt_port_input
*port
, void *data
);
60 typedef void (*bt_graph_source_component_output_port_added_listener_func
)(
61 const struct bt_component_source
*component
,
62 const struct bt_port_output
*port
, void *data
);
64 typedef void (*bt_graph_filter_component_output_port_added_listener_func
)(
65 const struct bt_component_filter
*component
,
66 const struct bt_port_output
*port
, void *data
);
68 typedef void (*bt_graph_filter_component_input_port_removed_listener_func
)(
69 const struct bt_component_filter
*component
,
70 const struct bt_port_input
*port
, void *data
);
72 typedef void (*bt_graph_sink_component_input_port_removed_listener_func
)(
73 const struct bt_component_sink
*component
,
74 const struct bt_port_input
*port
, void *data
);
76 typedef void (*bt_graph_source_component_output_port_removed_listener_func
)(
77 const struct bt_component_source
*component
,
78 const struct bt_port_output
*port
, void *data
);
80 typedef void (*bt_graph_filter_component_output_port_removed_listener_func
)(
81 const struct bt_component_filter
*component
,
82 const struct bt_port_output
*port
, void *data
);
84 typedef void (*bt_graph_source_filter_component_ports_connected_listener_func
)(
85 const struct bt_component_source
*source_component
,
86 const struct bt_component_filter
*filter_component
,
87 const struct bt_port_output
*upstream_port
,
88 const struct bt_port_input
*downstream_port
, void *data
);
90 typedef void (*bt_graph_source_sink_component_ports_connected_listener_func
)(
91 const struct bt_component_source
*source_component
,
92 const struct bt_component_sink
*sink_component
,
93 const struct bt_port_output
*upstream_port
,
94 const struct bt_port_input
*downstream_port
, void *data
);
96 typedef void (*bt_graph_filter_sink_component_ports_connected_listener_func
)(
97 const struct bt_component_filter
*filter_component
,
98 const struct bt_component_sink
*sink_component
,
99 const struct bt_port_output
*upstream_port
,
100 const struct bt_port_input
*downstream_port
, void *data
);
102 typedef void (*bt_graph_source_filter_component_ports_disconnected_listener_func
)(
103 const struct bt_component_source
*source_component
,
104 const struct bt_component_filter
*filter_component
,
105 const struct bt_port_output
*upstream_port
,
106 const struct bt_port_input
*downstream_port
,
109 typedef void (*bt_graph_source_sink_component_ports_disconnected_listener_func
)(
110 const struct bt_component_source
*source_component
,
111 const struct bt_component_sink
*sink_component
,
112 const struct bt_port_output
*upstream_port
,
113 const struct bt_port_input
*downstream_port
,
116 typedef void (*bt_graph_filter_sink_component_ports_disconnected_listener_func
)(
117 const struct bt_component_filter
*filter_component
,
118 const struct bt_component_sink
*sink_component
,
119 const struct bt_port_output
*upstream_port
,
120 const struct bt_port_input
*downstream_port
,
123 typedef void (* bt_graph_listener_removed_func
)(void *data
);
125 extern struct bt_graph
*bt_graph_create(void);
127 extern enum bt_graph_status
bt_graph_add_source_component(
128 struct bt_graph
*graph
,
129 const struct bt_component_class_source
*component_class
,
130 const char *name
, const struct bt_value
*params
,
131 const struct bt_component_source
**component
);
133 extern enum bt_graph_status
134 bt_graph_add_source_component_with_init_method_data(
135 struct bt_graph
*graph
,
136 const struct bt_component_class_source
*component_class
,
137 const char *name
, const struct bt_value
*params
,
138 void *init_method_data
,
139 const struct bt_component_source
**component
);
141 extern enum bt_graph_status
bt_graph_add_filter_component(
142 struct bt_graph
*graph
,
143 const struct bt_component_class_filter
*component_class
,
144 const char *name
, const struct bt_value
*params
,
145 const struct bt_component_filter
**component
);
147 extern enum bt_graph_status
148 bt_graph_add_filter_component_with_init_method_data(
149 struct bt_graph
*graph
,
150 const struct bt_component_class_filter
*component_class
,
151 const char *name
, const struct bt_value
*params
,
152 void *init_method_data
,
153 const struct bt_component_filter
**component
);
155 extern enum bt_graph_status
bt_graph_add_sink_component(
156 struct bt_graph
*graph
,
157 const struct bt_component_class_sink
*component_class
,
158 const char *name
, const struct bt_value
*params
,
159 const struct bt_component_sink
**component
);
161 extern enum bt_graph_status
162 bt_graph_add_sink_component_with_init_method_data(
163 struct bt_graph
*graph
,
164 const struct bt_component_class_sink
*component_class
,
165 const char *name
, const struct bt_value
*params
,
166 void *init_method_data
,
167 const struct bt_component_sink
**component
);
169 extern enum bt_graph_status
bt_graph_connect_ports(
170 struct bt_graph
*graph
,
171 const struct bt_port_output
*upstream
,
172 const struct bt_port_input
*downstream
,
173 const struct bt_connection
**connection
);
175 extern enum bt_graph_status
bt_graph_run(struct bt_graph
*graph
);
177 extern enum bt_graph_status
bt_graph_consume(
178 struct bt_graph
*graph
);
180 extern enum bt_graph_status
181 bt_graph_add_filter_component_input_port_added_listener(
182 struct bt_graph
*graph
,
183 bt_graph_filter_component_input_port_added_listener_func listener
,
184 bt_graph_listener_removed_func listener_removed
, void *data
,
187 extern enum bt_graph_status
188 bt_graph_add_sink_component_input_port_added_listener(
189 struct bt_graph
*graph
,
190 bt_graph_sink_component_input_port_added_listener_func listener
,
191 bt_graph_listener_removed_func listener_removed
, void *data
,
194 extern enum bt_graph_status
195 bt_graph_add_source_component_output_port_added_listener(
196 struct bt_graph
*graph
,
197 bt_graph_source_component_output_port_added_listener_func listener
,
198 bt_graph_listener_removed_func listener_removed
, void *data
,
201 extern enum bt_graph_status
202 bt_graph_add_filter_component_output_port_added_listener(
203 struct bt_graph
*graph
,
204 bt_graph_filter_component_output_port_added_listener_func listener
,
205 bt_graph_listener_removed_func listener_removed
, void *data
,
208 extern enum bt_graph_status
209 bt_graph_add_filter_component_input_port_removed_listener(
210 struct bt_graph
*graph
,
211 bt_graph_filter_component_input_port_removed_listener_func listener
,
212 bt_graph_listener_removed_func listener_removed
, void *data
,
215 extern enum bt_graph_status
216 bt_graph_add_sink_component_input_port_removed_listener(
217 struct bt_graph
*graph
,
218 bt_graph_sink_component_input_port_removed_listener_func listener
,
219 bt_graph_listener_removed_func listener_removed
, void *data
,
222 extern enum bt_graph_status
223 bt_graph_add_source_component_output_port_removed_listener(
224 struct bt_graph
*graph
,
225 bt_graph_source_component_output_port_removed_listener_func listener
,
226 bt_graph_listener_removed_func listener_removed
, void *data
,
229 extern enum bt_graph_status
230 bt_graph_add_filter_component_output_port_removed_listener(
231 struct bt_graph
*graph
,
232 bt_graph_filter_component_output_port_removed_listener_func listener
,
233 bt_graph_listener_removed_func listener_removed
, void *data
,
236 extern enum bt_graph_status
237 bt_graph_add_source_filter_component_ports_connected_listener(
238 struct bt_graph
*graph
,
239 bt_graph_source_filter_component_ports_connected_listener_func listener
,
240 bt_graph_listener_removed_func listener_removed
, void *data
,
243 extern enum bt_graph_status
244 bt_graph_add_source_sink_component_ports_connected_listener(
245 struct bt_graph
*graph
,
246 bt_graph_source_sink_component_ports_connected_listener_func listener
,
247 bt_graph_listener_removed_func listener_removed
, void *data
,
250 extern enum bt_graph_status
251 bt_graph_add_filter_sink_component_ports_connected_listener(
252 struct bt_graph
*graph
,
253 bt_graph_filter_sink_component_ports_connected_listener_func listener
,
254 bt_graph_listener_removed_func listener_removed
, void *data
,
257 extern enum bt_graph_status
258 bt_graph_add_source_filter_component_ports_disconnected_listener(
259 struct bt_graph
*graph
,
260 bt_graph_source_filter_component_ports_disconnected_listener_func listener
,
261 bt_graph_listener_removed_func listener_removed
, void *data
,
264 extern enum bt_graph_status
265 bt_graph_add_source_sink_component_ports_disconnected_listener(
266 struct bt_graph
*graph
,
267 bt_graph_source_sink_component_ports_disconnected_listener_func listener
,
268 bt_graph_listener_removed_func listener_removed
, void *data
,
271 extern enum bt_graph_status
272 bt_graph_add_filter_sink_component_ports_disconnected_listener(
273 struct bt_graph
*graph
,
274 bt_graph_filter_sink_component_ports_disconnected_listener_func listener
,
275 bt_graph_listener_removed_func listener_removed
, void *data
,
278 extern enum bt_graph_status
bt_graph_cancel(struct bt_graph
*graph
);
284 #endif /* BABELTRACE_GRAPH_GRAPH_H */