};
BT_HIDDEN
-struct bt_component_class_query_method_return metadata_info_query(
- struct bt_component_class *comp_class,
- struct bt_value *params)
+enum bt_query_status metadata_info_query(
+ struct bt_self_component_class_source *comp_class,
+ struct bt_value *params, struct bt_value **user_result)
{
- struct bt_component_class_query_method_return query_ret = {
- .result = NULL,
- .status = BT_QUERY_STATUS_OK,
- };
-
+ enum bt_query_status status = BT_QUERY_STATUS_OK;
struct bt_private_value *result = NULL;
struct bt_value *path_value = NULL;
char *metadata_text = NULL;
result = bt_private_value_map_create();
if (!result) {
- query_ret.status = BT_QUERY_STATUS_NOMEM;
+ status = BT_QUERY_STATUS_NOMEM;
goto error;
}
- query_ret.result = bt_value_borrow_from_private(result);
BT_ASSERT(params);
if (!bt_value_is_map(params)) {
BT_LOGE_STR("Query parameters is not a map value object.");
- query_ret.status = BT_QUERY_STATUS_INVALID_PARAMS;
+ status = BT_QUERY_STATUS_INVALID_PARAMS;
goto error;
}
error:
BT_OBJECT_PUT_REF_AND_RESET(result);
- query_ret.result = NULL;
+ result = NULL;
- if (query_ret.status >= 0) {
- query_ret.status = BT_QUERY_STATUS_ERROR;
+ if (status >= 0) {
+ status = BT_QUERY_STATUS_ERROR;
}
end:
fclose(metadata_fp);
}
- return query_ret;
+ *user_result = bt_private_value_borrow_value(result);
+ return status;
}
static
}
status = bt_private_value_map_insert_entry(info, range_name,
- bt_value_borrow_from_private(range_map));
+ bt_private_value_borrow_value(range_map));
if (status != BT_VALUE_STATUS_OK) {
ret = -1;
goto end;
}
status = bt_private_value_map_insert_entry(group_info, "paths",
- bt_value_borrow_from_private(file_paths));
+ bt_private_value_borrow_value(file_paths));
if (status != BT_VALUE_STATUS_OK) {
ret = -1;
goto end;
}
ret = add_stream_ids(group_info,
- bt_stream_borrow_from_private(group->stream));
+ bt_private_stream_borrow_stream(group->stream));
if (ret) {
goto end;
}
trace_intersection.set = true;
status = bt_private_value_array_append_element(
file_groups,
- bt_value_borrow_from_private(group_info));
+ bt_private_value_borrow_value(group_info));
bt_object_put_ref(group_info);
if (status != BT_VALUE_STATUS_OK) {
goto end;
}
status = bt_private_value_map_insert_entry(trace_info, "streams",
- bt_value_borrow_from_private(file_groups));
+ bt_private_value_borrow_value(file_groups));
BT_OBJECT_PUT_REF_AND_RESET(file_groups);
if (status != BT_VALUE_STATUS_OK) {
ret = -1;
}
BT_HIDDEN
-struct bt_component_class_query_method_return trace_info_query(
- struct bt_component_class *comp_class,
- struct bt_value *params)
+enum bt_query_status trace_info_query(
+ struct bt_self_component_class_source *comp_class,
+ struct bt_value *params, struct bt_value **user_result)
{
- struct bt_component_class_query_method_return query_ret = {
- .result = NULL,
- .status = BT_QUERY_STATUS_OK,
- };
-
+ enum bt_query_status status = BT_QUERY_STATUS_OK;
struct bt_private_value *result = NULL;
struct bt_value *path_value = NULL;
int ret = 0;
if (!bt_value_is_map(params)) {
BT_LOGE("Query parameters is not a map value object.");
- query_ret.status = BT_QUERY_STATUS_INVALID_PARAMS;
+ status = BT_QUERY_STATUS_INVALID_PARAMS;
goto error;
}
result = bt_private_value_array_create();
if (!result) {
- query_ret.status = BT_QUERY_STATUS_NOMEM;
+ status = BT_QUERY_STATUS_NOMEM;
goto error;
}
- query_ret.result = bt_value_borrow_from_private(result);
-
/* Iterates over both trace paths and names simultaneously. */
for (tp_node = trace_paths, tn_node = trace_names; tp_node;
tp_node = g_list_next(tp_node),
}
status = bt_private_value_array_append_element(result,
- bt_value_borrow_from_private(trace_info));
+ bt_private_value_borrow_value(trace_info));
bt_object_put_ref(trace_info);
if (status != BT_VALUE_STATUS_OK) {
goto error;
error:
BT_OBJECT_PUT_REF_AND_RESET(result);
- query_ret.result = NULL;
+ result = NULL;
- if (query_ret.status >= 0) {
- query_ret.status = BT_QUERY_STATUS_ERROR;
+ if (status >= 0) {
+ status = BT_QUERY_STATUS_ERROR;
}
end:
}
g_list_free(trace_names);
}
- /* "path" becomes invalid with the release of path_value. */
- return query_ret;
+
+ *user_result = bt_private_value_borrow_value(result);
+ return status;
}