}
static
-struct bt_plugin *find_plugin(const char *name)
+const struct bt_plugin *find_plugin(const char *name)
{
int i;
- struct bt_plugin *plugin = NULL;
+ const struct bt_plugin *plugin = NULL;
BT_ASSERT(name);
BT_LOGD("Finding plugin: name=\"%s\"", name);
return plugin;
}
-typedef void *(*plugin_borrow_comp_cls_func_t)(struct bt_plugin *,
+typedef void *(*plugin_borrow_comp_cls_func_t)(const struct bt_plugin *,
const char *);
static
plugin_borrow_comp_cls_func_t plugin_borrow_comp_cls_func)
{
void *comp_class = NULL;
- struct bt_plugin *plugin;
+ const struct bt_plugin *plugin;
BT_LOGD("Finding component class: plugin-name=\"%s\", "
"comp-cls-name=\"%s\"", plugin_name, comp_class_name);
return (void *) find_component_class_from_plugin(plugin_name,
comp_class_name,
(plugin_borrow_comp_cls_func_t)
- bt_plugin_borrow_source_component_class_by_name);
+ bt_plugin_borrow_source_component_class_by_name_const);
}
static
return (void *) find_component_class_from_plugin(plugin_name,
comp_class_name,
(plugin_borrow_comp_cls_func_t)
- bt_plugin_borrow_filter_component_class_by_name);
+ bt_plugin_borrow_filter_component_class_by_name_const);
}
static
return (void *) find_component_class_from_plugin(plugin_name,
comp_class_name,
(plugin_borrow_comp_cls_func_t)
- bt_plugin_borrow_sink_component_class_by_name);
+ bt_plugin_borrow_sink_component_class_by_name_const);
}
static
}
static
-void add_to_loaded_plugins(struct bt_plugin_set *plugin_set)
+void add_to_loaded_plugins(const struct bt_plugin_set *plugin_set)
{
int64_t i;
int64_t count;
BT_ASSERT(count >= 0);
for (i = 0; i < count; i++) {
- struct bt_plugin *plugin =
- bt_plugin_set_borrow_plugin_by_index(plugin_set, i);
- struct bt_plugin *loaded_plugin =
+ const struct bt_plugin *plugin =
+ bt_plugin_set_borrow_plugin_by_index_const(plugin_set, i);
+ const struct bt_plugin *loaded_plugin =
find_plugin(bt_plugin_get_name(plugin));
BT_ASSERT(plugin);
BT_LOGD("Adding plugin to loaded plugins: plugin-path=\"%s\"",
bt_plugin_get_name(plugin));
bt_object_get_ref(plugin);
- g_ptr_array_add(loaded_plugins, plugin);
+ g_ptr_array_add(loaded_plugins, (void *) plugin);
}
}
}
for (i = 0; i < nr_paths; i++) {
const struct bt_value *plugin_path_value = NULL;
const char *plugin_path;
- struct bt_plugin_set *plugin_set;
+ const struct bt_plugin_set *plugin_set;
plugin_path_value =
bt_value_array_borrow_element_by_index_const(
int load_static_plugins(void)
{
int ret = 0;
- struct bt_plugin_set *plugin_set;
+ const struct bt_plugin_set *plugin_set;
BT_LOGI("Loading static plugins.");
plugin_set = bt_plugin_create_all_from_static();
}
static
-void print_plugin_info(struct bt_plugin *plugin)
+void print_plugin_info(const struct bt_plugin *plugin)
{
unsigned int major, minor, patch;
const char *extra;
int cmd_help(struct bt_config *cfg)
{
int ret = 0;
- struct bt_plugin *plugin = NULL;
+ const struct bt_plugin *plugin = NULL;
struct bt_component_class *needed_comp_cls = NULL;
plugin = find_plugin(cfg->cmd_data.help.cfg_component->plugin_name->str);
return ret;
}
-typedef void *(* plugin_borrow_comp_cls_by_index_func_t)(struct bt_plugin *,
+typedef void *(* plugin_borrow_comp_cls_by_index_func_t)(const struct bt_plugin *,
uint64_t);
typedef struct bt_component_class *(* spec_comp_cls_borrow_comp_cls_func_t)(
void *);
-void cmd_list_plugins_print_component_classes(struct bt_plugin *plugin,
+void cmd_list_plugins_print_component_classes(const struct bt_plugin *plugin,
const char *cc_type_name, uint64_t count,
plugin_borrow_comp_cls_by_index_func_t borrow_comp_cls_by_index_func,
spec_comp_cls_borrow_comp_cls_func_t spec_comp_cls_borrow_comp_cls_func)
}
for (i = 0; i < plugins_count; i++) {
- struct bt_plugin *plugin = g_ptr_array_index(loaded_plugins, i);
+ const struct bt_plugin *plugin = g_ptr_array_index(loaded_plugins, i);
component_classes_count +=
bt_plugin_get_source_component_class_count(plugin) +
bt_common_color_reset());
for (i = 0; i < plugins_count; i++) {
- struct bt_plugin *plugin = g_ptr_array_index(loaded_plugins, i);
+ const struct bt_plugin *plugin = g_ptr_array_index(loaded_plugins, i);
printf("\n");
print_plugin_info(plugin);
cmd_list_plugins_print_component_classes(plugin, "Source",
bt_plugin_get_source_component_class_count(plugin),
(plugin_borrow_comp_cls_by_index_func_t)
- bt_plugin_borrow_source_component_class_by_name,
+ bt_plugin_borrow_source_component_class_by_name_const,
(spec_comp_cls_borrow_comp_cls_func_t)
bt_component_class_source_as_component_class);
cmd_list_plugins_print_component_classes(plugin, "Filter",
bt_plugin_get_filter_component_class_count(plugin),
(plugin_borrow_comp_cls_by_index_func_t)
- bt_plugin_borrow_filter_component_class_by_name,
+ bt_plugin_borrow_filter_component_class_by_name_const,
(spec_comp_cls_borrow_comp_cls_func_t)
bt_component_class_filter_as_component_class);
cmd_list_plugins_print_component_classes(plugin, "Sink",
bt_plugin_get_sink_component_class_count(plugin),
(plugin_borrow_comp_cls_by_index_func_t)
- bt_plugin_borrow_sink_component_class_by_name,
+ bt_plugin_borrow_sink_component_class_by_name_const,
(spec_comp_cls_borrow_comp_cls_func_t)
bt_component_class_sink_as_component_class);
}
babeltracepluginincludedir = "$(includedir)/babeltrace/plugin"
babeltraceplugininclude_HEADERS = \
babeltrace/plugin/plugin-dev.h \
- babeltrace/plugin/plugin.h \
- babeltrace/plugin/plugin-set.h
+ babeltrace/plugin/plugin-const.h \
+ babeltrace/plugin/plugin-set-const.h
# Graph, component, and notification API
babeltracegraphincludedir = "$(includedir)/babeltrace/graph"
#include <babeltrace/trace-ir/trace.h>
/* Plugin and plugin development API */
+#include <babeltrace/plugin/plugin-const.h>
#include <babeltrace/plugin/plugin-dev.h>
-#include <babeltrace/plugin/plugin-set.h>
-#include <babeltrace/plugin/plugin.h>
+#include <babeltrace/plugin/plugin-set-const.h>
/* Graph, component, and notification API */
#include <babeltrace/graph/component-class-filter.h>
* Graph. The parameter type is `struct bt_graph *`.
*
* `l`:
- * Plugin. The parameter type is `struct bt_plugin *`.
+ * Plugin. The parameter type is `const struct bt_plugin *`.
*
* `o`:
* Object pool. The parameter type is `struct bt_object_pool *`.
--- /dev/null
+#ifndef BABELTRACE_PLUGIN_PLUGIN_CONST_H
+#define BABELTRACE_PLUGIN_PLUGIN_CONST_H
+
+/*
+ * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ * Copyright 2017 Philippe Proulx <pproulx@efficios.com>
+ *
+ * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <stdint.h>
+#include <stddef.h>
+
+/* For bt_bool */
+#include <babeltrace/types.h>
+
+/* For enum bt_component_class_type */
+#include <babeltrace/graph/component-class.h>
+
+/* For enum bt_component_class_source */
+#include <babeltrace/graph/component-class-source.h>
+
+/* For enum bt_component_class_filter */
+#include <babeltrace/graph/component-class-filter.h>
+
+/* For enum bt_component_class_sink */
+#include <babeltrace/graph/component-class-sink.h>
+
+/* For enum bt_property_availability */
+#include <babeltrace/property.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct bt_plugin;
+struct bt_plugin_set;
+struct bt_component_class;
+struct bt_component_class_source;
+struct bt_component_class_filter;
+struct bt_component_class_sink;
+
+enum bt_plugin_status {
+ BT_PLUGIN_STATUS_OK = 0,
+ BT_PLUGIN_STATUS_ERROR = -1,
+ BT_PLUGIN_STATUS_NOMEM = -12,
+};
+
+extern const struct bt_plugin *bt_plugin_find(const char *plugin_name);
+
+extern const struct bt_plugin_set *bt_plugin_create_all_from_file(
+ const char *path);
+
+extern const struct bt_plugin_set *bt_plugin_create_all_from_dir(
+ const char *path, bt_bool recurse);
+
+extern const struct bt_plugin_set *bt_plugin_create_all_from_static(void);
+
+extern const char *bt_plugin_get_name(const struct bt_plugin *plugin);
+
+extern const char *bt_plugin_get_author(const struct bt_plugin *plugin);
+
+extern const char *bt_plugin_get_license(const struct bt_plugin *plugin);
+
+extern const char *bt_plugin_get_description(const struct bt_plugin *plugin);
+
+extern const char *bt_plugin_get_path(const struct bt_plugin *plugin);
+
+extern enum bt_property_availability bt_plugin_get_version(
+ const struct bt_plugin *plugin, unsigned int *major,
+ unsigned int *minor, unsigned int *patch, const char **extra);
+
+extern uint64_t bt_plugin_get_source_component_class_count(
+ const struct bt_plugin *plugin);
+
+extern uint64_t bt_plugin_get_filter_component_class_count(
+ const struct bt_plugin *plugin);
+
+extern uint64_t bt_plugin_get_sink_component_class_count(
+ const struct bt_plugin *plugin);
+
+extern struct bt_component_class_source *
+bt_plugin_borrow_source_component_class_by_index_const_const(
+ const struct bt_plugin *plugin, uint64_t index);
+
+extern struct bt_component_class_filter *
+bt_plugin_borrow_filter_component_class_by_index_const(
+ const struct bt_plugin *plugin, uint64_t index);
+
+extern struct bt_component_class_sink *
+bt_plugin_borrow_sink_component_class_by_index_const(
+ const struct bt_plugin *plugin, uint64_t index);
+
+extern struct bt_component_class_source *
+bt_plugin_borrow_source_component_class_by_name_const(const struct bt_plugin *plugin,
+ const char *name);
+
+extern struct bt_component_class_filter *
+bt_plugin_borrow_filter_component_class_by_name_const(const struct bt_plugin *plugin,
+ const char *name);
+
+extern struct bt_component_class_sink *
+bt_plugin_borrow_sink_component_class_by_name_const(const struct bt_plugin *plugin,
+ const char *name);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_PLUGIN_PLUGIN_CONST_H */
#include <stdint.h>
/* For enum bt_plugin_status */
-#include <babeltrace/plugin/plugin.h>
+#include <babeltrace/plugin/plugin-const.h>
/* For private component class method type definitions */
#include <babeltrace/graph/private-component-class-source.h>
/* Plugin initialization function type */
typedef enum bt_plugin_status (*bt_plugin_init_func)(
- struct bt_plugin *plugin);
+ const struct bt_plugin *plugin);
/* Plugin exit function type */
typedef enum bt_plugin_status (*bt_plugin_exit_func)(void);
#include <babeltrace/babeltrace-internal.h>
#include <babeltrace/graph/component-class-internal.h>
-#include <babeltrace/plugin/plugin.h>
+#include <babeltrace/plugin/plugin-const.h>
#include <babeltrace/plugin/plugin-dev.h>
#include <babeltrace/plugin/plugin-so-internal.h>
#include <babeltrace/object-internal.h>
--- /dev/null
+#ifndef BABELTRACE_PLUGIN_PLUGIN_SET_CONST_H
+#define BABELTRACE_PLUGIN_PLUGIN_SET_CONST_H
+
+/*
+ * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ * Copyright 2017 Philippe Proulx <pproulx@efficios.com>
+ *
+ * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <stdint.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct bt_plugin;
+struct bt_plugin_set;
+
+extern uint64_t bt_plugin_set_get_plugin_count(
+ const struct bt_plugin_set *plugin_set);
+
+extern const struct bt_plugin *bt_plugin_set_borrow_plugin_by_index_const(
+ const struct bt_plugin_set *plugin_set, uint64_t index);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_PLUGIN_PLUGIN_SET_CONST_H */
+++ /dev/null
-#ifndef BABELTRACE_PLUGIN_PLUGIN_SET_H
-#define BABELTRACE_PLUGIN_PLUGIN_SET_H
-
-/*
- * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- * Copyright 2017 Philippe Proulx <pproulx@efficios.com>
- *
- * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <stdint.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct bt_plugin;
-struct bt_plugin_set;
-
-extern uint64_t bt_plugin_set_get_plugin_count(
- struct bt_plugin_set *plugin_set);
-
-extern struct bt_plugin *bt_plugin_set_borrow_plugin_by_index(
- struct bt_plugin_set *plugin_set, uint64_t index);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_PLUGIN_PLUGIN_SET_H */
+++ /dev/null
-#ifndef BABELTRACE_PLUGIN_PLUGIN_H
-#define BABELTRACE_PLUGIN_PLUGIN_H
-
-/*
- * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- * Copyright 2017 Philippe Proulx <pproulx@efficios.com>
- *
- * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <stdint.h>
-#include <stddef.h>
-
-/* For bt_bool */
-#include <babeltrace/types.h>
-
-/* For enum bt_component_class_type */
-#include <babeltrace/graph/component-class.h>
-
-/* For enum bt_component_class_source */
-#include <babeltrace/graph/component-class-source.h>
-
-/* For enum bt_component_class_filter */
-#include <babeltrace/graph/component-class-filter.h>
-
-/* For enum bt_component_class_sink */
-#include <babeltrace/graph/component-class-sink.h>
-
-/* For enum bt_property_availability */
-#include <babeltrace/property.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct bt_plugin;
-struct bt_plugin_set;
-struct bt_component_class;
-struct bt_component_class_source;
-struct bt_component_class_filter;
-struct bt_component_class_sink;
-
-enum bt_plugin_status {
- BT_PLUGIN_STATUS_OK = 0,
- BT_PLUGIN_STATUS_ERROR = -1,
- BT_PLUGIN_STATUS_NOMEM = -12,
-};
-
-extern struct bt_plugin *bt_plugin_find(const char *plugin_name);
-
-extern struct bt_plugin_set *bt_plugin_create_all_from_file(const char *path);
-
-extern struct bt_plugin_set *bt_plugin_create_all_from_dir(const char *path,
- bt_bool recurse);
-
-extern struct bt_plugin_set *bt_plugin_create_all_from_static(void);
-
-extern const char *bt_plugin_get_name(struct bt_plugin *plugin);
-
-extern const char *bt_plugin_get_author(struct bt_plugin *plugin);
-
-extern const char *bt_plugin_get_license(struct bt_plugin *plugin);
-
-extern const char *bt_plugin_get_description(struct bt_plugin *plugin);
-
-extern const char *bt_plugin_get_path(struct bt_plugin *plugin);
-
-extern enum bt_property_availability bt_plugin_get_version(
- struct bt_plugin *plugin, unsigned int *major,
- unsigned int *minor, unsigned int *patch, const char **extra);
-
-extern uint64_t bt_plugin_get_source_component_class_count(
- struct bt_plugin *plugin);
-
-extern uint64_t bt_plugin_get_filter_component_class_count(
- struct bt_plugin *plugin);
-
-extern uint64_t bt_plugin_get_sink_component_class_count(
- struct bt_plugin *plugin);
-
-extern struct bt_component_class_source *
-bt_plugin_borrow_source_component_class_by_index(
- struct bt_plugin *plugin, uint64_t index);
-
-extern struct bt_component_class_filter *
-bt_plugin_borrow_filter_component_class_by_index(
- struct bt_plugin *plugin, uint64_t index);
-
-extern struct bt_component_class_sink *
-bt_plugin_borrow_sink_component_class_by_index(
- struct bt_plugin *plugin, uint64_t index);
-
-extern struct bt_component_class_source *
-bt_plugin_borrow_source_component_class_by_name(struct bt_plugin *plugin,
- const char *name);
-
-extern struct bt_component_class_filter *
-bt_plugin_borrow_filter_component_class_by_name(struct bt_plugin *plugin,
- const char *name);
-
-extern struct bt_component_class_sink *
-bt_plugin_borrow_sink_component_class_by_name(struct bt_plugin *plugin,
- const char *name);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_PLUGIN_PLUGIN_H */
* SOFTWARE.
*/
-#include <babeltrace/plugin/plugin.h>
+#include <babeltrace/plugin/plugin-const.h>
extern
struct bt_plugin_set *bt_plugin_python_create_all_from_file(const char *path);
}
static inline void format_plugin(char **buf_ch, bool extended,
- const char *prefix, struct bt_plugin *plugin)
+ const char *prefix, const struct bt_plugin *plugin)
{
char tmp_prefix[64];
#include <babeltrace/common-internal.h>
#include <babeltrace/plugin/plugin-internal.h>
#include <babeltrace/plugin/plugin-so-internal.h>
+#include <babeltrace/plugin/plugin-const.h>
#include <babeltrace/graph/component-class.h>
#include <babeltrace/graph/component-class-internal.h>
#include <babeltrace/types.h>
return (uint64_t) plugin_set->plugins->len;
}
-struct bt_plugin *bt_plugin_set_borrow_plugin_by_index(
- struct bt_plugin_set *plugin_set,
- uint64_t index)
+const struct bt_plugin *bt_plugin_set_borrow_plugin_by_index_const(
+ const struct bt_plugin_set *plugin_set, uint64_t index)
{
BT_ASSERT_PRE_NON_NULL(plugin_set, "Plugin set");
BT_ASSERT_PRE_VALID_INDEX(index, plugin_set->plugins->len);
return g_ptr_array_index(plugin_set->plugins, index);
}
-struct bt_plugin_set *bt_plugin_create_all_from_static(void)
+const struct bt_plugin_set *bt_plugin_create_all_from_static(void)
{
/* bt_plugin_so_create_all_from_static() logs errors */
return bt_plugin_so_create_all_from_static();
}
-struct bt_plugin_set *bt_plugin_create_all_from_file(const char *path)
+const struct bt_plugin_set *bt_plugin_create_all_from_file(const char *path)
{
struct bt_plugin_set *plugin_set = NULL;
g_string_free(data, TRUE);
}
-struct bt_plugin *bt_plugin_find(const char *plugin_name)
+const struct bt_plugin *bt_plugin_find(const char *plugin_name)
{
const char *system_plugin_dir;
char *home_plugin_dir = NULL;
const char *envvar;
- struct bt_plugin *plugin = NULL;
- struct bt_plugin_set *plugin_set = NULL;
+ const struct bt_plugin *plugin = NULL;
+ const struct bt_plugin_set *plugin_set = NULL;
GPtrArray *dirs = NULL;
int ret;
size_t i, j;
}
for (j = 0; j < plugin_set->plugins->len; j++) {
- struct bt_plugin *candidate_plugin =
+ const struct bt_plugin *candidate_plugin =
g_ptr_array_index(plugin_set->plugins, j);
if (strcmp(bt_plugin_get_name(candidate_plugin),
plugin_set = bt_plugin_create_all_from_static();
if (plugin_set) {
for (j = 0; j < plugin_set->plugins->len; j++) {
- struct bt_plugin *candidate_plugin =
+ const struct bt_plugin *candidate_plugin =
g_ptr_array_index(plugin_set->plugins, j);
if (strcmp(bt_plugin_get_name(candidate_plugin),
switch (flag) {
case FTW_F:
{
- struct bt_plugin_set *plugins_from_file;
+ const struct bt_plugin_set *plugins_from_file;
if (name[0] == '.') {
/* Skip hidden files */
BT_LIB_LOGD("Adding plugin to plugin set: "
"plugin-path=\"%s\", %![plugin-]+l",
file, plugin);
- bt_plugin_set_add_plugin(append_all_from_dir_info.plugin_set, plugin);
+ bt_plugin_set_add_plugin(
+ append_all_from_dir_info.plugin_set,
+ plugin);
}
bt_object_put_ref(plugins_from_file);
return ret;
}
-struct bt_plugin_set *bt_plugin_create_all_from_dir(const char *path,
+const struct bt_plugin_set *bt_plugin_create_all_from_dir(const char *path,
bt_bool recurse)
{
struct bt_plugin_set *plugin_set;
return plugin_set;
}
-const char *bt_plugin_get_name(struct bt_plugin *plugin)
+const char *bt_plugin_get_name(const struct bt_plugin *plugin)
{
BT_ASSERT_PRE_NON_NULL(plugin, "Plugin");
return plugin->info.name_set ? plugin->info.name->str : NULL;
}
-const char *bt_plugin_get_author(struct bt_plugin *plugin)
+const char *bt_plugin_get_author(const struct bt_plugin *plugin)
{
BT_ASSERT_PRE_NON_NULL(plugin, "Plugin");
return plugin->info.author_set ? plugin->info.author->str : NULL;
}
-const char *bt_plugin_get_license(struct bt_plugin *plugin)
+const char *bt_plugin_get_license(const struct bt_plugin *plugin)
{
BT_ASSERT_PRE_NON_NULL(plugin, "Plugin");
return plugin->info.license_set ? plugin->info.license->str : NULL;
}
-const char *bt_plugin_get_path(struct bt_plugin *plugin)
+const char *bt_plugin_get_path(const struct bt_plugin *plugin)
{
BT_ASSERT_PRE_NON_NULL(plugin, "Plugin");
return plugin->info.path_set ? plugin->info.path->str : NULL;
}
-const char *bt_plugin_get_description(struct bt_plugin *plugin)
+const char *bt_plugin_get_description(const struct bt_plugin *plugin)
{
BT_ASSERT_PRE_NON_NULL(plugin, "Plugin");
return plugin->info.description_set ?
plugin->info.description->str : NULL;
}
-enum bt_property_availability bt_plugin_get_version(struct bt_plugin *plugin,
+enum bt_property_availability bt_plugin_get_version(const struct bt_plugin *plugin,
unsigned int *major, unsigned int *minor, unsigned int *patch,
const char **extra)
{
return avail;
}
-uint64_t bt_plugin_get_source_component_class_count(struct bt_plugin *plugin)
+uint64_t bt_plugin_get_source_component_class_count(const struct bt_plugin *plugin)
{
BT_ASSERT_PRE_NON_NULL(plugin, "Plugin");
return (uint64_t) plugin->src_comp_classes->len;
}
-uint64_t bt_plugin_get_filter_component_class_count(struct bt_plugin *plugin)
+uint64_t bt_plugin_get_filter_component_class_count(const struct bt_plugin *plugin)
{
BT_ASSERT_PRE_NON_NULL(plugin, "Plugin");
return (uint64_t) plugin->flt_comp_classes->len;
}
-uint64_t bt_plugin_get_sink_component_class_count(struct bt_plugin *plugin)
+uint64_t bt_plugin_get_sink_component_class_count(const struct bt_plugin *plugin)
{
BT_ASSERT_PRE_NON_NULL(plugin, "Plugin");
return (uint64_t) plugin->sink_comp_classes->len;
static inline
struct bt_component_class *borrow_component_class_by_index(
- struct bt_plugin *plugin, GPtrArray *comp_classes,
+ const struct bt_plugin *plugin, GPtrArray *comp_classes,
uint64_t index)
{
BT_ASSERT_PRE_NON_NULL(plugin, "Plugin");
struct bt_component_class_source *
-bt_plugin_borrow_source_component_class_by_index(
- struct bt_plugin *plugin, uint64_t index)
+bt_plugin_borrow_source_component_class_by_index_const_const(
+ const struct bt_plugin *plugin, uint64_t index)
{
return (void *) borrow_component_class_by_index(plugin,
plugin->src_comp_classes, index);
}
struct bt_component_class_filter *
-bt_plugin_borrow_filter_component_class_by_index(
- struct bt_plugin *plugin, uint64_t index)
+bt_plugin_borrow_filter_component_class_by_index_const(
+ const struct bt_plugin *plugin, uint64_t index)
{
return (void *) borrow_component_class_by_index(plugin,
plugin->flt_comp_classes, index);
}
struct bt_component_class_sink *
-bt_plugin_borrow_sink_component_class_by_index(
- struct bt_plugin *plugin, uint64_t index)
+bt_plugin_borrow_sink_component_class_by_index_const(
+ const struct bt_plugin *plugin, uint64_t index)
{
return (void *) borrow_component_class_by_index(plugin,
plugin->sink_comp_classes, index);
static inline
struct bt_component_class *borrow_component_class_by_name(
- struct bt_plugin *plugin, GPtrArray *comp_classes,
+ const struct bt_plugin *plugin, GPtrArray *comp_classes,
const char *name)
{
struct bt_component_class *comp_class = NULL;
}
struct bt_component_class_source *
-bt_plugin_borrow_source_component_class_by_name(struct bt_plugin *plugin,
- const char *name)
+bt_plugin_borrow_source_component_class_by_name_const(
+ const struct bt_plugin *plugin, const char *name)
{
return (void *) borrow_component_class_by_name(plugin,
plugin->src_comp_classes, name);
}
struct bt_component_class_filter *
-bt_plugin_borrow_filter_component_class_by_name(struct bt_plugin *plugin,
- const char *name)
+bt_plugin_borrow_filter_component_class_by_name_const(
+ const struct bt_plugin *plugin, const char *name)
{
return (void *) borrow_component_class_by_name(plugin,
plugin->flt_comp_classes, name);
}
struct bt_component_class_sink *
-bt_plugin_borrow_sink_component_class_by_name(struct bt_plugin *plugin,
- const char *name)
+bt_plugin_borrow_sink_component_class_by_name_const(
+ const struct bt_plugin *plugin, const char *name)
{
return (void *) borrow_component_class_by_name(plugin,
plugin->sink_comp_classes, name);
#include <babeltrace/babeltrace-internal.h>
#include <babeltrace/compiler-internal.h>
#include <babeltrace/object.h>
-#include <babeltrace/plugin/plugin.h>
+#include <babeltrace/plugin/plugin-const.h>
#include <babeltrace/plugin/plugin-internal.h>
#include <babeltrace/graph/component-class.h>
#include <babeltrace/graph/component-class-internal.h>
}
static
-struct bt_plugin *bt_plugin_from_python_plugin_info(PyObject *plugin_info)
+const struct bt_plugin *bt_plugin_from_python_plugin_info(PyObject *plugin_info)
{
- struct bt_plugin *plugin = NULL;
+ const struct bt_plugin *plugin = NULL;
PyObject *py_name = NULL;
PyObject *py_author = NULL;
PyObject *py_description = NULL;
struct bt_plugin_set *bt_plugin_python_create_all_from_file(const char *path)
{
struct bt_plugin_set *plugin_set = NULL;
- struct bt_plugin *plugin = NULL;
+ const struct bt_plugin *plugin = NULL;
PyObject *py_plugin_info = NULL;
gchar *basename = NULL;
size_t path_len;
#include <stdlib.h>
#include <glib.h>
-static enum bt_plugin_status plugin_init(struct bt_plugin *plugin)
+static enum bt_plugin_status plugin_init(const struct bt_plugin *plugin)
{
g_setenv("BT_TEST_PLUGIN_INIT_CALLED", "1", 1);
return BT_PLUGIN_STATUS_OK;
static void test_minimal(const char *plugin_dir)
{
- struct bt_plugin_set *plugin_set;
- struct bt_plugin *plugin;
+ const struct bt_plugin_set *plugin_set;
+ const struct bt_plugin *plugin;
char *minimal_path = get_test_plugin_path(plugin_dir, "minimal");
BT_ASSERT(minimal_path);
"plugin's initialization function is called during bt_plugin_create_all_from_file()");
ok(bt_plugin_set_get_plugin_count(plugin_set) == 1,
"bt_plugin_create_all_from_file() returns the expected number of plugins");
- plugin = bt_plugin_set_borrow_plugin_by_index(plugin_set, 0);
+ plugin = bt_plugin_set_borrow_plugin_by_index_const(plugin_set, 0);
ok(strcmp(bt_plugin_get_name(plugin), "test_minimal") == 0,
"bt_plugin_get_name() returns the expected name");
ok(strcmp(bt_plugin_get_description(plugin),
static void test_sfs(const char *plugin_dir)
{
- struct bt_plugin_set *plugin_set;
- struct bt_plugin *plugin;
+ const struct bt_plugin_set *plugin_set;
+ const struct bt_plugin *plugin;
struct bt_component_class_sink *sink_comp_class;
struct bt_component_class_source *source_comp_class;
struct bt_component_class_filter *filter_comp_class;
plugin_set = bt_plugin_create_all_from_file(sfs_path);
BT_ASSERT(plugin_set && bt_plugin_set_get_plugin_count(plugin_set) == 1);
- plugin = bt_plugin_set_borrow_plugin_by_index(plugin_set, 0);
+ plugin = bt_plugin_set_borrow_plugin_by_index_const(plugin_set, 0);
ok(bt_plugin_get_version(plugin, &major, &minor, &patch, &extra) ==
BT_PROPERTY_AVAILABILITY_AVAILABLE,
"bt_plugin_get_version() succeeds when there's a version");
ok(bt_plugin_get_sink_component_class_count(plugin) == 1,
"bt_plugin_get_sink_component_class_count() returns the expected value");
- source_comp_class = bt_plugin_borrow_source_component_class_by_name(
+ source_comp_class = bt_plugin_borrow_source_component_class_by_name_const(
plugin, "source");
ok(source_comp_class,
- "bt_plugin_borrow_source_component_class_by_name() finds a source component class");
+ "bt_plugin_borrow_source_component_class_by_name_const() finds a source component class");
- sink_comp_class = bt_plugin_borrow_sink_component_class_by_name(
+ sink_comp_class = bt_plugin_borrow_sink_component_class_by_name_const(
plugin, "sink");
ok(sink_comp_class,
- "bt_plugin_borrow_sink_component_class_by_name() finds a sink component class");
+ "bt_plugin_borrow_sink_component_class_by_name_const() finds a sink component class");
ok(strcmp(bt_component_class_get_help(
bt_component_class_sink_as_component_class(sink_comp_class)),
"Bacon ipsum dolor amet strip steak cupim pastrami venison shoulder.\n"
"ground round brisket salami cupim pork bresaola turkey bacon boudin.\n") == 0,
"bt_component_class_get_help() returns the expected help text");
- filter_comp_class = bt_plugin_borrow_filter_component_class_by_name(
+ filter_comp_class = bt_plugin_borrow_filter_component_class_by_name_const(
plugin, "filter");
ok(filter_comp_class,
- "bt_plugin_borrow_filter_component_class_by_name() finds a filter component class");
+ "bt_plugin_borrow_filter_component_class_by_name_const() finds a filter component class");
params = bt_value_integer_create_init(23);
BT_ASSERT(params);
ret = bt_private_query_executor_query(query_exec,
static void test_create_all_from_dir(const char *plugin_dir)
{
- struct bt_plugin_set *plugin_set;
+ const struct bt_plugin_set *plugin_set;
diag("create from all test below");
static void test_find(const char *plugin_dir)
{
int ret;
- struct bt_plugin *plugin;
+ const struct bt_plugin *plugin;
char *plugin_path;
ok(!bt_plugin_find(NON_EXISTING_PATH),