plugin-so: use list of components instead of glib hash table
[babeltrace.git] / cli / babeltrace-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 <babeltrace/values.h>
32 #include <babeltrace/ref.h>
33 #include <babeltrace/object-internal.h>
34 #include <babeltrace/compiler-internal.h>
35 #include <babeltrace/graph/component-class.h>
36 #include <glib.h>
37
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
47 struct bt_config_component {
48 struct bt_object base;
49 enum bt_component_class_type type;
50 GString *plugin_name;
51 GString *comp_cls_name;
52 struct bt_value *params;
53 GString *instance_name;
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 struct bt_object base;
66 bool debug;
67 bool verbose;
68 struct bt_value *plugin_paths;
69 bool omit_system_plugin_path;
70 bool omit_home_plugin_path;
71 bool command_needs_plugins;
72 const char *command_name;
73 enum bt_config_command command;
74 union {
75 /* BT_CONFIG_COMMAND_RUN */
76 struct {
77 /* Array of pointers to struct bt_config_component */
78 GPtrArray *sources;
79
80 /* Array of pointers to struct bt_config_component */
81 GPtrArray *filters;
82
83 /* Array of pointers to struct bt_config_component */
84 GPtrArray *sinks;
85
86 /* Array of pointers to struct bt_config_connection */
87 GPtrArray *connections;
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;
94 } run;
95
96 /* BT_CONFIG_COMMAND_HELP */
97 struct {
98 struct bt_config_component *cfg_component;
99 } help;
100
101 /* BT_CONFIG_COMMAND_QUERY */
102 struct {
103 GString *object;
104 struct bt_config_component *cfg_component;
105 } query;
106
107 /* BT_CONFIG_COMMAND_PRINT_CTF_METADATA */
108 struct {
109 GString *path;
110 } print_ctf_metadata;
111
112 /* BT_CONFIG_COMMAND_PRINT_LTTNG_LIVE_SESSIONS */
113 struct {
114 GString *url;
115 } print_lttng_live_sessions;
116 } cmd_data;
117 };
118
119 static inline
120 struct bt_config_component *bt_config_get_component(GPtrArray *array,
121 size_t index)
122 {
123 return bt_get(g_ptr_array_index(array, index));
124 }
125
126 enum bt_value_status bt_config_append_plugin_paths(
127 struct bt_value *plugin_paths, const char *arg);
128
129 void bt_config_connection_destroy(struct bt_config_connection *connection);
130
131 #endif /* CLI_BABELTRACE_CFG_H */
This page took 0.032903 seconds and 4 git commands to generate.