1 #ifndef BABELTRACE_GRAPH_PRIVATE_GRAPH_H
2 #define BABELTRACE_GRAPH_PRIVATE_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.h>
39 struct bt_private_graph
;
43 struct bt_component_class
;
46 typedef void (*bt_private_graph_port_added_listener
)(struct bt_port
*port
,
49 typedef void (*bt_private_graph_port_removed_listener
)(
50 struct bt_component
*component
,
51 struct bt_port
*port
, void *data
);
53 typedef void (*bt_private_graph_ports_connected_listener
)(
54 struct bt_port
*upstream_port
,
55 struct bt_port
*downstream_port
, void *data
);
57 typedef void (*bt_private_graph_ports_disconnected_listener
)(
58 struct bt_component
*upstream_component
,
59 struct bt_component
*downstream_component
,
60 struct bt_port
*upstream_port
, struct bt_port
*downstream_port
,
63 typedef void (* bt_private_graph_listener_removed
)(void *data
);
65 extern struct bt_graph
*bt_graph_borrow_from_private(
66 struct bt_private_graph
*priv_graph
);
68 extern struct bt_private_graph
*bt_private_graph_create(void);
70 extern enum bt_graph_status
bt_private_graph_add_component(
71 struct bt_private_graph
*graph
,
72 struct bt_component_class
*component_class
,
73 const char *name
, struct bt_value
*params
,
74 struct bt_component
**component
);
76 extern enum bt_graph_status
77 bt_private_graph_add_component_with_init_method_data(
78 struct bt_private_graph
*graph
,
79 struct bt_component_class
*component_class
,
80 const char *name
, struct bt_value
*params
,
81 void *init_method_data
, struct bt_component
**component
);
84 * Creates a connection between two components using the two ports specified
85 * and adds the connection and components (if not already added) to the graph.
87 extern enum bt_graph_status
bt_private_graph_connect_ports(
88 struct bt_private_graph
*graph
,
89 struct bt_port
*upstream
, struct bt_port
*downstream
,
90 struct bt_connection
**connection
);
93 * Run graph to completion or until a single sink is left and "AGAIN" is received.
95 * Runs "bt_component_sink_consume()" on all sinks in round-robin until they all
96 * indicate that the end is reached or that an error occured.
98 extern enum bt_graph_status
bt_private_graph_run(
99 struct bt_private_graph
*graph
);
102 * Runs "bt_component_sink_consume()" on the graph's sinks. Each invokation will
103 * invoke "bt_component_sink_consume()" on the next sink, in round-robin, until
104 * they all indicated that the end is reached.
106 extern enum bt_graph_status
bt_private_graph_consume(
107 struct bt_private_graph
*graph
);
109 extern int bt_private_graph_add_port_added_listener(
110 struct bt_private_graph
*graph
,
111 bt_private_graph_port_added_listener listener
,
112 bt_private_graph_listener_removed listener_removed
, void *data
);
114 extern int bt_private_graph_add_port_removed_listener(
115 struct bt_private_graph
*graph
,
116 bt_private_graph_port_removed_listener listener
,
117 bt_private_graph_listener_removed listener_removed
, void *data
);
119 extern int bt_private_graph_add_ports_connected_listener(
120 struct bt_private_graph
*graph
,
121 bt_private_graph_ports_connected_listener listener
,
122 bt_private_graph_listener_removed listener_removed
, void *data
);
124 extern int bt_private_graph_add_ports_disconnected_listener(
125 struct bt_private_graph
*graph
,
126 bt_private_graph_ports_disconnected_listener listener
,
127 bt_private_graph_listener_removed listener_removed
, void *data
);
129 extern enum bt_graph_status
bt_private_graph_cancel(
130 struct bt_private_graph
*graph
);
136 #endif /* BABELTRACE_GRAPH_PRIVATE_GRAPH_H */