1 #ifndef BABELTRACE2_GRAPH_GRAPH_H
2 #define BABELTRACE2_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
27 #ifndef __BT_IN_BABELTRACE_H
28 # error "Please include <babeltrace2/babeltrace.h> instead."
31 #include <babeltrace2/types.h>
32 #include <babeltrace2/logging.h>
38 typedef enum bt_graph_listener_func_status
{
39 BT_GRAPH_LISTENER_FUNC_STATUS_OK
= __BT_FUNC_STATUS_OK
,
40 BT_GRAPH_LISTENER_FUNC_STATUS_ERROR
= __BT_FUNC_STATUS_ERROR
,
41 BT_GRAPH_LISTENER_FUNC_STATUS_MEMORY_ERROR
= __BT_FUNC_STATUS_MEMORY_ERROR
,
42 } bt_graph_listener_func_status
;
44 typedef bt_graph_listener_func_status
45 (*bt_graph_filter_component_input_port_added_listener_func
)(
46 const bt_component_filter
*component
,
47 const bt_port_input
*port
, void *data
);
49 typedef bt_graph_listener_func_status
50 (*bt_graph_sink_component_input_port_added_listener_func
)(
51 const bt_component_sink
*component
,
52 const bt_port_input
*port
, void *data
);
54 typedef bt_graph_listener_func_status
55 (*bt_graph_source_component_output_port_added_listener_func
)(
56 const bt_component_source
*component
,
57 const bt_port_output
*port
, void *data
);
59 typedef bt_graph_listener_func_status
60 (*bt_graph_filter_component_output_port_added_listener_func
)(
61 const bt_component_filter
*component
,
62 const bt_port_output
*port
, void *data
);
64 typedef bt_graph_listener_func_status
65 (*bt_graph_source_filter_component_ports_connected_listener_func
)(
66 const bt_component_source
*source_component
,
67 const bt_component_filter
*filter_component
,
68 const bt_port_output
*upstream_port
,
69 const bt_port_input
*downstream_port
, void *data
);
71 typedef bt_graph_listener_func_status
72 (*bt_graph_source_sink_component_ports_connected_listener_func
)(
73 const bt_component_source
*source_component
,
74 const bt_component_sink
*sink_component
,
75 const bt_port_output
*upstream_port
,
76 const bt_port_input
*downstream_port
, void *data
);
78 typedef bt_graph_listener_func_status
79 (*bt_graph_filter_filter_component_ports_connected_listener_func
)(
80 const bt_component_filter
*filter_component_upstream
,
81 const bt_component_filter
*filter_component_downstream
,
82 const bt_port_output
*upstream_port
,
83 const bt_port_input
*downstream_port
,
86 typedef bt_graph_listener_func_status
87 (*bt_graph_filter_sink_component_ports_connected_listener_func
)(
88 const bt_component_filter
*filter_component
,
89 const bt_component_sink
*sink_component
,
90 const bt_port_output
*upstream_port
,
91 const bt_port_input
*downstream_port
, void *data
);
93 typedef void (* bt_graph_listener_removed_func
)(void *data
);
95 extern bt_graph
*bt_graph_create(void);
97 typedef enum bt_graph_add_component_status
{
98 BT_GRAPH_ADD_COMPONENT_STATUS_OK
= __BT_FUNC_STATUS_OK
,
99 BT_GRAPH_ADD_COMPONENT_STATUS_ERROR
= __BT_FUNC_STATUS_ERROR
,
100 BT_GRAPH_ADD_COMPONENT_STATUS_MEMORY_ERROR
= __BT_FUNC_STATUS_MEMORY_ERROR
,
101 } bt_graph_add_component_status
;
103 extern bt_graph_add_component_status
104 bt_graph_add_source_component(bt_graph
*graph
,
105 const bt_component_class_source
*component_class
,
106 const char *name
, const bt_value
*params
,
107 bt_logging_level log_level
, const bt_component_source
**component
);
109 extern bt_graph_add_component_status
110 bt_graph_add_source_component_with_init_method_data(
112 const bt_component_class_source
*component_class
,
113 const char *name
, const bt_value
*params
,
114 void *init_method_data
, bt_logging_level log_level
,
115 const bt_component_source
**component
);
117 extern bt_graph_add_component_status
118 bt_graph_add_filter_component(bt_graph
*graph
,
119 const bt_component_class_filter
*component_class
,
120 const char *name
, const bt_value
*params
,
121 bt_logging_level log_level
,
122 const bt_component_filter
**component
);
124 extern bt_graph_add_component_status
125 bt_graph_add_filter_component_with_init_method_data(
127 const bt_component_class_filter
*component_class
,
128 const char *name
, const bt_value
*params
,
129 void *init_method_data
, bt_logging_level log_level
,
130 const bt_component_filter
**component
);
132 extern bt_graph_add_component_status
133 bt_graph_add_sink_component(
134 bt_graph
*graph
, const bt_component_class_sink
*component_class
,
135 const char *name
, const bt_value
*params
,
136 bt_logging_level log_level
,
137 const bt_component_sink
**component
);
139 extern bt_graph_add_component_status
140 bt_graph_add_sink_component_with_init_method_data(
141 bt_graph
*graph
, const bt_component_class_sink
*component_class
,
142 const char *name
, const bt_value
*params
,
143 void *init_method_data
, bt_logging_level log_level
,
144 const bt_component_sink
**component
);
146 typedef enum bt_graph_connect_ports_status
{
147 BT_GRAPH_CONNECT_PORTS_STATUS_OK
= __BT_FUNC_STATUS_OK
,
148 BT_GRAPH_CONNECT_PORTS_STATUS_ERROR
= __BT_FUNC_STATUS_ERROR
,
149 BT_GRAPH_CONNECT_PORTS_STATUS_CANCELED
= __BT_FUNC_STATUS_CANCELED
,
150 BT_GRAPH_CONNECT_PORTS_STATUS_MEMORY_ERROR
= __BT_FUNC_STATUS_MEMORY_ERROR
,
151 } bt_graph_connect_ports_status
;
153 extern bt_graph_connect_ports_status
bt_graph_connect_ports(bt_graph
*graph
,
154 const bt_port_output
*upstream
,
155 const bt_port_input
*downstream
,
156 const bt_connection
**connection
);
158 typedef enum bt_graph_run_status
{
159 BT_GRAPH_RUN_STATUS_OK
= __BT_FUNC_STATUS_OK
,
160 BT_GRAPH_RUN_STATUS_ERROR
= __BT_FUNC_STATUS_ERROR
,
161 BT_GRAPH_RUN_STATUS_MEMORY_ERROR
= __BT_FUNC_STATUS_MEMORY_ERROR
,
162 BT_GRAPH_RUN_STATUS_AGAIN
= __BT_FUNC_STATUS_AGAIN
,
163 BT_GRAPH_RUN_STATUS_END
= __BT_FUNC_STATUS_END
,
164 BT_GRAPH_RUN_STATUS_CANCELED
= __BT_FUNC_STATUS_CANCELED
,
165 } bt_graph_run_status
;
167 extern bt_graph_run_status
bt_graph_run(bt_graph
*graph
);
169 typedef enum bt_graph_consume_status
{
170 BT_GRAPH_CONSUME_STATUS_OK
= __BT_FUNC_STATUS_OK
,
171 BT_GRAPH_CONSUME_STATUS_ERROR
= __BT_FUNC_STATUS_ERROR
,
172 BT_GRAPH_CONSUME_STATUS_MEMORY_ERROR
= __BT_FUNC_STATUS_MEMORY_ERROR
,
173 BT_GRAPH_CONSUME_STATUS_AGAIN
= __BT_FUNC_STATUS_AGAIN
,
174 BT_GRAPH_CONSUME_STATUS_END
= __BT_FUNC_STATUS_END
,
175 BT_GRAPH_CONSUME_STATUS_CANCELED
= __BT_FUNC_STATUS_CANCELED
,
176 } bt_graph_consume_status
;
178 extern bt_graph_consume_status
bt_graph_consume(bt_graph
*graph
);
180 typedef enum bt_graph_add_listener_status
{
181 BT_GRAPH_ADD_LISTENER_STATUS_OK
= __BT_FUNC_STATUS_OK
,
182 BT_GRAPH_ADD_LISTENER_STATUS_MEMORY_ERROR
= __BT_FUNC_STATUS_MEMORY_ERROR
,
183 } bt_graph_add_listener_status
;
185 extern bt_graph_add_listener_status
186 bt_graph_add_filter_component_input_port_added_listener(
188 bt_graph_filter_component_input_port_added_listener_func listener
,
189 bt_graph_listener_removed_func listener_removed
, void *data
,
192 extern bt_graph_add_listener_status
193 bt_graph_add_sink_component_input_port_added_listener(
195 bt_graph_sink_component_input_port_added_listener_func listener
,
196 bt_graph_listener_removed_func listener_removed
, void *data
,
199 extern bt_graph_add_listener_status
200 bt_graph_add_source_component_output_port_added_listener(
202 bt_graph_source_component_output_port_added_listener_func listener
,
203 bt_graph_listener_removed_func listener_removed
, void *data
,
206 extern bt_graph_add_listener_status
207 bt_graph_add_filter_component_output_port_added_listener(
209 bt_graph_filter_component_output_port_added_listener_func listener
,
210 bt_graph_listener_removed_func listener_removed
, void *data
,
213 extern bt_graph_add_listener_status
214 bt_graph_add_source_filter_component_ports_connected_listener(
216 bt_graph_source_filter_component_ports_connected_listener_func listener
,
217 bt_graph_listener_removed_func listener_removed
, void *data
,
220 extern bt_graph_add_listener_status
221 bt_graph_add_filter_filter_component_ports_connected_listener(
223 bt_graph_filter_filter_component_ports_connected_listener_func listener
,
224 bt_graph_listener_removed_func listener_removed
, void *data
,
227 extern bt_graph_add_listener_status
228 bt_graph_add_source_sink_component_ports_connected_listener(
230 bt_graph_source_sink_component_ports_connected_listener_func listener
,
231 bt_graph_listener_removed_func listener_removed
, void *data
,
234 extern bt_graph_add_listener_status
235 bt_graph_add_filter_sink_component_ports_connected_listener(
237 bt_graph_filter_sink_component_ports_connected_listener_func listener
,
238 bt_graph_listener_removed_func listener_removed
, void *data
,
241 typedef enum bt_graph_cancel_status
{
242 BT_GRAPH_CANCEL_STATUS_OK
= __BT_FUNC_STATUS_OK
,
243 } bt_graph_cancel_status
;
245 extern bt_graph_cancel_status
bt_graph_cancel(bt_graph
*graph
);
251 #endif /* BABELTRACE2_GRAPH_GRAPH_H */