babeltrace-cfg: put comp. class type within struct bt_config_component
[babeltrace.git] / converter / babeltrace.c
index 04185214eff798cc8224cc08eb0f399991e6a758..928f623b478d9d07806dfb295a2bb42c08407812 100644 (file)
@@ -44,6 +44,7 @@
 #include <stdio.h>
 #include <glib.h>
 #include "babeltrace-cfg.h"
+#include "babeltrace-cfg-connect.h"
 #include "default-cfg.h"
 
 GPtrArray *loaded_plugins;
@@ -265,13 +266,36 @@ void print_plugin_paths(struct bt_value *plugin_paths)
 static
 void print_cfg_convert(struct bt_config *cfg)
 {
+       size_t i;
+
        printf("  Force correlate: %s\n",
                cfg->cmd_data.convert.force_correlate ? "yes" : "no");
        print_plugin_paths(cfg->cmd_data.convert.plugin_paths);
        printf("  Source component instances:\n");
        print_bt_config_components(cfg->cmd_data.convert.sources);
+
+       if (cfg->cmd_data.convert.filters->len > 0) {
+               printf("  Filter component instances:\n");
+               print_bt_config_components(cfg->cmd_data.convert.filters);
+       }
+
        printf("  Sink component instances:\n");
        print_bt_config_components(cfg->cmd_data.convert.sinks);
+       printf("  Connections:\n");
+
+       for (i = 0; i < cfg->cmd_data.convert.connections->len; i++) {
+               struct bt_config_connection *cfg_connection =
+                       g_ptr_array_index(cfg->cmd_data.convert.connections,
+                               i);
+
+               printf("    %s%s%s -> %s%s%s\n",
+                       cfg_connection->src_instance_name->str,
+                       cfg_connection->src_port_name->len > 0 ? "." : "",
+                       cfg_connection->src_port_name->str,
+                       cfg_connection->dst_instance_name->str,
+                       cfg_connection->dst_port_name->len > 0 ? "." : "",
+                       cfg_connection->dst_port_name->str);
+       }
 }
 
 static
@@ -620,12 +644,12 @@ static int cmd_help(struct bt_config *cfg)
                goto end;
        }
 
-       plugin = find_plugin(cfg->cmd_data.help.plugin_name->str);
+       plugin = find_plugin(cfg->cmd_data.help.cfg_component->plugin_name->str);
        if (!plugin) {
                fprintf(stderr, "%s%sCannot find plugin %s%s%s\n",
                        bt_common_color_bold(), bt_common_color_fg_red(),
                        bt_common_color_fg_blue(),
-                       cfg->cmd_data.help.plugin_name->str,
+                       cfg->cmd_data.help.cfg_component->plugin_name->str,
                        bt_common_color_reset());
                ret = -1;
                goto end;
@@ -638,13 +662,13 @@ static int cmd_help(struct bt_config *cfg)
                        bt_plugin_get_component_class_count(plugin));
 
 
-       if (cfg->cmd_data.help.comp_cls_type !=
+       if (cfg->cmd_data.help.cfg_component->type !=
                        BT_COMPONENT_CLASS_TYPE_UNKNOWN) {
                struct bt_component_class *needed_comp_cls =
                        find_component_class(
-                               cfg->cmd_data.help.plugin_name->str,
-                               cfg->cmd_data.help.component_name->str,
-                               cfg->cmd_data.help.comp_cls_type);
+                               cfg->cmd_data.help.cfg_component->plugin_name->str,
+                               cfg->cmd_data.help.cfg_component->component_name->str,
+                               cfg->cmd_data.help.cfg_component->type);
 
                if (!needed_comp_cls) {
                        fprintf(stderr, "\n%s%sCannot find component class %s",
@@ -652,9 +676,9 @@ static int cmd_help(struct bt_config *cfg)
                                bt_common_color_fg_red(),
                                bt_common_color_reset());
                        print_plugin_comp_cls_opt(stderr,
-                               cfg->cmd_data.help.plugin_name->str,
-                               cfg->cmd_data.help.component_name->str,
-                               cfg->cmd_data.help.comp_cls_type);
+                               cfg->cmd_data.help.cfg_component->plugin_name->str,
+                               cfg->cmd_data.help.cfg_component->component_name->str,
+                               cfg->cmd_data.help.cfg_component->type);
                        fprintf(stderr, "\n");
                        ret = -1;
                        goto end;
@@ -677,12 +701,12 @@ static int cmd_help(struct bt_config *cfg)
 
                assert(comp_cls);
 
-               if (cfg->cmd_data.help.comp_cls_type !=
+               if (cfg->cmd_data.help.cfg_component->type !=
                                BT_COMPONENT_CLASS_TYPE_UNKNOWN) {
-                       if (strcmp(cfg->cmd_data.help.component_name->str,
+                       if (strcmp(cfg->cmd_data.help.cfg_component->component_name->str,
                                        comp_class_name) != 0 &&
                                        type ==
-                                       cfg->cmd_data.help.comp_cls_type) {
+                                       cfg->cmd_data.help.cfg_component->type) {
                                bt_put(comp_cls);
                                continue;
                        }
@@ -690,7 +714,7 @@ static int cmd_help(struct bt_config *cfg)
 
                printf("\n");
                print_plugin_comp_cls_opt(stdout,
-                       cfg->cmd_data.help.plugin_name->str,
+                       cfg->cmd_data.help.cfg_component->plugin_name->str,
                        comp_class_name,
                        type);
                printf("\n");
@@ -810,12 +834,14 @@ static int cmd_convert(struct bt_config *cfg)
        /* TODO handle more than 1 source and 1 sink. */
        if (cfg->cmd_data.convert.sources->len != 1 ||
                        cfg->cmd_data.convert.sinks->len != 1) {
+               fprintf(stderr, "Only one source and one sink component class are supported. Aborting...\n");
                ret = -1;
                goto end;
        }
 
        ret = load_all_plugins(cfg->cmd_data.convert.plugin_paths);
        if (ret) {
+               fprintf(stderr, "Could not load plugins from configured plugin paths. Aborting...\n");
                goto end;
        }
 
This page took 0.029191 seconds and 4 git commands to generate.