}
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
* the timestamp_begin of the first index entry and the timestamp_end
* of the last index entry.
*/
- BT_ASSERT(group->index);
- BT_ASSERT(!group->index->entries.empty());
+ BT_ASSERT(!group->index.entries.empty());
/* First entry. */
- const auto first_ds_index_entry = group->index->entries.front().get();
+ const auto& first_ds_index_entry = group->index.entries.front();
/* Last entry. */
- const auto last_ds_index_entry = group->index->entries.back().get();
+ const auto& last_ds_index_entry = group->index.entries.back();
- stream_range->begin_ns = first_ds_index_entry->timestamp_begin_ns;
- stream_range->end_ns = last_ds_index_entry->timestamp_end_ns;
+ stream_range->begin_ns = first_ds_index_entry.timestamp_begin_ns;
+ stream_range->end_ns = last_ds_index_entry.timestamp_end_ns;
/*
* If any of the begin and end timestamps is not set it means that
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,
{
/* Add trace range info only if it contains streams. */
if (trace->ds_file_groups.empty()) {
- BT_CPPLOGE_APPEND_CAUSE_AND_THROW_SPEC(
- logger, bt2::Error, "Trace has no streams: trace-path={}", trace->path->str);
+ BT_CPPLOGE_APPEND_CAUSE_AND_THROW_SPEC(logger, bt2::Error,
+ "Trace has no streams: trace-path={}", trace->path);
}
const auto fileGroups = traceInfo.insertEmptyArray("stream-infos");
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);
}
}
bt2::Value::Shared trace_infos_query(const bt2::ConstMapValue params, const bt2c::Logger& logger)
{
- ctf_fs_component::UP ctf_fs = ctf_fs_component_create(logger);
- if (!ctf_fs) {
- BT_CPPLOGE_APPEND_CAUSE_AND_THROW_SPEC(logger, bt2::Error,
- "Cannot create ctf_fs_component");
- }
-
- const bt_value *inputs_value = NULL;
- const bt_value *trace_name_value;
-
- if (!read_src_fs_parameters(params.libObjPtr(), &inputs_value, &trace_name_value,
- ctf_fs.get())) {
- BT_CPPLOGE_APPEND_CAUSE_AND_THROW_SPEC(logger, bt2::Error, "Failed to read parameters");
- }
+ const auto parameters = read_src_fs_parameters(params, logger);
+ ctf_fs_component ctf_fs {parameters.clkClsCfg, logger};
- if (ctf_fs_component_create_ctf_fs_trace(ctf_fs.get(), inputs_value, trace_name_value, NULL)) {
+ if (ctf_fs_component_create_ctf_fs_trace(
+ &ctf_fs, parameters.inputs,
+ parameters.traceName ? parameters.traceName->c_str() : nullptr, nullptr)) {
BT_CPPLOGE_APPEND_CAUSE_AND_THROW_SPEC(logger, bt2::Error, "Failed to create trace");
}
const auto result = bt2::ArrayValue::create();
const auto traceInfo = result->appendEmptyMap();
- populate_trace_info(ctf_fs->trace.get(), traceInfo, logger);
+ populate_trace_info(ctf_fs.trace.get(), traceInfo, logger);
return result;
}