From: Philippe Proulx Date: Mon, 13 Feb 2017 22:01:33 +0000 (-0500) Subject: Rename "query info" to "query" everywhere, and "action" to "object" X-Git-Tag: v2.0.0-pre1~474 X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=commitdiff_plain;h=a67681c1f02f54bc1f708d449bceb35476024083 Rename "query info" to "query" everywhere, and "action" to "object" A "query" here is a request for a specific named object using or not parameters. This is analogous to a REST (HTTP) GET stateless request: GET /path/to/object?param1=value1¶m2=value2 Also expect the `metadata-info` object in the ctf.fs query method instead of the `get-metadata-info` action. Signed-off-by: Philippe Proulx Signed-off-by: Jérémie Galarneau --- diff --git a/bindings/python/bt2/component.py b/bindings/python/bt2/component.py index ebfe1262..6ee1a145 100644 --- a/bindings/python/bt2/component.py +++ b/bindings/python/bt2/component.py @@ -45,8 +45,8 @@ class _GenericComponentClass(object._Object): 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) @@ -202,8 +202,8 @@ def _trim_docstring(docstring): 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 @@ -211,11 +211,11 @@ def _query_info(comp_cls_ptr, action, params): 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 @@ -430,13 +430,13 @@ class _UserComponentType(type): 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: @@ -449,7 +449,7 @@ class _UserComponentType(type): return results_addr @staticmethod - def _query_info(action, params): + def _query(action, params): # BT catches this and returns NULL to the user raise NotImplementedError diff --git a/bindings/python/bt2/native_btcomponentclass.i b/bindings/python/bt2/native_btcomponentclass.i index 6acfdb6e..4fe24886 100644 --- a/bindings/python/bt2/native_btcomponentclass.i +++ b/bindings/python/bt2/native_btcomponentclass.i @@ -51,7 +51,7 @@ const char *bt_component_class_get_description( 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( @@ -563,14 +563,14 @@ static void bt_py3_cc_destroy(struct bt_component *component) } } -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; @@ -584,13 +584,13 @@ static struct bt_value *bt_py3_cc_query_info( 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; } @@ -621,8 +621,8 @@ 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; } @@ -982,8 +982,7 @@ static int bt_py3_cc_set_optional_attrs_methods(struct bt_component_class *cc, 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; } diff --git a/converter/babeltrace-cfg.c b/converter/babeltrace-cfg.c index 7c688316..e005df2c 100644 --- a/converter/babeltrace-cfg.c +++ b/converter/babeltrace-cfg.c @@ -855,12 +855,12 @@ void bt_config_destroy(struct bt_object *obj) 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: @@ -2362,32 +2362,32 @@ end: 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; } @@ -2669,16 +2669,16 @@ end: * 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"); @@ -2686,16 +2686,16 @@ void print_query_info_usage(FILE *fp) 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 }, @@ -2709,12 +2709,12 @@ static struct poptOption query_info_long_options[] = { }; /* - * 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) @@ -2728,16 +2728,16 @@ struct bt_config *bt_config_query_info_from_args(int argc, const char *argv[], 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; @@ -2745,7 +2745,7 @@ struct bt_config *bt_config_query_info_from_args(int argc, const char *argv[], /* 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; @@ -2762,7 +2762,7 @@ struct bt_config *bt_config_query_info_from_args(int argc, const char *argv[], 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); @@ -2771,10 +2771,10 @@ struct bt_config *bt_config_query_info_from_args(int argc, const char *argv[], } 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: @@ -2782,7 +2782,7 @@ struct bt_config *bt_config_query_info_from_args(int argc, const char *argv[], { 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; @@ -2802,17 +2802,17 @@ struct bt_config *bt_config_query_info_from_args(int argc, const char *argv[], 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; } @@ -2827,7 +2827,7 @@ struct bt_config *bt_config_query_info_from_args(int argc, const char *argv[], break; } case OPT_HELP: - print_query_info_usage(stdout); + print_query_usage(stdout); *retcode = -1; BT_PUT(cfg); goto end; @@ -2841,13 +2841,13 @@ struct bt_config *bt_config_query_info_from_args(int argc, const char *argv[], 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) { @@ -2858,18 +2858,18 @@ struct bt_config *bt_config_query_info_from_args(int argc, const char *argv[], /* * 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; @@ -2882,9 +2882,9 @@ struct bt_config *bt_config_query_info_from_args(int argc, const char *argv[], } 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; } @@ -3954,7 +3954,7 @@ void print_gen_usage(FILE *fp) 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"); } @@ -4013,8 +4013,8 @@ struct bt_config *bt_config_from_args(int argc, const char *argv[], 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 @@ -4067,8 +4067,8 @@ struct bt_config *bt_config_from_args(int argc, const char *argv[], 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; diff --git a/converter/babeltrace-cfg.h b/converter/babeltrace-cfg.h index 6cb375b8..f78fc1ae 100644 --- a/converter/babeltrace-cfg.h +++ b/converter/babeltrace-cfg.h @@ -47,7 +47,7 @@ enum bt_config_command { 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 { @@ -94,14 +94,14 @@ 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; }; diff --git a/converter/babeltrace.c b/converter/babeltrace.c index c94bf967..4b834ad8 100644 --- a/converter/babeltrace.c +++ b/converter/babeltrace.c @@ -335,12 +335,12 @@ void print_cfg_help(struct bt_config *cfg) } 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 @@ -364,8 +364,8 @@ void print_cfg(struct bt_config *cfg) 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); @@ -678,7 +678,7 @@ static void print_plugin_comp_cls_opt(FILE *fh, const char *plugin_name, 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; @@ -689,39 +689,39 @@ static int cmd_query_info(struct bt_config *cfg) 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; @@ -972,11 +972,11 @@ static int print_ctf_metadata(struct bt_config *cfg) 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()); @@ -1164,8 +1164,8 @@ int main(int argc, const char **argv) 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); diff --git a/include/babeltrace/component/component-class-internal.h b/include/babeltrace/component/component-class-internal.h index 7ec59b95..d03ded15 100644 --- a/include/babeltrace/component/component-class-internal.h +++ b/include/babeltrace/component/component-class-internal.h @@ -57,7 +57,7 @@ struct bt_component_class { 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; diff --git a/include/babeltrace/component/component-class.h b/include/babeltrace/component/component-class.h index 9a631be0..6135343e 100644 --- a/include/babeltrace/component/component-class.h +++ b/include/babeltrace/component/component-class.h @@ -73,9 +73,9 @@ typedef enum bt_notification_iterator_status (*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, @@ -120,13 +120,13 @@ extern const char *bt_component_class_get_description( 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. diff --git a/include/babeltrace/plugin/plugin-dev.h b/include/babeltrace/plugin/plugin-dev.h index 975fa286..bf04da73 100644 --- a/include/babeltrace/plugin/plugin-dev.h +++ b/include/babeltrace/plugin/plugin-dev.h @@ -168,7 +168,7 @@ enum __bt_plugin_component_class_descriptor_attribute_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, @@ -204,8 +204,8 @@ struct __bt_plugin_component_class_descriptor_attribute { /* 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; @@ -591,37 +591,37 @@ struct __bt_plugin_component_class_descriptor_attribute { __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 @@ -943,37 +943,37 @@ struct __bt_plugin_component_class_descriptor_attribute { 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 diff --git a/lib/component/component-class.c b/lib/component/component-class.c index 4e337e03..fa71bc94 100644 --- a/lib/component/component-class.c +++ b/lib/component/component-class.c @@ -228,18 +228,18 @@ end: 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; @@ -542,19 +542,19 @@ end: 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; diff --git a/lib/plugin/plugin-so.c b/lib/plugin/plugin-so.c index a772ea40..83c5e10e 100644 --- a/lib/plugin/plugin-so.c +++ b/lib/plugin/plugin-so.c @@ -252,7 +252,7 @@ enum bt_plugin_status bt_plugin_so_init( 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; @@ -379,9 +379,9 @@ enum bt_plugin_status bt_plugin_so_init( 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 = @@ -506,9 +506,9 @@ enum bt_plugin_status bt_plugin_so_init( } } - 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); diff --git a/plugins/ctf/fs/fs.c b/plugins/ctf/fs/fs.c index b406ee96..ee0c5606 100644 --- a/plugins/ctf/fs/fs.c +++ b/plugins/ctf/fs/fs.c @@ -738,8 +738,8 @@ error: } 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; @@ -747,7 +747,7 @@ struct bt_value *ctf_fs_query_info(struct bt_component_class *comp_class, 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; @@ -760,7 +760,7 @@ struct bt_value *ctf_fs_query_info(struct bt_component_class *comp_class, 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; } @@ -840,7 +840,7 @@ struct bt_value *ctf_fs_query_info(struct bt_component_class *comp_class, goto error; } } else { - fprintf(stderr, "Unknown query info action `%s`\n", action); + fprintf(stderr, "Unknown query object `%s`\n", object); goto error; } diff --git a/plugins/ctf/fs/fs.h b/plugins/ctf/fs/fs.h index 936cfdd0..80e56c1b 100644 --- a/plugins/ctf/fs/fs.h +++ b/plugins/ctf/fs/fs.h @@ -127,7 +127,7 @@ struct bt_notification *ctf_fs_iterator_get( 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 */ diff --git a/plugins/ctf/plugin.c b/plugins/ctf/plugin.c index f91e1a1b..37d59d0c 100644 --- a/plugins/ctf/plugin.c +++ b/plugins/ctf/plugin.c @@ -40,7 +40,7 @@ BT_PLUGIN_LICENSE("MIT"); 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); diff --git a/tests/bindings/python/bt2/test_comp_notif_iter.py b/tests/bindings/python/bt2/test_comp_notif_iter.py index 0c787f9e..70afebe9 100644 --- a/tests/bindings/python/bt2/test_comp_notif_iter.py +++ b/tests/bindings/python/bt2/test_comp_notif_iter.py @@ -256,91 +256,91 @@ This too: 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): diff --git a/tests/lib/test-plugin-plugins/sfs.c b/tests/lib/test-plugin-plugins/sfs.c index f86b848b..a3b7f84b 100644 --- a/tests/lib/test-plugin-plugins/sfs.c +++ b/tests/lib/test-plugin-plugins/sfs.c @@ -57,15 +57,15 @@ static enum bt_notification_iterator_status dummy_iterator_seek_time_method( 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); @@ -106,4 +106,4 @@ BT_PLUGIN_FILTER_COMPONENT_CLASS_NOTIFICATION_ITERATOR_DESTROY_METHOD(filter, 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); diff --git a/tests/lib/test_plugin.c b/tests/lib/test_plugin.c index 4d54bee6..77e7840f 100644 --- a/tests/lib/test_plugin.c +++ b/tests/lib/test_plugin.c @@ -144,9 +144,9 @@ static void test_sfs(const char *plugin_dir) 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); @@ -194,25 +194,25 @@ static void test_sfs(const char *plugin_dir) "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); @@ -231,7 +231,7 @@ static void test_sfs(const char *plugin_dir) free(sfs_path); free(plugins); - bt_put(action); + bt_put(object); bt_put(res_params); bt_put(results); bt_put(params);