Commit | Line | Data |
---|---|---|
9009cc24 PP |
1 | #ifndef CLI_BABELTRACE_CFG_H |
2 | #define CLI_BABELTRACE_CFG_H | |
c42c79ea PP |
3 | |
4 | /* | |
9009cc24 | 5 | * Babeltrace trace converter - CLI tool's configuration |
c42c79ea | 6 | * |
9009cc24 | 7 | * Copyright 2016-2017 Philippe Proulx <pproulx@efficios.com> |
c42c79ea PP |
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 | #include <stdlib.h> | |
015cee23 | 29 | #include <stdint.h> |
c55a9f58 | 30 | #include <stdbool.h> |
c42c79ea | 31 | #include <babeltrace/values.h> |
65300d60 | 32 | #include <babeltrace/object.h> |
c42c79ea | 33 | #include <babeltrace/object-internal.h> |
3d9990ac | 34 | #include <babeltrace/compiler-internal.h> |
b2e0c907 | 35 | #include <babeltrace/graph/component-class.h> |
c42c79ea PP |
36 | #include <glib.h> |
37 | ||
9009cc24 PP |
38 | enum bt_config_command { |
39 | BT_CONFIG_COMMAND_RUN, | |
40 | BT_CONFIG_COMMAND_PRINT_CTF_METADATA, | |
41 | BT_CONFIG_COMMAND_PRINT_LTTNG_LIVE_SESSIONS, | |
42 | BT_CONFIG_COMMAND_LIST_PLUGINS, | |
43 | BT_CONFIG_COMMAND_HELP, | |
44 | BT_CONFIG_COMMAND_QUERY, | |
45 | }; | |
46 | ||
c42c79ea PP |
47 | struct bt_config_component { |
48 | struct bt_object base; | |
90de159b | 49 | enum bt_component_class_type type; |
c42c79ea | 50 | GString *plugin_name; |
db0f160a | 51 | GString *comp_cls_name; |
05e21286 | 52 | struct bt_value *params; |
3b6cfcc5 | 53 | GString *instance_name; |
c42c79ea PP |
54 | }; |
55 | ||
9009cc24 PP |
56 | struct bt_config_connection { |
57 | GString *upstream_comp_name; | |
58 | GString *downstream_comp_name; | |
59 | GString *upstream_port_glob; | |
60 | GString *downstream_port_glob; | |
61 | GString *arg; | |
290725f7 PP |
62 | }; |
63 | ||
c42c79ea PP |
64 | struct bt_config { |
65 | struct bt_object base; | |
290725f7 PP |
66 | bool debug; |
67 | bool verbose; | |
05e21286 | 68 | struct bt_value *plugin_paths; |
db0f160a PP |
69 | bool omit_system_plugin_path; |
70 | bool omit_home_plugin_path; | |
71 | bool command_needs_plugins; | |
290725f7 | 72 | const char *command_name; |
3efa3052 | 73 | char log_level; |
290725f7 PP |
74 | enum bt_config_command command; |
75 | union { | |
db0f160a | 76 | /* BT_CONFIG_COMMAND_RUN */ |
290725f7 | 77 | struct { |
290725f7 PP |
78 | /* Array of pointers to struct bt_config_component */ |
79 | GPtrArray *sources; | |
c42c79ea | 80 | |
ebba3338 PP |
81 | /* Array of pointers to struct bt_config_component */ |
82 | GPtrArray *filters; | |
83 | ||
290725f7 PP |
84 | /* Array of pointers to struct bt_config_component */ |
85 | GPtrArray *sinks; | |
c42c79ea | 86 | |
ebba3338 PP |
87 | /* Array of pointers to struct bt_config_connection */ |
88 | GPtrArray *connections; | |
9009cc24 PP |
89 | |
90 | /* | |
91 | * Number of microseconds to sleep when we need | |
92 | * to retry to run the graph. | |
93 | */ | |
94 | uint64_t retry_duration_us; | |
75a2cb9b JG |
95 | |
96 | /* | |
97 | * Whether or not to trim the source trace to the | |
98 | * intersection of its streams. | |
99 | */ | |
100 | bool stream_intersection_mode; | |
db0f160a | 101 | } run; |
22e22462 PP |
102 | |
103 | /* BT_CONFIG_COMMAND_HELP */ | |
104 | struct { | |
90de159b | 105 | struct bt_config_component *cfg_component; |
22e22462 | 106 | } help; |
63ce0e1d | 107 | |
a67681c1 | 108 | /* BT_CONFIG_COMMAND_QUERY */ |
63ce0e1d | 109 | struct { |
a67681c1 | 110 | GString *object; |
63ce0e1d | 111 | struct bt_config_component *cfg_component; |
a67681c1 | 112 | } query; |
db0f160a PP |
113 | |
114 | /* BT_CONFIG_COMMAND_PRINT_CTF_METADATA */ | |
115 | struct { | |
116 | GString *path; | |
c327e427 | 117 | GString *output_path; |
db0f160a PP |
118 | } print_ctf_metadata; |
119 | ||
120 | /* BT_CONFIG_COMMAND_PRINT_LTTNG_LIVE_SESSIONS */ | |
121 | struct { | |
122 | GString *url; | |
c327e427 | 123 | GString *output_path; |
db0f160a | 124 | } print_lttng_live_sessions; |
290725f7 | 125 | } cmd_data; |
c42c79ea PP |
126 | }; |
127 | ||
128 | static inline | |
129 | struct bt_config_component *bt_config_get_component(GPtrArray *array, | |
130 | size_t index) | |
131 | { | |
398454ed PP |
132 | struct bt_config_component *comp = g_ptr_array_index(array, index); |
133 | ||
134 | bt_object_get_ref(comp); | |
135 | return comp; | |
c42c79ea PP |
136 | } |
137 | ||
05e21286 | 138 | int bt_config_append_plugin_paths(struct bt_value *plugin_paths, |
601b0d3c | 139 | const char *arg); |
5a3ee633 | 140 | |
9009cc24 PP |
141 | void bt_config_connection_destroy(struct bt_config_connection *connection); |
142 | ||
143 | #endif /* CLI_BABELTRACE_CFG_H */ |