fc566d79ab2802e11b9b39f18395ec5ad4ac8f2b
[babeltrace.git] / src / cli / babeltrace2-cfg.h
1 #ifndef CLI_BABELTRACE_CFG_H
2 #define CLI_BABELTRACE_CFG_H
3
4 /*
5 * Babeltrace trace converter - CLI tool's configuration
6 *
7 * Copyright 2016-2017 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>
29 #include <stdint.h>
30 #include <stdbool.h>
31 #include <babeltrace2/value.h>
32 #include "lib/object.h"
33 #include "compat/compiler.h"
34 #include <babeltrace2/graph/component-class.h>
35 #include <glib.h>
36
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
46 struct bt_config_component {
47 bt_object base;
48 bt_component_class_type type;
49 GString *plugin_name;
50 GString *comp_cls_name;
51 bt_value *params;
52 GString *instance_name;
53 int log_level;
54 };
55
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;
62 };
63
64 struct bt_config {
65 bt_object base;
66 bt_value *plugin_paths;
67 bool omit_system_plugin_path;
68 bool omit_home_plugin_path;
69 bool command_needs_plugins;
70 const char *command_name;
71 int log_level;
72 enum bt_config_command command;
73 union {
74 /* BT_CONFIG_COMMAND_RUN */
75 struct {
76 /* Array of pointers to struct bt_config_component */
77 GPtrArray *sources;
78
79 /* Array of pointers to struct bt_config_component */
80 GPtrArray *filters;
81
82 /* Array of pointers to struct bt_config_component */
83 GPtrArray *sinks;
84
85 /* Array of pointers to struct bt_config_connection */
86 GPtrArray *connections;
87
88 /*
89 * Number of microseconds to sleep when we need
90 * to retry to run the graph.
91 */
92 uint64_t retry_duration_us;
93
94 /*
95 * Whether or not to trim the source trace to the
96 * intersection of its streams.
97 */
98 bool stream_intersection_mode;
99 } run;
100
101 /* BT_CONFIG_COMMAND_HELP */
102 struct {
103 struct bt_config_component *cfg_component;
104 } help;
105
106 /* BT_CONFIG_COMMAND_QUERY */
107 struct {
108 GString *object;
109 struct bt_config_component *cfg_component;
110 } query;
111
112 /* BT_CONFIG_COMMAND_PRINT_CTF_METADATA */
113 struct {
114 GString *path;
115 GString *output_path;
116 } print_ctf_metadata;
117
118 /* BT_CONFIG_COMMAND_PRINT_LTTNG_LIVE_SESSIONS */
119 struct {
120 GString *url;
121 GString *output_path;
122 } print_lttng_live_sessions;
123 } cmd_data;
124 };
125
126 static inline
127 struct bt_config_component *bt_config_get_component(GPtrArray *array,
128 size_t index)
129 {
130 struct bt_config_component *comp = g_ptr_array_index(array, index);
131
132 bt_object_get_ref(comp);
133 return comp;
134 }
135
136 int bt_config_append_plugin_paths(bt_value *plugin_paths,
137 const char *arg);
138
139 void bt_config_connection_destroy(struct bt_config_connection *connection);
140
141 #endif /* CLI_BABELTRACE_CFG_H */
This page took 0.034686 seconds and 3 git commands to generate.