Update notification iterator's "init" function signature
[babeltrace.git] / include / babeltrace / component / graph.h
1 #ifndef BABELTRACE_COMPONENT_GRAPH_H
2 #define BABELTRACE_COMPONENT_GRAPH_H
3
4 /*
5 * BabelTrace - Babeltrace Graph Interface
6 *
7 * Copyright 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
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
30 #include <babeltrace/component/component.h>
31
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35
36 struct bt_port;
37 struct bt_connection;
38
39 enum bt_graph_status {
40 /** No sink can consume at the moment. */
41 BT_GRAPH_STATUS_AGAIN = 2,
42 /** Downstream component does not support multiple inputs. */
43 BT_GRAPH_STATUS_END = 1,
44 BT_GRAPH_STATUS_OK = 0,
45 /** Downstream component does not support multiple inputs. */
46 BT_GRAPH_STATUS_MULTIPLE_INPUTS_UNSUPPORTED = -1,
47 /** Component is already part of another graph. */
48 BT_GRAPH_STATUS_ALREADY_IN_A_GRAPH = -2,
49 /** Invalid arguments. */
50 BT_GRAPH_STATUS_INVALID = -3,
51 /** No sink in graph. */
52 BT_GRAPH_STATUS_NO_SINK = -4,
53 /** General error. */
54 BT_GRAPH_STATUS_ERROR = -5,
55 };
56
57 typedef void (*bt_graph_port_added_listener)(struct bt_port *port,
58 void *data);
59 typedef void (*bt_graph_port_removed_listener)(struct bt_component *component,
60 struct bt_port *port, void *data);
61 typedef void (*bt_graph_port_connected_listener)(struct bt_port *port,
62 void *data);
63 typedef void (*bt_graph_port_disconnected_listener)(
64 struct bt_component *component, struct bt_port *port,
65 void *data);
66
67 extern struct bt_graph *bt_graph_create(void);
68
69 /**
70 * Creates a connection between two components using the two ports specified
71 * and adds the connection and components (if not already added) to the graph.
72 */
73 extern struct bt_connection *bt_graph_connect(struct bt_graph *graph,
74 struct bt_port *upstream,
75 struct bt_port *downstream);
76
77 /**
78 * Add a component as a "sibling" of the origin component. Sibling share
79 * connections equivalent to each other at the time of connection (same
80 * upstream and downstream ports).
81 */
82 extern enum bt_graph_status bt_graph_add_component_as_sibling(
83 struct bt_graph *graph, struct bt_component *origin,
84 struct bt_component *new_component);
85
86 /**
87 * Run graph to completion or until a single sink is left and "AGAIN" is received.
88 *
89 * Runs "bt_component_sink_consume()" on all sinks in round-robin until they all
90 * indicate that the end is reached or that an error occured.
91 */
92 extern enum bt_graph_status bt_graph_run(struct bt_graph *graph);
93
94 /**
95 * Runs "bt_component_sink_consume()" on the graph's sinks. Each invokation will
96 * invoke "bt_component_sink_consume()" on the next sink, in round-robin, until
97 * they all indicated that the end is reached.
98 */
99 extern enum bt_graph_status bt_graph_consume(struct bt_graph *graph);
100
101 extern enum bt_graph_status bt_graph_add_port_added_listener(
102 struct bt_graph *graph,
103 bt_graph_port_added_listener listener, void *data);
104
105 extern enum bt_graph_status bt_graph_add_port_removed_listener(
106 struct bt_graph *graph,
107 bt_graph_port_removed_listener listener, void *data);
108
109 extern enum bt_graph_status bt_graph_add_port_connected_listener(
110 struct bt_graph *graph,
111 bt_graph_port_connected_listener listener, void *data);
112
113 extern enum bt_graph_status bt_graph_add_port_disconnected_listener(
114 struct bt_graph *graph,
115 bt_graph_port_disconnected_listener listener, void *data);
116
117 #ifdef __cplusplus
118 }
119 #endif
120
121 #endif /* BABELTRACE_COMPONENT_GRAPH_H */
This page took 0.031603 seconds and 4 git commands to generate.