4a1fe1a0e25f961acfd166e8bc8c01c779180f77
[babeltrace.git] / include / babeltrace / graph / private-graph.h
1 #ifndef BABELTRACE_GRAPH_PRIVATE_GRAPH_H
2 #define BABELTRACE_GRAPH_PRIVATE_GRAPH_H
3
4 /*
5 * Copyright 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 *
7 * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
8 *
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:
15 *
16 * The above copyright notice and this permission notice shall be included in
17 * all copies or substantial portions of the Software.
18 *
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
25 * SOFTWARE.
26 */
27
28 /* For bt_bool */
29 #include <babeltrace/types.h>
30
31 /* For enum bt_graph_status */
32 #include <babeltrace/graph/graph.h>
33
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37
38 struct bt_graph;
39 struct bt_private_graph;
40 struct bt_port;
41 struct bt_connection;
42 struct bt_component;
43 struct bt_component_class;
44 struct bt_value;
45
46 typedef void (*bt_private_graph_port_added_listener)(struct bt_port *port,
47 void *data);
48
49 typedef void (*bt_private_graph_port_removed_listener)(
50 struct bt_component *component,
51 struct bt_port *port, void *data);
52
53 typedef void (*bt_private_graph_ports_connected_listener)(
54 struct bt_port *upstream_port,
55 struct bt_port *downstream_port, void *data);
56
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,
61 void *data);
62
63 typedef void (* bt_private_graph_listener_removed)(void *data);
64
65 extern struct bt_graph *bt_graph_borrow_from_private(
66 struct bt_private_graph *priv_graph);
67
68 extern struct bt_private_graph *bt_private_graph_create(void);
69
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);
75
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);
82
83 /**
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.
86 */
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);
91
92 /**
93 * Run graph to completion or until a single sink is left and "AGAIN" is received.
94 *
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.
97 */
98 extern enum bt_graph_status bt_private_graph_run(
99 struct bt_private_graph *graph);
100
101 /**
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.
105 */
106 extern enum bt_graph_status bt_private_graph_consume(
107 struct bt_private_graph *graph);
108
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);
113
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);
118
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);
123
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);
128
129 extern enum bt_graph_status bt_private_graph_cancel(
130 struct bt_private_graph *graph);
131
132 #ifdef __cplusplus
133 }
134 #endif
135
136 #endif /* BABELTRACE_GRAPH_PRIVATE_GRAPH_H */
This page took 0.031771 seconds and 3 git commands to generate.