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