| 1 | #ifndef BABELTRACE2_GRAPH_GRAPH_H |
| 2 | #define BABELTRACE2_GRAPH_GRAPH_H |
| 3 | |
| 4 | /* |
| 5 | * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com> |
| 6 | * Copyright 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com> |
| 7 | * |
| 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: |
| 14 | * |
| 15 | * The above copyright notice and this permission notice shall be included in |
| 16 | * all copies or substantial portions of the Software. |
| 17 | * |
| 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 |
| 24 | * SOFTWARE. |
| 25 | */ |
| 26 | |
| 27 | #ifndef __BT_IN_BABELTRACE_H |
| 28 | # error "Please include <babeltrace2/babeltrace.h> instead." |
| 29 | #endif |
| 30 | |
| 31 | #include <babeltrace2/types.h> |
| 32 | #include <babeltrace2/logging.h> |
| 33 | |
| 34 | #ifdef __cplusplus |
| 35 | extern "C" { |
| 36 | #endif |
| 37 | |
| 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; |
| 43 | |
| 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); |
| 48 | |
| 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); |
| 53 | |
| 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); |
| 58 | |
| 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); |
| 63 | |
| 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); |
| 70 | |
| 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); |
| 77 | |
| 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, |
| 84 | void *data); |
| 85 | |
| 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); |
| 92 | |
| 93 | typedef void (* bt_graph_listener_removed_func)(void *data); |
| 94 | |
| 95 | extern bt_graph *bt_graph_create(void); |
| 96 | |
| 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; |
| 102 | |
| 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); |
| 108 | |
| 109 | extern bt_graph_add_component_status |
| 110 | bt_graph_add_source_component_with_init_method_data( |
| 111 | bt_graph *graph, |
| 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); |
| 116 | |
| 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); |
| 123 | |
| 124 | extern bt_graph_add_component_status |
| 125 | bt_graph_add_filter_component_with_init_method_data( |
| 126 | bt_graph *graph, |
| 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); |
| 131 | |
| 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); |
| 138 | |
| 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); |
| 145 | |
| 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; |
| 152 | |
| 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); |
| 157 | |
| 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; |
| 166 | |
| 167 | extern bt_graph_run_status bt_graph_run(bt_graph *graph); |
| 168 | |
| 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; |
| 177 | |
| 178 | extern bt_graph_consume_status bt_graph_consume(bt_graph *graph); |
| 179 | |
| 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; |
| 184 | |
| 185 | extern bt_graph_add_listener_status |
| 186 | bt_graph_add_filter_component_input_port_added_listener( |
| 187 | bt_graph *graph, |
| 188 | bt_graph_filter_component_input_port_added_listener_func listener, |
| 189 | bt_graph_listener_removed_func listener_removed, void *data, |
| 190 | int *listener_id); |
| 191 | |
| 192 | extern bt_graph_add_listener_status |
| 193 | bt_graph_add_sink_component_input_port_added_listener( |
| 194 | bt_graph *graph, |
| 195 | bt_graph_sink_component_input_port_added_listener_func listener, |
| 196 | bt_graph_listener_removed_func listener_removed, void *data, |
| 197 | int *listener_id); |
| 198 | |
| 199 | extern bt_graph_add_listener_status |
| 200 | bt_graph_add_source_component_output_port_added_listener( |
| 201 | bt_graph *graph, |
| 202 | bt_graph_source_component_output_port_added_listener_func listener, |
| 203 | bt_graph_listener_removed_func listener_removed, void *data, |
| 204 | int *listener_id); |
| 205 | |
| 206 | extern bt_graph_add_listener_status |
| 207 | bt_graph_add_filter_component_output_port_added_listener( |
| 208 | bt_graph *graph, |
| 209 | bt_graph_filter_component_output_port_added_listener_func listener, |
| 210 | bt_graph_listener_removed_func listener_removed, void *data, |
| 211 | int *listener_id); |
| 212 | |
| 213 | extern bt_graph_add_listener_status |
| 214 | bt_graph_add_source_filter_component_ports_connected_listener( |
| 215 | bt_graph *graph, |
| 216 | bt_graph_source_filter_component_ports_connected_listener_func listener, |
| 217 | bt_graph_listener_removed_func listener_removed, void *data, |
| 218 | int *listener_id); |
| 219 | |
| 220 | extern bt_graph_add_listener_status |
| 221 | bt_graph_add_filter_filter_component_ports_connected_listener( |
| 222 | bt_graph *graph, |
| 223 | bt_graph_filter_filter_component_ports_connected_listener_func listener, |
| 224 | bt_graph_listener_removed_func listener_removed, void *data, |
| 225 | int *listener_id); |
| 226 | |
| 227 | extern bt_graph_add_listener_status |
| 228 | bt_graph_add_source_sink_component_ports_connected_listener( |
| 229 | bt_graph *graph, |
| 230 | bt_graph_source_sink_component_ports_connected_listener_func listener, |
| 231 | bt_graph_listener_removed_func listener_removed, void *data, |
| 232 | int *listener_id); |
| 233 | |
| 234 | extern bt_graph_add_listener_status |
| 235 | bt_graph_add_filter_sink_component_ports_connected_listener( |
| 236 | bt_graph *graph, |
| 237 | bt_graph_filter_sink_component_ports_connected_listener_func listener, |
| 238 | bt_graph_listener_removed_func listener_removed, void *data, |
| 239 | int *listener_id); |
| 240 | |
| 241 | typedef enum bt_graph_cancel_status { |
| 242 | BT_GRAPH_CANCEL_STATUS_OK = __BT_FUNC_STATUS_OK, |
| 243 | } bt_graph_cancel_status; |
| 244 | |
| 245 | extern bt_graph_cancel_status bt_graph_cancel(bt_graph *graph); |
| 246 | |
| 247 | #ifdef __cplusplus |
| 248 | } |
| 249 | #endif |
| 250 | |
| 251 | #endif /* BABELTRACE2_GRAPH_GRAPH_H */ |