ctf_metadata_decoder_up decoder = ctf_metadata_decoder_create(&decoder_cfg);
if (!decoder) {
BT_CPPLOGE_APPEND_CAUSE_AND_THROW_SPEC(
- logger, bt2::Error, "Cannot create metadata decoder: path=\"{}}\".", path);
+ logger, bt2::Error, "Cannot create metadata decoder: path=\"{}\".", path);
}
rewind(metadataFp.get());
return result;
}
-static void add_range(const bt2::MapValue info, struct range *range, const char *range_name)
+static void add_range(const bt2::MapValue info, const range& range, const char *range_name)
{
- if (!range->set) {
+ if (!range.set) {
/* Not an error. */
return;
}
const auto rangeMap = info.insertEmptyMap(range_name);
- rangeMap.insert("begin", range->begin_ns);
- rangeMap.insert("end", range->end_ns);
+ rangeMap.insert("begin", range.begin_ns);
+ rangeMap.insert("end", range.end_ns);
}
-static void populate_stream_info(struct ctf_fs_ds_file_group *group, const bt2::MapValue groupInfo,
- struct range *stream_range)
+static void populate_stream_info(struct ctf_fs_ds_file_group *group, const bt2::MapValue groupInfo)
{
/*
* 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;
+ range stream_range;
+ 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
* packets don't include `timestamp_begin` _and_ `timestamp_end` fields
* in their packet context so we can't set the range.
*/
- stream_range->set =
- stream_range->begin_ns != UINT64_C(-1) && stream_range->end_ns != UINT64_C(-1);
+ stream_range.set = stream_range.begin_ns != UINT64_C(-1) && stream_range.end_ns != UINT64_C(-1);
add_range(groupInfo, stream_range, "range-ns");
groupInfo.insert("port-name", ctf_fs_make_port_name(group));
/* Find range of all stream groups, and of the trace. */
for (const auto& group : trace->ds_file_groups) {
- range group_range;
const auto groupInfo = fileGroups.appendEmptyMap();
- populate_stream_info(group.get(), groupInfo, &group_range);
+ populate_stream_info(group.get(), groupInfo);
}
}
bt2::Value::Shared trace_infos_query(const bt2::ConstMapValue params, const bt2c::Logger& logger)
{
- ctf_fs_component ctf_fs {logger};
- const bt_value *inputs_value = NULL;
- const bt_value *trace_name_value;
+ const auto parameters = read_src_fs_parameters(params, logger);
+ ctf_fs_component ctf_fs {parameters.clkClsCfg, logger};
- if (!read_src_fs_parameters(params.libObjPtr(), &inputs_value, &trace_name_value, &ctf_fs)) {
- BT_CPPLOGE_APPEND_CAUSE_AND_THROW_SPEC(logger, bt2::Error, "Failed to read parameters");
- }
-
- if (ctf_fs_component_create_ctf_fs_trace(&ctf_fs, 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");
}