Commit | Line | Data |
---|---|---|
f60c8b34 JG |
1 | #ifndef BABELTRACE_COMPONENT_GRAPH_H |
2 | #define BABELTRACE_COMPONENT_GRAPH_H | |
c0418dd9 JG |
3 | |
4 | /* | |
f60c8b34 | 5 | * BabelTrace - Babeltrace Graph Interface |
c0418dd9 | 6 | * |
f60c8b34 | 7 | * Copyright 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com> |
c0418dd9 JG |
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 | ||
33b34c43 | 30 | #include <babeltrace/component/component.h> |
c0418dd9 JG |
31 | |
32 | #ifdef __cplusplus | |
33 | extern "C" { | |
34 | #endif | |
35 | ||
f60c8b34 JG |
36 | struct bt_port; |
37 | struct bt_connection; | |
c0418dd9 | 38 | |
f60c8b34 JG |
39 | enum bt_graph_status { |
40 | /** Downstream component does not support multiple inputs. */ | |
41 | BT_GRAPH_STATUS_END = 1, | |
42 | BT_GRAPH_STATUS_OK = 0, | |
43 | /** Downstream component does not support multiple inputs. */ | |
44 | BT_GRAPH_STATUS_MULTIPLE_INPUTS_UNSUPPORTED = -1, | |
45 | /** Component is already part of another graph. */ | |
46 | BT_GRAPH_STATUS_ALREADY_IN_A_GRAPH = -2, | |
47 | /** Invalid arguments. */ | |
48 | BT_GRAPH_STATUS_INVALID = -3, | |
49 | /** No sink in graph. */ | |
50 | BT_GRAPH_STATUS_NO_SINK = -4, | |
51 | /** General error. */ | |
52 | BT_GRAPH_STATUS_ERROR = -5, | |
53 | /** No sink can consume at the moment. */ | |
54 | BT_GRAPH_STATUS_AGAIN = -6, | |
55 | }; | |
c0418dd9 | 56 | |
f60c8b34 | 57 | extern struct bt_graph *bt_graph_create(void); |
c0418dd9 JG |
58 | |
59 | /** | |
f60c8b34 JG |
60 | * Creates a connection between two components using the two ports specified |
61 | * and adds the connection and components (if not already added) to the graph. | |
c0418dd9 | 62 | */ |
f60c8b34 JG |
63 | extern struct bt_connection *bt_graph_connect(struct bt_graph *graph, |
64 | struct bt_port *upstream, | |
65 | struct bt_port *downstream); | |
c0418dd9 JG |
66 | |
67 | /** | |
68 | * Add a component as a "sibling" of the origin component. Sibling share | |
69 | * connections equivalent to each other at the time of connection (same | |
f60c8b34 | 70 | * upstream and downstream ports). |
c0418dd9 | 71 | */ |
f60c8b34 JG |
72 | extern enum bt_graph_status bt_graph_add_component_as_sibling( |
73 | struct bt_graph *graph, struct bt_component *origin, | |
c0418dd9 JG |
74 | struct bt_component *new_component); |
75 | ||
76 | /** | |
f60c8b34 JG |
77 | * Run graph to completion or until a single sink is left and "AGAIN" is received. |
78 | * | |
c0418dd9 | 79 | * Runs "bt_component_sink_consume()" on all sinks in round-robin until they all |
f60c8b34 JG |
80 | * indicate that the end is reached or that an error occured. |
81 | */ | |
82 | extern enum bt_graph_status bt_graph_run(struct bt_graph *graph, | |
83 | enum bt_component_status *component_status); | |
84 | ||
85 | /** | |
86 | * Runs "bt_component_sink_consume()" on the graph's sinks. Each invokation will | |
87 | * invoke "bt_component_sink_consume()" on the next sink, in round-robin, until | |
88 | * they all indicated that the end is reached. | |
c0418dd9 | 89 | */ |
f60c8b34 | 90 | extern enum bt_component_status bt_graph_consume(struct bt_graph *graph); |
c0418dd9 JG |
91 | |
92 | #ifdef __cplusplus | |
93 | } | |
94 | #endif | |
95 | ||
f60c8b34 | 96 | #endif /* BABELTRACE_COMPONENT_GRAPH_H */ |