Commit | Line | Data |
---|---|---|
c42c79ea PP |
1 | #ifndef BABELTRACE_CONVERTER_CFG_H |
2 | #define BABELTRACE_CONVERTER_CFG_H | |
3 | ||
4 | /* | |
5 | * Babeltrace trace converter - configuration | |
6 | * | |
7 | * Copyright 2016 Philippe Proulx <pproulx@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 | #include <stdlib.h> | |
015cee23 | 29 | #include <stdint.h> |
c42c79ea PP |
30 | #include <babeltrace/values.h> |
31 | #include <babeltrace/ref.h> | |
32 | #include <babeltrace/object-internal.h> | |
33 | #include <babeltrace/compiler.h> | |
22e22462 | 34 | #include <babeltrace/component/component-class.h> |
c42c79ea PP |
35 | #include <glib.h> |
36 | ||
37 | struct bt_config_component { | |
38 | struct bt_object base; | |
90de159b | 39 | enum bt_component_class_type type; |
c42c79ea PP |
40 | GString *plugin_name; |
41 | GString *component_name; | |
42 | struct bt_value *params; | |
3b6cfcc5 | 43 | GString *instance_name; |
c42c79ea PP |
44 | }; |
45 | ||
290725f7 PP |
46 | enum bt_config_command { |
47 | BT_CONFIG_COMMAND_CONVERT, | |
48 | BT_CONFIG_COMMAND_LIST_PLUGINS, | |
22e22462 | 49 | BT_CONFIG_COMMAND_HELP, |
a67681c1 | 50 | BT_CONFIG_COMMAND_QUERY, |
290725f7 PP |
51 | }; |
52 | ||
c42c79ea PP |
53 | struct bt_config { |
54 | struct bt_object base; | |
290725f7 PP |
55 | bool debug; |
56 | bool verbose; | |
57 | const char *command_name; | |
58 | enum bt_config_command command; | |
59 | union { | |
60 | /* BT_CONFIG_COMMAND_CONVERT */ | |
61 | struct { | |
62 | struct bt_value *plugin_paths; | |
c42c79ea | 63 | |
290725f7 PP |
64 | /* Array of pointers to struct bt_config_component */ |
65 | GPtrArray *sources; | |
c42c79ea | 66 | |
ebba3338 PP |
67 | /* Array of pointers to struct bt_config_component */ |
68 | GPtrArray *filters; | |
69 | ||
290725f7 PP |
70 | /* Array of pointers to struct bt_config_component */ |
71 | GPtrArray *sinks; | |
c42c79ea | 72 | |
ebba3338 PP |
73 | /* Array of pointers to struct bt_config_connection */ |
74 | GPtrArray *connections; | |
75 | ||
290725f7 PP |
76 | bool force_correlate; |
77 | bool omit_system_plugin_path; | |
78 | bool omit_home_plugin_path; | |
05a67631 | 79 | bool print_ctf_metadata; |
290725f7 PP |
80 | } convert; |
81 | ||
82 | /* BT_CONFIG_COMMAND_LIST_PLUGINS */ | |
83 | struct { | |
84 | struct bt_value *plugin_paths; | |
85 | bool omit_system_plugin_path; | |
86 | bool omit_home_plugin_path; | |
87 | } list_plugins; | |
22e22462 PP |
88 | |
89 | /* BT_CONFIG_COMMAND_HELP */ | |
90 | struct { | |
91 | struct bt_value *plugin_paths; | |
92 | bool omit_system_plugin_path; | |
93 | bool omit_home_plugin_path; | |
90de159b | 94 | struct bt_config_component *cfg_component; |
22e22462 | 95 | } help; |
63ce0e1d | 96 | |
a67681c1 | 97 | /* BT_CONFIG_COMMAND_QUERY */ |
63ce0e1d PP |
98 | struct { |
99 | struct bt_value *plugin_paths; | |
100 | bool omit_system_plugin_path; | |
101 | bool omit_home_plugin_path; | |
a67681c1 | 102 | GString *object; |
63ce0e1d | 103 | struct bt_config_component *cfg_component; |
a67681c1 | 104 | } query; |
290725f7 | 105 | } cmd_data; |
c42c79ea PP |
106 | }; |
107 | ||
108 | static inline | |
109 | struct bt_config_component *bt_config_get_component(GPtrArray *array, | |
110 | size_t index) | |
111 | { | |
112 | return bt_get(g_ptr_array_index(array, index)); | |
113 | } | |
114 | ||
290725f7 PP |
115 | struct bt_config *bt_config_from_args(int argc, const char *argv[], |
116 | int *retcode, bool omit_system_plugin_path, | |
117 | bool omit_home_plugin_path, | |
118 | struct bt_value *initial_plugin_paths); | |
c42c79ea | 119 | |
90de159b PP |
120 | struct bt_config_component *bt_config_component_from_arg( |
121 | enum bt_component_class_type type, const char *arg); | |
ebba3338 | 122 | |
5a3ee633 PP |
123 | enum bt_value_status bt_config_append_plugin_paths( |
124 | struct bt_value *plugin_paths, const char *arg); | |
125 | ||
c42c79ea | 126 | #endif /* BABELTRACE_CONVERTER_CFG_H */ |