Commit | Line | Data |
---|---|---|
c42c79ea | 1 | /* |
0235b0db | 2 | * SPDX-License-Identifier: MIT |
c42c79ea | 3 | * |
9009cc24 | 4 | * Copyright 2016-2017 Philippe Proulx <pproulx@efficios.com> |
c42c79ea | 5 | * |
0235b0db | 6 | * Babeltrace trace converter - CLI tool's configuration |
c42c79ea PP |
7 | */ |
8 | ||
0235b0db MJ |
9 | #ifndef CLI_BABELTRACE_CFG_H |
10 | #define CLI_BABELTRACE_CFG_H | |
11 | ||
c42c79ea | 12 | #include <stdlib.h> |
015cee23 | 13 | #include <stdint.h> |
c55a9f58 | 14 | #include <stdbool.h> |
3fadfbc0 | 15 | #include <babeltrace2/value.h> |
578e048b MJ |
16 | #include "lib/object.h" |
17 | #include "compat/compiler.h" | |
3fadfbc0 | 18 | #include <babeltrace2/graph/component-class.h> |
c42c79ea PP |
19 | #include <glib.h> |
20 | ||
9009cc24 PP |
21 | enum bt_config_command { |
22 | BT_CONFIG_COMMAND_RUN, | |
23 | BT_CONFIG_COMMAND_PRINT_CTF_METADATA, | |
24 | BT_CONFIG_COMMAND_PRINT_LTTNG_LIVE_SESSIONS, | |
25 | BT_CONFIG_COMMAND_LIST_PLUGINS, | |
26 | BT_CONFIG_COMMAND_HELP, | |
27 | BT_CONFIG_COMMAND_QUERY, | |
28 | }; | |
29 | ||
c42c79ea | 30 | struct bt_config_component { |
b19ff26f | 31 | bt_object base; |
4cdfc5e8 | 32 | bt_component_class_type type; |
c42c79ea | 33 | GString *plugin_name; |
db0f160a | 34 | GString *comp_cls_name; |
b19ff26f | 35 | bt_value *params; |
3b6cfcc5 | 36 | GString *instance_name; |
29da2ffc | 37 | int log_level; |
c42c79ea PP |
38 | }; |
39 | ||
9009cc24 PP |
40 | struct bt_config_connection { |
41 | GString *upstream_comp_name; | |
42 | GString *downstream_comp_name; | |
43 | GString *upstream_port_glob; | |
44 | GString *downstream_port_glob; | |
45 | GString *arg; | |
290725f7 PP |
46 | }; |
47 | ||
c42c79ea | 48 | struct bt_config { |
b19ff26f | 49 | bt_object base; |
b19ff26f | 50 | bt_value *plugin_paths; |
db0f160a PP |
51 | bool omit_system_plugin_path; |
52 | bool omit_home_plugin_path; | |
53 | bool command_needs_plugins; | |
290725f7 | 54 | const char *command_name; |
83094759 | 55 | int log_level; |
290725f7 PP |
56 | enum bt_config_command command; |
57 | union { | |
db0f160a | 58 | /* BT_CONFIG_COMMAND_RUN */ |
290725f7 | 59 | struct { |
290725f7 PP |
60 | /* Array of pointers to struct bt_config_component */ |
61 | GPtrArray *sources; | |
c42c79ea | 62 | |
ebba3338 PP |
63 | /* Array of pointers to struct bt_config_component */ |
64 | GPtrArray *filters; | |
65 | ||
290725f7 PP |
66 | /* Array of pointers to struct bt_config_component */ |
67 | GPtrArray *sinks; | |
c42c79ea | 68 | |
ebba3338 PP |
69 | /* Array of pointers to struct bt_config_connection */ |
70 | GPtrArray *connections; | |
9009cc24 PP |
71 | |
72 | /* | |
73 | * Number of microseconds to sleep when we need | |
74 | * to retry to run the graph. | |
75 | */ | |
76 | uint64_t retry_duration_us; | |
75a2cb9b JG |
77 | |
78 | /* | |
79 | * Whether or not to trim the source trace to the | |
80 | * intersection of its streams. | |
81 | */ | |
82 | bool stream_intersection_mode; | |
db0f160a | 83 | } run; |
22e22462 PP |
84 | |
85 | /* BT_CONFIG_COMMAND_HELP */ | |
86 | struct { | |
90de159b | 87 | struct bt_config_component *cfg_component; |
22e22462 | 88 | } help; |
63ce0e1d | 89 | |
a67681c1 | 90 | /* BT_CONFIG_COMMAND_QUERY */ |
63ce0e1d | 91 | struct { |
a67681c1 | 92 | GString *object; |
63ce0e1d | 93 | struct bt_config_component *cfg_component; |
a67681c1 | 94 | } query; |
db0f160a PP |
95 | |
96 | /* BT_CONFIG_COMMAND_PRINT_CTF_METADATA */ | |
97 | struct { | |
98 | GString *path; | |
c327e427 | 99 | GString *output_path; |
db0f160a PP |
100 | } print_ctf_metadata; |
101 | ||
102 | /* BT_CONFIG_COMMAND_PRINT_LTTNG_LIVE_SESSIONS */ | |
103 | struct { | |
104 | GString *url; | |
c327e427 | 105 | GString *output_path; |
db0f160a | 106 | } print_lttng_live_sessions; |
290725f7 | 107 | } cmd_data; |
c42c79ea PP |
108 | }; |
109 | ||
110 | static inline | |
111 | struct bt_config_component *bt_config_get_component(GPtrArray *array, | |
112 | size_t index) | |
113 | { | |
398454ed PP |
114 | struct bt_config_component *comp = g_ptr_array_index(array, index); |
115 | ||
116 | bt_object_get_ref(comp); | |
117 | return comp; | |
c42c79ea PP |
118 | } |
119 | ||
b19ff26f | 120 | int bt_config_append_plugin_paths(bt_value *plugin_paths, |
601b0d3c | 121 | const char *arg); |
5a3ee633 | 122 | |
9009cc24 PP |
123 | void bt_config_connection_destroy(struct bt_config_connection *connection); |
124 | ||
125 | #endif /* CLI_BABELTRACE_CFG_H */ |