X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=src%2Flib%2Fplugin%2Fplugin.c;h=547859f89b4f130829d392a4f33e7d56def2d502;hb=1353b066072e6c389ff35853bac83f65597e7a6a;hp=af8dc0924f177e1da3c79268c30f2c00e735ee2c;hpb=d98421f2abfc5adab28ab7ee9b63537a6c7261cc;p=babeltrace.git diff --git a/src/lib/plugin/plugin.c b/src/lib/plugin/plugin.c index af8dc092..547859f8 100644 --- a/src/lib/plugin/plugin.c +++ b/src/lib/plugin/plugin.c @@ -12,6 +12,7 @@ #include "lib/assert-cond.h" #include "common/macros.h" #include "compat/compiler.h" +#include "compat/limits.h" #include "common/common.h" #include #include @@ -152,20 +153,23 @@ void fini_python_plugin_provider(void) { } #endif +BT_EXPORT uint64_t bt_plugin_set_get_plugin_count(const struct bt_plugin_set *plugin_set) { - BT_ASSERT_PRE_DEV_NON_NULL(plugin_set, "Plugin set"); + BT_ASSERT_PRE_DEV_PLUGIN_SET_NON_NULL(plugin_set); return (uint64_t) plugin_set->plugins->len; } +BT_EXPORT 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_DEV_NON_NULL(plugin_set, "Plugin set"); + BT_ASSERT_PRE_DEV_PLUGIN_SET_NON_NULL(plugin_set); BT_ASSERT_PRE_DEV_VALID_INDEX(index, plugin_set->plugins->len); return g_ptr_array_index(plugin_set->plugins, index); } +BT_EXPORT enum bt_plugin_find_all_from_static_status bt_plugin_find_all_from_static( bt_bool fail_on_load_error, const struct bt_plugin_set **plugin_set_out) @@ -177,6 +181,7 @@ enum bt_plugin_find_all_from_static_status bt_plugin_find_all_from_static( (void *) plugin_set_out); } +BT_EXPORT enum bt_plugin_find_all_from_file_status bt_plugin_find_all_from_file( const char *path, bt_bool fail_on_load_error, const struct bt_plugin_set **plugin_set_out) @@ -184,8 +189,8 @@ enum bt_plugin_find_all_from_file_status bt_plugin_find_all_from_file( enum bt_plugin_find_all_from_file_status status; BT_ASSERT_PRE_NO_ERROR(); - BT_ASSERT_PRE_NON_NULL(path, "Path"); - BT_ASSERT_PRE_NON_NULL(path, "Plugin set (output)"); + BT_ASSERT_PRE_NON_NULL("path", path, "Path"); + BT_ASSERT_PRE_PLUGIN_SET_OUT_NON_NULL(path); BT_LOGI("Creating plugins from file: path=\"%s\"", path); /* Try shared object plugins */ @@ -255,6 +260,7 @@ void destroy_gstring(void *data) g_string_free(data, TRUE); } +BT_EXPORT enum bt_plugin_find_all_status bt_plugin_find_all(bt_bool find_in_std_env_var, bt_bool find_in_user_dir, bt_bool find_in_sys_dir, bt_bool find_in_static, bt_bool fail_on_load_error, @@ -268,7 +274,7 @@ enum bt_plugin_find_all_status bt_plugin_find_all(bt_bool find_in_std_env_var, uint64_t dir_i, plugin_i; BT_ASSERT_PRE_NO_ERROR(); - BT_ASSERT_PRE_NON_NULL(plugin_set_out, "Plugin set (output)"); + BT_ASSERT_PRE_PLUGIN_SET_OUT_NON_NULL(plugin_set_out); BT_LOGI("Finding all plugins in standard directories and built-in plugins: " "find-in-std-env-var=%d, find-in-user-dir=%d, " "find-in-sys-dir=%d, find-in-static=%d", @@ -442,6 +448,7 @@ end: return status; } +BT_EXPORT enum bt_plugin_find_status bt_plugin_find(const char *plugin_name, bt_bool find_in_std_env_var, bt_bool find_in_user_dir, bt_bool find_in_sys_dir, bt_bool find_in_static, @@ -452,8 +459,8 @@ enum bt_plugin_find_status bt_plugin_find(const char *plugin_name, uint64_t i; BT_ASSERT_PRE_NO_ERROR(); - BT_ASSERT_PRE_NON_NULL(plugin_name, "Name"); - BT_ASSERT_PRE_NON_NULL(plugin_out, "Plugin (output)"); + BT_ASSERT_PRE_NAME_NON_NULL(plugin_name); + BT_ASSERT_PRE_PLUGIN_OUT_NON_NULL(plugin_out); BT_LOGI("Finding named plugin in standard directories and built-in plugins: " "name=\"%s\", find-in-std-env-var=%d, find-in-user-dir=%d, " "find-in-sys-dir=%d, find-in-static=%d", @@ -646,6 +653,7 @@ end: return status; } +BT_EXPORT enum bt_plugin_find_all_from_dir_status bt_plugin_find_all_from_dir( const char *path, bt_bool recurse, bt_bool fail_on_load_error, const struct bt_plugin_set **plugin_set_out) @@ -654,7 +662,7 @@ enum bt_plugin_find_all_from_dir_status bt_plugin_find_all_from_dir( BT_FUNC_STATUS_OK; BT_ASSERT_PRE_NO_ERROR(); - BT_ASSERT_PRE_NON_NULL(plugin_set_out, "Plugin set (output)"); + BT_ASSERT_PRE_PLUGIN_SET_OUT_NON_NULL(plugin_set_out); BT_LOGI("Creating all plugins in directory: path=\"%s\", recurse=%d", path, recurse); *plugin_set_out = bt_plugin_set_create(); @@ -704,37 +712,43 @@ end: return status; } +BT_EXPORT const char *bt_plugin_get_name(const struct bt_plugin *plugin) { - BT_ASSERT_PRE_DEV_NON_NULL(plugin, "Plugin"); + BT_ASSERT_PRE_DEV_PLUGIN_NON_NULL(plugin); return plugin->info.name_set ? plugin->info.name->str : NULL; } +BT_EXPORT const char *bt_plugin_get_author(const struct bt_plugin *plugin) { - BT_ASSERT_PRE_DEV_NON_NULL(plugin, "Plugin"); + BT_ASSERT_PRE_DEV_PLUGIN_NON_NULL(plugin); return plugin->info.author_set ? plugin->info.author->str : NULL; } +BT_EXPORT const char *bt_plugin_get_license(const struct bt_plugin *plugin) { - BT_ASSERT_PRE_DEV_NON_NULL(plugin, "Plugin"); + BT_ASSERT_PRE_DEV_PLUGIN_NON_NULL(plugin); return plugin->info.license_set ? plugin->info.license->str : NULL; } +BT_EXPORT const char *bt_plugin_get_path(const struct bt_plugin *plugin) { - BT_ASSERT_PRE_DEV_NON_NULL(plugin, "Plugin"); + BT_ASSERT_PRE_DEV_PLUGIN_NON_NULL(plugin); return plugin->info.path_set ? plugin->info.path->str : NULL; } +BT_EXPORT const char *bt_plugin_get_description(const struct bt_plugin *plugin) { - BT_ASSERT_PRE_DEV_NON_NULL(plugin, "Plugin"); + BT_ASSERT_PRE_DEV_PLUGIN_NON_NULL(plugin); return plugin->info.description_set ? plugin->info.description->str : NULL; } +BT_EXPORT 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) @@ -742,7 +756,7 @@ enum bt_property_availability bt_plugin_get_version(const struct bt_plugin *plug enum bt_property_availability avail = BT_PROPERTY_AVAILABILITY_AVAILABLE; - BT_ASSERT_PRE_DEV_NON_NULL(plugin, "Plugin"); + BT_ASSERT_PRE_DEV_PLUGIN_NON_NULL(plugin); if (!plugin->info.version_set) { BT_LIB_LOGD("Plugin's version is not set: %!+l", plugin); @@ -770,21 +784,24 @@ end: return avail; } +BT_EXPORT uint64_t bt_plugin_get_source_component_class_count(const struct bt_plugin *plugin) { - BT_ASSERT_PRE_DEV_NON_NULL(plugin, "Plugin"); + BT_ASSERT_PRE_DEV_PLUGIN_NON_NULL(plugin); return (uint64_t) plugin->src_comp_classes->len; } +BT_EXPORT uint64_t bt_plugin_get_filter_component_class_count(const struct bt_plugin *plugin) { - BT_ASSERT_PRE_DEV_NON_NULL(plugin, "Plugin"); + BT_ASSERT_PRE_DEV_PLUGIN_NON_NULL(plugin); return (uint64_t) plugin->flt_comp_classes->len; } +BT_EXPORT uint64_t bt_plugin_get_sink_component_class_count(const struct bt_plugin *plugin) { - BT_ASSERT_PRE_DEV_NON_NULL(plugin, "Plugin"); + BT_ASSERT_PRE_DEV_PLUGIN_NON_NULL(plugin); return (uint64_t) plugin->sink_comp_classes->len; } @@ -793,11 +810,12 @@ struct bt_component_class *borrow_component_class_by_index( const struct bt_plugin *plugin, GPtrArray *comp_classes, uint64_t index) { - BT_ASSERT_PRE_DEV_NON_NULL(plugin, "Plugin"); + BT_ASSERT_PRE_DEV_PLUGIN_NON_NULL(plugin); BT_ASSERT_PRE_DEV_VALID_INDEX(index, comp_classes->len); return g_ptr_array_index(comp_classes, index); } +BT_EXPORT const struct bt_component_class_source * bt_plugin_borrow_source_component_class_by_index_const( const struct bt_plugin *plugin, uint64_t index) @@ -806,6 +824,7 @@ bt_plugin_borrow_source_component_class_by_index_const( plugin->src_comp_classes, index); } +BT_EXPORT const struct bt_component_class_filter * bt_plugin_borrow_filter_component_class_by_index_const( const struct bt_plugin *plugin, uint64_t index) @@ -814,6 +833,7 @@ bt_plugin_borrow_filter_component_class_by_index_const( plugin->flt_comp_classes, index); } +BT_EXPORT const struct bt_component_class_sink * bt_plugin_borrow_sink_component_class_by_index_const( const struct bt_plugin *plugin, uint64_t index) @@ -830,8 +850,8 @@ struct bt_component_class *borrow_component_class_by_name( struct bt_component_class *comp_class = NULL; size_t i; - BT_ASSERT_PRE_DEV_NON_NULL(plugin, "Plugin"); - BT_ASSERT_PRE_DEV_NON_NULL(name, "Name"); + BT_ASSERT_PRE_DEV_PLUGIN_NON_NULL(plugin); + BT_ASSERT_PRE_DEV_NAME_NON_NULL(name); for (i = 0; i < comp_classes->len; i++) { struct bt_component_class *comp_class_candidate = @@ -850,6 +870,7 @@ struct bt_component_class *borrow_component_class_by_name( return comp_class; } +BT_EXPORT const struct bt_component_class_source * bt_plugin_borrow_source_component_class_by_name_const( const struct bt_plugin *plugin, const char *name) @@ -858,6 +879,7 @@ bt_plugin_borrow_source_component_class_by_name_const( plugin->src_comp_classes, name); } +BT_EXPORT const struct bt_component_class_filter * bt_plugin_borrow_filter_component_class_by_name_const( const struct bt_plugin *plugin, const char *name) @@ -866,6 +888,7 @@ bt_plugin_borrow_filter_component_class_by_name_const( plugin->flt_comp_classes, name); } +BT_EXPORT const struct bt_component_class_sink * bt_plugin_borrow_sink_component_class_by_name_const( const struct bt_plugin *plugin, const char *name) @@ -874,21 +897,25 @@ bt_plugin_borrow_sink_component_class_by_name_const( plugin->sink_comp_classes, name); } +BT_EXPORT void bt_plugin_get_ref(const struct bt_plugin *plugin) { bt_object_get_ref(plugin); } +BT_EXPORT void bt_plugin_put_ref(const struct bt_plugin *plugin) { bt_object_put_ref(plugin); } +BT_EXPORT void bt_plugin_set_get_ref(const struct bt_plugin_set *plugin_set) { bt_object_get_ref(plugin_set); } +BT_EXPORT void bt_plugin_set_put_ref(const struct bt_plugin_set *plugin_set) { bt_object_put_ref(plugin_set);