def help(self):
return native_bt.component_class_get_help(self._ptr)
- def query_info(self, action, params=None):
- return _query_info(self._ptr, action, params)
+ def query(self, obj, params=None):
+ return _query(self._ptr, obj, params)
def __call__(self, params=None, name=None):
params = bt2.create_value(params)
return '\n'.join(trimmed)
-def _query_info(comp_cls_ptr, action, params):
- utils._check_str(action)
+def _query(comp_cls_ptr, obj, params):
+ utils._check_str(obj)
if params is None:
params_ptr = native_bt.value_null
params = bt2.create_value(params)
params_ptr = params._ptr
- results_ptr = native_bt.component_class_query_info(comp_cls_ptr, action,
+ results_ptr = native_bt.component_class_query(comp_cls_ptr, obj,
params_ptr)
if results_ptr is None:
- raise bt2.Error('cannot query info with action "{}"'.format(action))
+ raise bt2.Error('cannot query info with object "{}"'.format(obj))
if results_ptr == native_bt.value_null:
return
def addr(cls):
return int(cls._cc_ptr)
- def query_info(cls, action, params=None):
- return _query_info(cls._cc_ptr, action, params)
+ def query(cls, action, params=None):
+ return _query(cls._cc_ptr, action, params)
- def _query_info_from_bt(cls, action, params):
+ def _query_from_bt(cls, action, params):
# this can raise, in which case the native call to
- # bt_component_class_query_info() returns NULL
- results = cls._query_info(action, params)
+ # bt_component_class_query() returns NULL
+ results = cls._query(action, params)
results = bt2.create_value(results)
if results is None:
return results_addr
@staticmethod
- def _query_info(action, params):
+ def _query(action, params):
# BT catches this and returns NULL to the user
raise NotImplementedError
struct bt_component_class *component_class);
const char *bt_component_class_get_help(
struct bt_component_class *component_class);
-struct bt_value *bt_component_class_query_info(
+struct bt_value *bt_component_class_query(
struct bt_component_class *component_class,
const char *action, struct bt_value *params);
enum bt_component_class_type bt_component_class_get_type(
}
}
-static struct bt_value *bt_py3_cc_query_info(
+static struct bt_value *bt_py3_cc_query(
struct bt_component_class *component_class,
- const char *action, struct bt_value *params)
+ const char *object, struct bt_value *params)
{
PyObject *py_cls = NULL;
PyObject *py_params = NULL;
- PyObject *py_query_info_func = NULL;
- PyObject *py_action = NULL;
+ PyObject *py_query_func = NULL;
+ PyObject *py_object = NULL;
PyObject *py_results_addr = NULL;
struct bt_value *results = NULL;
goto error;
}
- py_action = SWIG_FromCharPtr(action);
- if (!py_action) {
+ py_object = SWIG_FromCharPtr(object);
+ if (!py_object) {
goto error;
}
py_results_addr = PyObject_CallMethod(py_cls,
- "_query_info_from_bt", "(OO)", py_action, py_params);
+ "_query_from_bt", "(OO)", py_object, py_params);
if (!py_results_addr) {
goto error;
}
end:
Py_XDECREF(py_params);
- Py_XDECREF(py_query_info_func);
- Py_XDECREF(py_action);
+ Py_XDECREF(py_query_func);
+ Py_XDECREF(py_object);
Py_XDECREF(py_results_addr);
return results;
}
goto end;
}
- ret = bt_component_class_set_query_info_method(cc,
- bt_py3_cc_query_info);
+ ret = bt_component_class_set_query_method(cc, bt_py3_cc_query);
if (ret) {
goto end;
}
BT_PUT(cfg->cmd_data.help.plugin_paths);
BT_PUT(cfg->cmd_data.help.cfg_component);
break;
- case BT_CONFIG_COMMAND_QUERY_INFO:
- BT_PUT(cfg->cmd_data.query_info.plugin_paths);
- BT_PUT(cfg->cmd_data.query_info.cfg_component);
+ case BT_CONFIG_COMMAND_QUERY:
+ BT_PUT(cfg->cmd_data.query.plugin_paths);
+ BT_PUT(cfg->cmd_data.query.cfg_component);
- if (cfg->cmd_data.query_info.action) {
- g_string_free(cfg->cmd_data.query_info.action, TRUE);
+ if (cfg->cmd_data.query.object) {
+ g_string_free(cfg->cmd_data.query.object, TRUE);
}
break;
default:
return cfg;
}
-static struct bt_config *bt_config_query_info_create(
+static struct bt_config *bt_config_query_create(
struct bt_value *initial_plugin_paths)
{
struct bt_config *cfg;
/* Create config */
- cfg = bt_config_base_create(BT_CONFIG_COMMAND_QUERY_INFO);
+ cfg = bt_config_base_create(BT_CONFIG_COMMAND_QUERY);
if (!cfg) {
print_err_oom();
goto error;
}
if (initial_plugin_paths) {
- cfg->cmd_data.query_info.plugin_paths =
+ cfg->cmd_data.query.plugin_paths =
bt_get(initial_plugin_paths);
} else {
- cfg->cmd_data.query_info.plugin_paths =
+ cfg->cmd_data.query.plugin_paths =
bt_value_array_create();
- if (!cfg->cmd_data.query_info.plugin_paths) {
+ if (!cfg->cmd_data.query.plugin_paths) {
print_err_oom();
goto error;
}
}
- cfg->cmd_data.query_info.action = g_string_new(NULL);
- if (!cfg->cmd_data.query_info.action) {
+ cfg->cmd_data.query.object = g_string_new(NULL);
+ if (!cfg->cmd_data.query.object) {
print_err_oom();
goto error;
}
* Prints the help command usage.
*/
static
-void print_query_info_usage(FILE *fp)
+void print_query_usage(FILE *fp)
{
- fprintf(fp, "Usage: babeltrace [GEN OPTS] query-info [OPTS] ACTION --source=PLUGIN.COMPCLS\n");
- fprintf(fp, " babeltrace [GEN OPTS] query-info [OPTS] ACTION --filter=PLUGIN.COMPCLS\n");
- fprintf(fp, " babeltrace [GEN OPTS] query-info [OPTS] ACTION --sink=PLUGIN.COMPCLS\n");
+ fprintf(fp, "Usage: babeltrace [GEN OPTS] query [OPTS] OBJECT --source=PLUGIN.COMPCLS\n");
+ fprintf(fp, " babeltrace [GEN OPTS] query [OPTS] OBJECT --filter=PLUGIN.COMPCLS\n");
+ fprintf(fp, " babeltrace [GEN OPTS] query [OPTS] OBJECT --sink=PLUGIN.COMPCLS\n");
fprintf(fp, "\n");
fprintf(fp, "Options:\n");
fprintf(fp, "\n");
- fprintf(fp, " --filter=PLUGIN.COMPCLS Query info from the filter component class\n");
- fprintf(fp, " COMPCLS found in the plugin PLUGIN\n");
+ fprintf(fp, " --filter=PLUGIN.COMPCLS Query object from the filter component\n");
+ fprintf(fp, " class COMPCLS found in the plugin PLUGIN\n");
fprintf(fp, " --omit-home-plugin-path Omit home plugins from plugin search path\n");
fprintf(fp, " (~/.local/lib/babeltrace/plugins)\n");
fprintf(fp, " --omit-system-plugin-path Omit system plugins from plugin search path\n");
fprintf(fp, " (see the expected format of PARAMS below)\n");
fprintf(fp, " --plugin-path=PATH[:PATH]... Add PATH to the list of paths from which\n");
fprintf(fp, " dynamic plugins can be loaded\n");
- fprintf(fp, " --sink=PLUGIN.COMPCLS Query info from the sink component class\n");
- fprintf(fp, " COMPCLS found in the plugin PLUGIN\n");
- fprintf(fp, " --source=PLUGIN.COMPCLS Query info from the source component class\n");
+ fprintf(fp, " --sink=PLUGIN.COMPCLS Query object from the sink component class\n");
fprintf(fp, " COMPCLS found in the plugin PLUGIN\n");
+ fprintf(fp, " --source=PLUGIN.COMPCLS Query object from the source component\n");
+ fprintf(fp, " class COMPCLS found in the plugin PLUGIN\n");
fprintf(fp, " -h --help Show this help and quit\n");
fprintf(fp, "\n\n");
print_expected_params_format(fp);
}
-static struct poptOption query_info_long_options[] = {
+static struct poptOption query_long_options[] = {
/* longName, shortName, argInfo, argPtr, value, descrip, argDesc */
{ "filter", '\0', POPT_ARG_STRING, NULL, OPT_FILTER, NULL, NULL },
{ "help", 'h', POPT_ARG_NONE, NULL, OPT_HELP, NULL, NULL },
};
/*
- * Creates a Babeltrace config object from the arguments of a query-info
+ * Creates a Babeltrace config object from the arguments of a query
* command.
*
* *retcode is set to the appropriate exit code to use.
*/
-struct bt_config *bt_config_query_info_from_args(int argc, const char *argv[],
+struct bt_config *bt_config_query_from_args(int argc, const char *argv[],
int *retcode, bool omit_system_plugin_path,
bool omit_home_plugin_path,
struct bt_value *initial_plugin_paths)
struct bt_value *params = bt_value_null;
*retcode = 0;
- cfg = bt_config_query_info_create(initial_plugin_paths);
+ cfg = bt_config_query_create(initial_plugin_paths);
if (!cfg) {
print_err_oom();
goto error;
}
- cfg->cmd_data.query_info.omit_system_plugin_path =
+ cfg->cmd_data.query.omit_system_plugin_path =
omit_system_plugin_path;
- cfg->cmd_data.query_info.omit_home_plugin_path = omit_home_plugin_path;
- ret = append_env_var_plugin_paths(cfg->cmd_data.query_info.plugin_paths);
+ cfg->cmd_data.query.omit_home_plugin_path = omit_home_plugin_path;
+ ret = append_env_var_plugin_paths(cfg->cmd_data.query.plugin_paths);
if (ret) {
printf_err("Cannot append plugin paths from BABELTRACE_PLUGIN_PATH\n");
goto error;
/* Parse options */
pc = poptGetContext(NULL, argc, (const char **) argv,
- query_info_long_options, 0);
+ query_long_options, 0);
if (!pc) {
printf_err("Cannot get popt context\n");
goto error;
printf_debug("Skipping non-system plugin paths for setuid/setgid binary\n");
} else {
if (bt_config_append_plugin_paths(
- cfg->cmd_data.query_info.plugin_paths,
+ cfg->cmd_data.query.plugin_paths,
arg)) {
printf_err("Invalid --plugin-path option's argument:\n %s\n",
arg);
}
break;
case OPT_OMIT_SYSTEM_PLUGIN_PATH:
- cfg->cmd_data.query_info.omit_system_plugin_path = true;
+ cfg->cmd_data.query.omit_system_plugin_path = true;
break;
case OPT_OMIT_HOME_PLUGIN_PATH:
- cfg->cmd_data.query_info.omit_home_plugin_path = true;
+ cfg->cmd_data.query.omit_home_plugin_path = true;
break;
case OPT_SOURCE:
case OPT_FILTER:
{
enum bt_component_class_type type;
- if (cfg->cmd_data.query_info.cfg_component) {
+ if (cfg->cmd_data.query.cfg_component) {
printf_err("Cannot specify more than one plugin and component class:\n %s\n",
arg);
goto error;
assert(false);
}
- cfg->cmd_data.query_info.cfg_component =
+ cfg->cmd_data.query.cfg_component =
bt_config_component_from_arg(type, arg);
- if (!cfg->cmd_data.query_info.cfg_component) {
+ if (!cfg->cmd_data.query.cfg_component) {
printf_err("Invalid format for --source/--filter/--sink option's argument:\n %s\n",
arg);
goto error;
}
/* Default parameters: null */
- bt_put(cfg->cmd_data.query_info.cfg_component->params);
- cfg->cmd_data.query_info.cfg_component->params =
+ bt_put(cfg->cmd_data.query.cfg_component->params);
+ cfg->cmd_data.query.cfg_component->params =
bt_value_null;
break;
}
break;
}
case OPT_HELP:
- print_query_info_usage(stdout);
+ print_query_usage(stdout);
*retcode = -1;
BT_PUT(cfg);
goto end;
arg = NULL;
}
- if (!cfg->cmd_data.query_info.cfg_component) {
+ if (!cfg->cmd_data.query.cfg_component) {
printf_err("No target component class specified with --source/--filter/--sink option\n");
goto error;
}
assert(params);
- BT_MOVE(cfg->cmd_data.query_info.cfg_component->params, params);
+ BT_MOVE(cfg->cmd_data.query.cfg_component->params, params);
/* Check for option parsing error */
if (opt < -1) {
/*
* We need exactly one leftover argument which is the
- * mandatory action.
+ * mandatory object.
*/
leftover = poptGetArg(pc);
if (leftover) {
if (strlen(leftover) == 0) {
- printf_err("Invalid empty action\n");
+ printf_err("Invalid empty object\n");
goto error;
}
- g_string_assign(cfg->cmd_data.query_info.action, leftover);
+ g_string_assign(cfg->cmd_data.query.object, leftover);
} else {
- print_query_info_usage(stdout);
+ print_query_usage(stdout);
*retcode = -1;
BT_PUT(cfg);
goto end;
}
if (append_home_and_system_plugin_paths(
- cfg->cmd_data.query_info.plugin_paths,
- cfg->cmd_data.query_info.omit_system_plugin_path,
- cfg->cmd_data.query_info.omit_home_plugin_path)) {
+ cfg->cmd_data.query.plugin_paths,
+ cfg->cmd_data.query.omit_system_plugin_path,
+ cfg->cmd_data.query.omit_home_plugin_path)) {
printf_err("Cannot append home and system plugin paths\n");
goto error;
}
fprintf(fp, " convert Build a trace conversion graph and run it (default)\n");
fprintf(fp, " help Get help for a plugin or a component class\n");
fprintf(fp, " list-plugins List available plugins and their content\n");
- fprintf(fp, " query-info Query information from a component class\n");
+ fprintf(fp, " query Query objects from a component class\n");
fprintf(fp, "\n");
fprintf(fp, "Use `babeltrace COMMAND --help` to show the help of COMMAND.\n");
}
command = BT_CONFIG_COMMAND_LIST_PLUGINS;
} else if (strcmp(cur_arg, "help") == 0) {
command = BT_CONFIG_COMMAND_HELP;
- } else if (strcmp(cur_arg, "query-info") == 0) {
- command = BT_CONFIG_COMMAND_QUERY_INFO;
+ } else if (strcmp(cur_arg, "query") == 0) {
+ command = BT_CONFIG_COMMAND_QUERY;
} else {
/*
* Unknown argument, but not a known
command_argv, retcode, omit_system_plugin_path,
omit_home_plugin_path, initial_plugin_paths);
break;
- case BT_CONFIG_COMMAND_QUERY_INFO:
- config = bt_config_query_info_from_args(command_argc,
+ case BT_CONFIG_COMMAND_QUERY:
+ config = bt_config_query_from_args(command_argc,
command_argv, retcode, omit_system_plugin_path,
omit_home_plugin_path, initial_plugin_paths);
break;
BT_CONFIG_COMMAND_CONVERT,
BT_CONFIG_COMMAND_LIST_PLUGINS,
BT_CONFIG_COMMAND_HELP,
- BT_CONFIG_COMMAND_QUERY_INFO,
+ BT_CONFIG_COMMAND_QUERY,
};
struct bt_config {
struct bt_config_component *cfg_component;
} help;
- /* BT_CONFIG_COMMAND_QUERY_INFO */
+ /* BT_CONFIG_COMMAND_QUERY */
struct {
struct bt_value *plugin_paths;
bool omit_system_plugin_path;
bool omit_home_plugin_path;
- GString *action;
+ GString *object;
struct bt_config_component *cfg_component;
- } query_info;
+ } query;
} cmd_data;
};
}
static
-void print_cfg_query_info(struct bt_config *cfg)
+void print_cfg_query(struct bt_config *cfg)
{
- print_plugin_paths(cfg->cmd_data.query_info.plugin_paths);
- printf(" Action: `%s`\n", cfg->cmd_data.query_info.action->str);
+ print_plugin_paths(cfg->cmd_data.query.plugin_paths);
+ printf(" Object: `%s`\n", cfg->cmd_data.query.object->str);
printf(" Component class:\n");
- print_bt_config_component(cfg->cmd_data.query_info.cfg_component);
+ print_bt_config_component(cfg->cmd_data.query.cfg_component);
}
static
case BT_CONFIG_COMMAND_HELP:
print_cfg_help(cfg);
break;
- case BT_CONFIG_COMMAND_QUERY_INFO:
- print_cfg_query_info(cfg);
+ case BT_CONFIG_COMMAND_QUERY:
+ print_cfg_query(cfg);
break;
default:
assert(false);
bt_common_color_reset());
}
-static int cmd_query_info(struct bt_config *cfg)
+static int cmd_query(struct bt_config *cfg)
{
int ret;
struct bt_component_class *comp_cls = NULL;
goto end;
}
- comp_cls = find_component_class(cfg->cmd_data.query_info.cfg_component->plugin_name->str,
- cfg->cmd_data.query_info.cfg_component->component_name->str,
- cfg->cmd_data.query_info.cfg_component->type);
+ comp_cls = find_component_class(cfg->cmd_data.query.cfg_component->plugin_name->str,
+ cfg->cmd_data.query.cfg_component->component_name->str,
+ cfg->cmd_data.query.cfg_component->type);
if (!comp_cls) {
fprintf(stderr, "%s%sCannot find component class %s",
bt_common_color_bold(),
bt_common_color_fg_red(),
bt_common_color_reset());
print_plugin_comp_cls_opt(stderr,
- cfg->cmd_data.query_info.cfg_component->plugin_name->str,
- cfg->cmd_data.query_info.cfg_component->component_name->str,
- cfg->cmd_data.query_info.cfg_component->type);
+ cfg->cmd_data.query.cfg_component->plugin_name->str,
+ cfg->cmd_data.query.cfg_component->component_name->str,
+ cfg->cmd_data.query.cfg_component->type);
fprintf(stderr, "\n");
ret = -1;
goto end;
}
- results = bt_component_class_query_info(comp_cls,
- cfg->cmd_data.query_info.action->str,
- cfg->cmd_data.query_info.cfg_component->params);
+ results = bt_component_class_query(comp_cls,
+ cfg->cmd_data.query.object->str,
+ cfg->cmd_data.query.cfg_component->params);
if (!results) {
fprintf(stderr, "%s%sFailed to query info to %s",
bt_common_color_bold(),
bt_common_color_fg_red(),
bt_common_color_reset());
print_plugin_comp_cls_opt(stderr,
- cfg->cmd_data.query_info.cfg_component->plugin_name->str,
- cfg->cmd_data.query_info.cfg_component->component_name->str,
- cfg->cmd_data.query_info.cfg_component->type);
- fprintf(stderr, "%s%s with action `%s`%s\n",
+ cfg->cmd_data.query.cfg_component->plugin_name->str,
+ cfg->cmd_data.query.cfg_component->component_name->str,
+ cfg->cmd_data.query.cfg_component->type);
+ fprintf(stderr, "%s%s with object `%s`%s\n",
bt_common_color_bold(),
bt_common_color_fg_red(),
- cfg->cmd_data.query_info.action->str,
+ cfg->cmd_data.query.object->str,
bt_common_color_reset());
ret = -1;
goto end;
goto end;
}
- results = bt_component_class_query_info(comp_cls, "get-metadata-info",
+ results = bt_component_class_query(comp_cls, "metadata-info",
params);
if (!results) {
ret = -1;
- fprintf(stderr, "%s%sFailed to get metadata info%s\n",
+ fprintf(stderr, "%s%sFailed to request metadata info%s\n",
bt_common_color_bold(),
bt_common_color_fg_red(),
bt_common_color_reset());
case BT_CONFIG_COMMAND_HELP:
ret = cmd_help(cfg);
break;
- case BT_CONFIG_COMMAND_QUERY_INFO:
- ret = cmd_query_info(cfg);
+ case BT_CONFIG_COMMAND_QUERY:
+ ret = cmd_query(cfg);
break;
default:
assert(false);
struct {
bt_component_class_init_method init;
bt_component_class_destroy_method destroy;
- bt_component_class_query_info_method query_info;
+ bt_component_class_query_method query;
} methods;
/* Array of struct bt_component_class_destroy_listener */
GArray *destroy_listeners;
(*bt_component_class_notification_iterator_seek_time_method)(
struct bt_notification_iterator *iterator, int64_t time);
-typedef struct bt_value *(*bt_component_class_query_info_method)(
+typedef struct bt_value *(*bt_component_class_query_method)(
struct bt_component_class *component_class,
- const char *action, struct bt_value *params);
+ const char *object, struct bt_value *params);
extern int bt_component_class_set_init_method(
struct bt_component_class *component_class,
extern const char *bt_component_class_get_help(
struct bt_component_class *component_class);
-extern int bt_component_class_set_query_info_method(
+extern int bt_component_class_set_query_method(
struct bt_component_class *component_class,
- bt_component_class_query_info_method query_info_method);
+ bt_component_class_query_method query_method);
-extern struct bt_value *bt_component_class_query_info(
+extern struct bt_value *bt_component_class_query(
struct bt_component_class *component_class,
- const char *action, struct bt_value *params);
+ const char *object, struct bt_value *params);
/**
* Get a component class' type.
BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_HELP = 1,
BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_INIT_METHOD = 2,
BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_DESTROY_METHOD = 3,
- BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_QUERY_INFO_METHOD = 4,
+ BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_QUERY_METHOD = 4,
BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_FILTER_ADD_ITERATOR_METHOD = 5,
BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_SINK_ADD_ITERATOR_METHOD = 6,
BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_NOTIF_ITER_INIT_METHOD = 7,
/* BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_DESTROY_METHOD */
bt_component_class_destroy_method destroy_method;
- /* BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_QUERY_INFO_METHOD */
- bt_component_class_query_info_method query_info_method;
+ /* BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_QUERY_METHOD */
+ bt_component_class_query_method query_method;
/* BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_FILTER_ADD_ITERATOR_METHOD */
bt_component_class_filter_add_iterator_method filter_add_iterator_method;
__BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(destroy_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_DESTROY_METHOD, _id, _comp_class_id, sink, _x)
/*
- * Defines a query info method attribute attached to a specific source
+ * Defines a query method attribute attached to a specific source
* component class descriptor.
*
* _id: Plugin descriptor ID (C identifier).
* _comp_class_id: Component class descriptor ID (C identifier).
- * _x: Destroy method (bt_component_class_query_info_method).
+ * _x: Destroy method (bt_component_class_query_method).
*/
-#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_QUERY_INFO_METHOD_WITH_ID(_id, _comp_class_id, _x) \
- __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(query_info_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_QUERY_INFO_METHOD, _id, _comp_class_id, source, _x)
+#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_QUERY_METHOD_WITH_ID(_id, _comp_class_id, _x) \
+ __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(query_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_QUERY_METHOD, _id, _comp_class_id, source, _x)
/*
- * Defines a query info method attribute attached to a specific filter
+ * Defines a query method attribute attached to a specific filter
* component class descriptor.
*
* _id: Plugin descriptor ID (C identifier).
* _comp_class_id: Component class descriptor ID (C identifier).
- * _x: Destroy method (bt_component_class_query_info_method).
+ * _x: Destroy method (bt_component_class_query_method).
*/
-#define BT_PLUGIN_FILTER_COMPONENT_CLASS_QUERY_INFO_METHOD_WITH_ID(_id, _comp_class_id, _x) \
- __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(query_info_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_QUERY_INFO_METHOD, _id, _comp_class_id, filter, _x)
+#define BT_PLUGIN_FILTER_COMPONENT_CLASS_QUERY_METHOD_WITH_ID(_id, _comp_class_id, _x) \
+ __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(query_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_QUERY_METHOD, _id, _comp_class_id, filter, _x)
/*
- * Defines a query info method attribute attached to a specific sink
+ * Defines a query method attribute attached to a specific sink
* component class descriptor.
*
* _id: Plugin descriptor ID (C identifier).
* _comp_class_id: Component class descriptor ID (C identifier).
- * _x: Destroy method (bt_component_class_query_info_method).
+ * _x: Destroy method (bt_component_class_query_method).
*/
-#define BT_PLUGIN_SINK_COMPONENT_CLASS_QUERY_INFO_METHOD_WITH_ID(_id, _comp_class_id, _x) \
- __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(query_info_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_QUERY_INFO_METHOD, _id, _comp_class_id, sink, _x)
+#define BT_PLUGIN_SINK_COMPONENT_CLASS_QUERY_METHOD_WITH_ID(_id, _comp_class_id, _x) \
+ __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(query_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_QUERY_METHOD, _id, _comp_class_id, sink, _x)
/*
* Defines an add iterator method attribute attached to a specific
BT_PLUGIN_SINK_COMPONENT_CLASS_DESTROY_METHOD_WITH_ID(auto, _name, _x)
/*
- * Defines a query info method attribute attached to a source component
+ * Defines a query method attribute attached to a source component
* class descriptor which is attached to the automatic plugin
* descriptor.
*
* _name: Component class name (C identifier).
- * _x: Initialization method (bt_component_class_query_info_method).
+ * _x: Initialization method (bt_component_class_query_method).
*/
-#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_QUERY_INFO_METHOD(_name, _x) \
- BT_PLUGIN_SOURCE_COMPONENT_CLASS_QUERY_INFO_METHOD_WITH_ID(auto, _name, _x)
+#define BT_PLUGIN_SOURCE_COMPONENT_CLASS_QUERY_METHOD(_name, _x) \
+ BT_PLUGIN_SOURCE_COMPONENT_CLASS_QUERY_METHOD_WITH_ID(auto, _name, _x)
/*
- * Defines a query info method attribute attached to a filter component
+ * Defines a query method attribute attached to a filter component
* class descriptor which is attached to the automatic plugin
* descriptor.
*
* _name: Component class name (C identifier).
- * _x: Initialization method (bt_component_class_query_info_method).
+ * _x: Initialization method (bt_component_class_query_method).
*/
-#define BT_PLUGIN_FILTER_COMPONENT_CLASS_QUERY_INFO_METHOD(_name, _x) \
- BT_PLUGIN_FILTER_COMPONENT_CLASS_QUERY_INFO_METHOD_WITH_ID(auto, _name, _x)
+#define BT_PLUGIN_FILTER_COMPONENT_CLASS_QUERY_METHOD(_name, _x) \
+ BT_PLUGIN_FILTER_COMPONENT_CLASS_QUERY_METHOD_WITH_ID(auto, _name, _x)
/*
- * Defines a query info method attribute attached to a sink component
+ * Defines a query method attribute attached to a sink component
* class descriptor which is attached to the automatic plugin
* descriptor.
*
* _name: Component class name (C identifier).
- * _x: Initialization method (bt_component_class_query_info_method).
+ * _x: Initialization method (bt_component_class_query_method).
*/
-#define BT_PLUGIN_SINK_COMPONENT_CLASS_QUERY_INFO_METHOD(_name, _x) \
- BT_PLUGIN_SINK_COMPONENT_CLASS_QUERY_INFO_METHOD_WITH_ID(auto, _name, _x)
+#define BT_PLUGIN_SINK_COMPONENT_CLASS_QUERY_METHOD(_name, _x) \
+ BT_PLUGIN_SINK_COMPONENT_CLASS_QUERY_METHOD_WITH_ID(auto, _name, _x)
/*
* Defines an add iterator method attribute attached to a filter
return ret;
}
-int bt_component_class_set_query_info_method(
+int bt_component_class_set_query_method(
struct bt_component_class *component_class,
- bt_component_class_query_info_method query_info_method)
+ bt_component_class_query_method query_method)
{
int ret = 0;
- if (!component_class || component_class->frozen || !query_info_method) {
+ if (!component_class || component_class->frozen || !query_method) {
ret = -1;
goto end;
}
- component_class->methods.query_info = query_info_method;
+ component_class->methods.query = query_method;
end:
return ret;
return ret;
}
-struct bt_value *bt_component_class_query_info(
+struct bt_value *bt_component_class_query(
struct bt_component_class *component_class,
- const char *action, struct bt_value *params)
+ const char *object, struct bt_value *params)
{
struct bt_value *results = NULL;
- if (!component_class || !action || !params ||
- !component_class->methods.query_info) {
+ if (!component_class || !object || !params ||
+ !component_class->methods.query) {
goto end;
}
- results = component_class->methods.query_info(component_class,
- action, params);
+ results = component_class->methods.query(component_class,
+ object, params);
end:
return results;
const char *help;
bt_component_class_init_method init_method;
bt_component_class_destroy_method destroy_method;
- bt_component_class_query_info_method query_info_method;
+ bt_component_class_query_method query_method;
bt_component_class_filter_add_iterator_method filter_add_iterator_method;
bt_component_class_sink_add_iterator_method sink_add_iterator_method;
struct bt_component_class_iterator_methods iterator_methods;
cc_full_descr->destroy_method =
cur_cc_descr_attr->value.destroy_method;
break;
- case BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_QUERY_INFO_METHOD:
- cc_full_descr->query_info_method =
- cur_cc_descr_attr->value.query_info_method;
+ case BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_QUERY_METHOD:
+ cc_full_descr->query_method =
+ cur_cc_descr_attr->value.query_method;
break;
case BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_FILTER_ADD_ITERATOR_METHOD:
cc_full_descr->filter_add_iterator_method =
}
}
- if (cc_full_descr->query_info_method) {
- ret = bt_component_class_set_query_info_method(
- comp_class, cc_full_descr->query_info_method);
+ if (cc_full_descr->query_method) {
+ ret = bt_component_class_set_query_method(
+ comp_class, cc_full_descr->query_method);
if (ret) {
status = BT_PLUGIN_STATUS_ERROR;
BT_PUT(comp_class);
}
BT_HIDDEN
-struct bt_value *ctf_fs_query_info(struct bt_component_class *comp_class,
- const char *action, struct bt_value *params)
+struct bt_value *ctf_fs_query(struct bt_component_class *comp_class,
+ const char *object, struct bt_value *params)
{
struct bt_value *results = NULL;
struct bt_value *path_value = NULL;
FILE *metadata_fp = NULL;
GString *g_metadata_text = NULL;
- if (strcmp(action, "get-metadata-info") == 0) {
+ if (strcmp(object, "metadata-info") == 0) {
int ret;
int bo;
const char *path;
if (!bt_value_is_map(params)) {
fprintf(stderr,
- "Query info parameters is not a map value object\n");
+ "Query parameters is not a map value object\n");
goto error;
}
goto error;
}
} else {
- fprintf(stderr, "Unknown query info action `%s`\n", action);
+ fprintf(stderr, "Unknown query object `%s`\n", object);
goto error;
}
struct bt_notification_iterator *iterator);
BT_HIDDEN
-struct bt_value *ctf_fs_query_info(struct bt_component_class *comp_class,
- const char *action, struct bt_value *params);
+struct bt_value *ctf_fs_query(struct bt_component_class *comp_class,
+ const char *object, struct bt_value *params);
#endif /* BABELTRACE_PLUGIN_CTF_FS_H */
BT_PLUGIN_SOURCE_COMPONENT_CLASS(fs, ctf_fs_iterator_get, ctf_fs_iterator_next);
BT_PLUGIN_SOURCE_COMPONENT_CLASS_DESCRIPTION(fs, CTF_FS_COMPONENT_DESCRIPTION);
BT_PLUGIN_SOURCE_COMPONENT_CLASS_INIT_METHOD(fs, ctf_fs_init);
-BT_PLUGIN_SOURCE_COMPONENT_CLASS_QUERY_INFO_METHOD(fs, ctf_fs_query_info);
+BT_PLUGIN_SOURCE_COMPONENT_CLASS_QUERY_METHOD(fs, ctf_fs_query);
BT_PLUGIN_SOURCE_COMPONENT_CLASS_DESTROY_METHOD(fs, ctf_fs_destroy);
BT_PLUGIN_SOURCE_COMPONENT_CLASS_NOTIFICATION_ITERATOR_INIT_METHOD(fs,
ctf_fs_iterator_init);
Voilà.'''
self.assertEqual(MySink.help, expected_help)
- def test_query_info_missing(self):
+ def test_query_missing(self):
class MySink(bt2.UserSinkComponent):
def _consume(self):
pass
with self.assertRaises(bt2.Error):
- MySink.query_info('salut')
+ MySink.query('salut')
- def test_query_info_raises(self):
+ def test_query_raises(self):
class MySink(bt2.UserSinkComponent):
def _consume(self):
pass
@staticmethod
- def _query_info(action, params):
+ def _query(obj, params):
raise ValueError
with self.assertRaises(bt2.Error):
- MySink.query_info('salut')
+ MySink.query('salut')
- def test_query_info_gets_none_params(self):
+ def test_query_gets_none_params(self):
class MySink(bt2.UserSinkComponent):
def _consume(self):
pass
@staticmethod
- def _query_info(action, params):
+ def _query(obj, params):
nonlocal recv_params
recv_params = params
recv_params = NotImplemented
- MySink.query_info('allo', None)
+ MySink.query('allo', None)
self.assertIsNone(recv_params)
- def test_query_info_gets_same_params(self):
+ def test_query_gets_same_params(self):
class MySink(bt2.UserSinkComponent):
def _consume(self):
pass
@staticmethod
- def _query_info(action, params):
+ def _query(obj, params):
nonlocal recv_params
recv_params = params
recv_params = NotImplemented
params = bt2.create_value(23)
- MySink.query_info('allo', params)
+ MySink.query('allo', params)
self.assertEqual(recv_params.addr, params.addr)
- def test_query_info_action(self):
+ def test_query_obj(self):
class MySink(bt2.UserSinkComponent):
def _consume(self):
pass
@staticmethod
- def _query_info(action, params):
- nonlocal recv_action
- recv_action = action
+ def _query(obj, params):
+ nonlocal recv_obj
+ recv_obj = obj
- recv_action = None
- MySink.query_info('salut')
- self.assertEqual(recv_action, 'salut')
+ recv_obj = None
+ MySink.query('salut')
+ self.assertEqual(recv_obj, 'salut')
- def test_query_info_returns_none(self):
+ def test_query_returns_none(self):
class MySink(bt2.UserSinkComponent):
def _consume(self):
pass
@staticmethod
- def _query_info(action, params):
+ def _query(obj, params):
pass
- self.assertIsNone(MySink.query_info('allo', 177))
+ self.assertIsNone(MySink.query('allo', 177))
- def test_query_info_returns_params(self):
+ def test_query_returns_params(self):
class MySink(bt2.UserSinkComponent):
def _consume(self):
pass
@staticmethod
- def _query_info(action, params):
- return {'action': action, 'params': params}
+ def _query(obj, params):
+ return {'obj': obj, 'params': params}
- results = MySink.query_info('hello', (45, 'lol'))
- self.assertEqual(results['action'], 'hello')
+ results = MySink.query('hello', (45, 'lol'))
+ self.assertEqual(results['obj'], 'hello')
self.assertEqual(results['params'], (45, 'lol'))
def test_init(self):
return BT_NOTIFICATION_ITERATOR_STATUS_OK;
}
-static struct bt_value *query_info_method(
+static struct bt_value *query_method(
struct bt_component_class *component_class,
- const char *action, struct bt_value *params)
+ const char *object, struct bt_value *params)
{
int ret;
struct bt_value *results = bt_value_array_create();
assert(results);
- ret = bt_value_array_append_string(results, action);
+ ret = bt_value_array_append_string(results, object);
assert(ret == 0);
ret = bt_value_array_append(results, params);
assert(ret == 0);
dummy_iterator_destroy_method);
BT_PLUGIN_FILTER_COMPONENT_CLASS_NOTIFICATION_ITERATOR_SEEK_TIME_METHOD(filter,
dummy_iterator_seek_time_method);
-BT_PLUGIN_FILTER_COMPONENT_CLASS_QUERY_INFO_METHOD(filter, query_info_method);
+BT_PLUGIN_FILTER_COMPONENT_CLASS_QUERY_METHOD(filter, query_method);
const char *extra;
struct bt_value *params;
struct bt_value *results;
- struct bt_value *action;
+ struct bt_value *object;
struct bt_value *res_params;
- const char *action_str;
+ const char *object_str;
int ret;
assert(sfs_path);
"bt_plugin_get_component_class_by_name_and_type() does not find a component class given the wrong type");
params = bt_value_integer_create_init(23);
assert(params);
- ok (!bt_component_class_query_info(NULL, "get-something", params),
- "bt_component_class_query_info() handles NULL (component class)");
- ok (!bt_component_class_query_info(filter_comp_class, NULL, params),
- "bt_component_class_query_info() handles NULL (action)");
- ok (!bt_component_class_query_info(filter_comp_class, "get-something", NULL),
- "bt_component_class_query_info() handles NULL (parameters)");
- results = bt_component_class_query_info(filter_comp_class,
+ ok (!bt_component_class_query(NULL, "get-something", params),
+ "bt_component_class_query() handles NULL (component class)");
+ ok (!bt_component_class_query(filter_comp_class, NULL, params),
+ "bt_component_class_query() handles NULL (object)");
+ ok (!bt_component_class_query(filter_comp_class, "get-something", NULL),
+ "bt_component_class_query() handles NULL (parameters)");
+ results = bt_component_class_query(filter_comp_class,
"get-something", params);
- ok(results, "bt_component_class_query_info() succeeds");
+ ok(results, "bt_component_class_query() succeeds");
assert(bt_value_is_array(results) && bt_value_array_size(results) == 2);
- action = bt_value_array_get(results, 0);
- assert(action && bt_value_is_string(action));
- ret = bt_value_string_get(action, &action_str);
+ object = bt_value_array_get(results, 0);
+ assert(object && bt_value_is_string(object));
+ ret = bt_value_string_get(object, &object_str);
assert(ret == 0);
- ok(strcmp(action_str, "get-something") == 0,
- "bt_component_class_query_info() receives the expected action name");
+ ok(strcmp(object_str, "get-something") == 0,
+ "bt_component_class_query() receives the expected object name");
res_params = bt_value_array_get(results, 1);
ok(res_params == params,
- "bt_component_class_query_info() receives the expected parameters");
+ "bt_component_class_query() receives the expected parameters");
diag("> putting the plugin object here");
BT_PUT(plugin);
free(sfs_path);
free(plugins);
- bt_put(action);
+ bt_put(object);
bt_put(res_params);
bt_put(results);
bt_put(params);