Change-Id: I9e2f4d2ac47e4f061e5dda1a3813d1a092ffe433
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8296
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12332
Tested-by: jenkins <jenkins@lttng.org>
* Babeltrace CTF file system Reader Component
*/
* Babeltrace CTF file system Reader Component
*/
#include <babeltrace2/babeltrace.h>
#include "common/assert.h"
#include "common/common.h"
#include "common/uuid.h"
#include <babeltrace2/babeltrace.h>
#include "common/assert.h"
#include "common/common.h"
#include "common/uuid.h"
+#include "cpp-common/bt2c/glib-up.hpp"
#include "cpp-common/bt2s/make-unique.hpp"
#include "plugins/common/param-validation/param-validation.h"
#include "cpp-common/bt2s/make-unique.hpp"
#include "plugins/common/param-validation/param-validation.h"
bt_self_component_get_data(bt_self_component_source_as_self_component(component)))};
}
bt_self_component_get_data(bt_self_component_source_as_self_component(component)))};
}
-bt2c::GCharUP ctf_fs_make_port_name(struct ctf_fs_ds_file_group *ds_file_group)
+std::string ctf_fs_make_port_name(ctf_fs_ds_file_group *ds_file_group)
- GString *name = g_string_new(NULL);
+ std::stringstream name;
/*
* The unique port name is generated by concatenating unique identifiers
/*
* The unique port name is generated by concatenating unique identifiers
char uuid_str[BT_UUID_STR_LEN + 1];
bt_uuid_to_str(ds_file_group->ctf_fs_trace->metadata->tc->uuid, uuid_str);
char uuid_str[BT_UUID_STR_LEN + 1];
bt_uuid_to_str(ds_file_group->ctf_fs_trace->metadata->tc->uuid, uuid_str);
- g_string_assign(name, uuid_str);
- g_string_assign(name, ds_file_group->ctf_fs_trace->path.c_str());
+ name << ds_file_group->ctf_fs_trace->path;
* otherwise, as there will only be a single stream class.
*/
if (ds_file_group->sc->id != UINT64_C(-1)) {
* otherwise, as there will only be a single stream class.
*/
if (ds_file_group->sc->id != UINT64_C(-1)) {
- g_string_append_printf(name, " | %" PRIu64, ds_file_group->sc->id);
+ name << " | " << ds_file_group->sc->id;
}
/* For the stream, use the id if present, else, use the path. */
if (ds_file_group->stream_id != UINT64_C(-1)) {
}
/* For the stream, use the id if present, else, use the path. */
if (ds_file_group->stream_id != UINT64_C(-1)) {
- g_string_append_printf(name, " | %" PRIu64, ds_file_group->stream_id);
+ name << " | " << ds_file_group->stream_id;
} else {
BT_ASSERT(ds_file_group->ds_file_infos.size() == 1);
const auto& ds_file_info = *ds_file_group->ds_file_infos[0];
} else {
BT_ASSERT(ds_file_group->ds_file_infos.size() == 1);
const auto& ds_file_info = *ds_file_group->ds_file_infos[0];
- g_string_append_printf(name, " | %s", ds_file_info.path.c_str());
+ name << " | " << ds_file_info.path;
- return bt2c::GCharUP {g_string_free(name, FALSE)};
}
static int create_one_port_for_trace(struct ctf_fs_component *ctf_fs,
}
static int create_one_port_for_trace(struct ctf_fs_component *ctf_fs,
int ret = 0;
ctf_fs_port_data::UP port_data;
int ret = 0;
ctf_fs_port_data::UP port_data;
- bt2c::GCharUP port_name = ctf_fs_make_port_name(ds_file_group);
- if (!port_name) {
- goto error;
- }
-
- BT_CPPLOGI_SPEC(ctf_fs->logger, "Creating one port named `{}`", port_name.get());
+ const auto port_name = ctf_fs_make_port_name(ds_file_group);
+ BT_CPPLOGI_SPEC(ctf_fs->logger, "Creating one port named `{}`", port_name);
/* Create output port for this file */
port_data = bt2s::make_unique<ctf_fs_port_data>();
port_data->ctf_fs = ctf_fs;
port_data->ds_file_group = ds_file_group;
/* Create output port for this file */
port_data = bt2s::make_unique<ctf_fs_port_data>();
port_data->ctf_fs = ctf_fs;
port_data->ds_file_group = ds_file_group;
- ret = bt_self_component_source_add_output_port(self_comp_src, port_name.get(), port_data.get(),
- NULL);
+ ret = bt_self_component_source_add_output_port(self_comp_src, port_name.c_str(),
+ port_data.get(), NULL);
#include <babeltrace2/babeltrace.h>
#include <babeltrace2/babeltrace.h>
-#include "cpp-common/bt2c/glib-up.hpp"
#include "cpp-common/bt2c/logging.hpp"
#include "data-stream-file.hpp"
#include "cpp-common/bt2c/logging.hpp"
#include "data-stream-file.hpp"
* Generate the port name to be used for a given data stream file group.
*/
* Generate the port name to be used for a given data stream file group.
*/
-bt2c::GCharUP ctf_fs_make_port_name(struct ctf_fs_ds_file_group *ds_file_group);
+std::string ctf_fs_make_port_name(ctf_fs_ds_file_group *ds_file_group);
#endif /* BABELTRACE_PLUGIN_CTF_FS_H */
#endif /* BABELTRACE_PLUGIN_CTF_FS_H */
}
static void populate_stream_info(struct ctf_fs_ds_file_group *group, const bt2::MapValue groupInfo,
}
static void populate_stream_info(struct ctf_fs_ds_file_group *group, const bt2::MapValue groupInfo,
- struct range *stream_range, const bt2c::Logger& logger)
+ struct range *stream_range)
{
/*
* Since each `struct ctf_fs_ds_file_group` has a sorted array of
{
/*
* Since each `struct ctf_fs_ds_file_group` has a sorted array of
stream_range->begin_ns != UINT64_C(-1) && stream_range->end_ns != UINT64_C(-1);
add_range(groupInfo, stream_range, "range-ns");
stream_range->begin_ns != UINT64_C(-1) && stream_range->end_ns != UINT64_C(-1);
add_range(groupInfo, stream_range, "range-ns");
-
- bt2c::GCharUP portName = ctf_fs_make_port_name(group);
- if (!portName) {
- BT_CPPLOGE_APPEND_CAUSE_AND_THROW_SPEC(logger, bt2::Error, "Failed to make port name");
- }
-
- groupInfo.insert("port-name", portName.get());
+ groupInfo.insert("port-name", ctf_fs_make_port_name(group));
}
static void populate_trace_info(const struct ctf_fs_trace *trace, const bt2::MapValue traceInfo,
}
static void populate_trace_info(const struct ctf_fs_trace *trace, const bt2::MapValue traceInfo,
for (const auto& group : trace->ds_file_groups) {
range group_range;
const auto groupInfo = fileGroups.appendEmptyMap();
for (const auto& group : trace->ds_file_groups) {
range group_range;
const auto groupInfo = fileGroups.appendEmptyMap();
- populate_stream_info(group.get(), groupInfo, &group_range, logger);
+ populate_stream_info(group.get(), groupInfo, &group_range);