From: Simon Marchi Date: Mon, 19 Feb 2024 18:20:44 +0000 (-0500) Subject: cpp-common/bt2: move findAllPluginsFromDir() to `plugin-load.hpp` X-Git-Url: https://git.efficios.com/?p=babeltrace.git;a=commitdiff_plain;h=c40b7b8a76c864db9c74b2ecf6833f52fc7646e0 cpp-common/bt2: move findAllPluginsFromDir() to `plugin-load.hpp` All "find plugin(s)" function will go in that file. Change-Id: Ie81a35d8a253dafef2fd696c64341609b0e4960b Signed-off-by: Simon Marchi Reviewed-on: https://review.lttng.org/c/babeltrace/+/11821 Tested-by: jenkins Reviewed-by: Philippe Proulx --- diff --git a/src/Makefile.am b/src/Makefile.am index 873ccf85..235dab4e 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -135,8 +135,8 @@ cpp_common_libcpp_common_la_SOURCES = \ cpp-common/bt2/message.hpp \ cpp-common/bt2/optional-borrowed-object.hpp \ cpp-common/bt2/plugin-dev.hpp \ + cpp-common/bt2/plugin-load.hpp \ cpp-common/bt2/plugin-set.hpp \ - cpp-common/bt2/plugin.hpp \ cpp-common/bt2/private-query-executor.hpp \ cpp-common/bt2/query-executor.hpp \ cpp-common/bt2/raw-value-proxy.hpp \ diff --git a/src/cpp-common/bt2/plugin-load.hpp b/src/cpp-common/bt2/plugin-load.hpp new file mode 100644 index 00000000..0f3e8d5e --- /dev/null +++ b/src/cpp-common/bt2/plugin-load.hpp @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 EfficiOS, Inc. + * + * SPDX-License-Identifier: MIT + */ + +#ifndef BABELTRACE_CPP_COMMON_BT2_PLUGIN_LOAD_HPP +#define BABELTRACE_CPP_COMMON_BT2_PLUGIN_LOAD_HPP + +#include + +#include "common/common.h" +#include "cpp-common/bt2c/c-string-view.hpp" + +#include "exc.hpp" +#include "plugin-set.hpp" + +namespace bt2 { + +inline ConstPluginSet::Shared findAllPluginsFromDir(const bt2c::CStringView path, + const bool recurse, const bool failOnLoadError) +{ + const bt_plugin_set *pluginSet; + + switch (bt_plugin_find_all_from_dir(path, recurse, failOnLoadError, &pluginSet)) { + case BT_PLUGIN_FIND_ALL_FROM_DIR_STATUS_OK: + return ConstPluginSet::Shared::createWithoutRef(pluginSet); + case BT_PLUGIN_FIND_ALL_FROM_DIR_STATUS_NOT_FOUND: + return ConstPluginSet::Shared {}; + case BT_PLUGIN_FIND_ALL_FROM_DIR_STATUS_MEMORY_ERROR: + throw MemoryError {}; + case BT_PLUGIN_FIND_ALL_FROM_DIR_STATUS_ERROR: + throw Error {}; + } + + bt_common_abort(); +} + +} /* namespace bt2 */ + +#endif /* BABELTRACE_CPP_COMMON_BT2_PLUGIN_LOAD_HPP */ diff --git a/src/cpp-common/bt2/plugin.hpp b/src/cpp-common/bt2/plugin.hpp deleted file mode 100644 index 6d1a71a6..00000000 --- a/src/cpp-common/bt2/plugin.hpp +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2024 EfficiOS, Inc. - * - * SPDX-License-Identifier: MIT - */ - -#ifndef BABELTRACE_CPP_COMMON_BT2_PLUGIN_HPP -#define BABELTRACE_CPP_COMMON_BT2_PLUGIN_HPP - -#include - -#include "common/common.h" -#include "cpp-common/bt2c/c-string-view.hpp" - -#include "exc.hpp" -#include "plugin-set.hpp" - -namespace bt2 { - -inline ConstPluginSet::Shared findAllPluginsFromDir(const bt2c::CStringView path, - const bool recurse, const bool failOnLoadError) -{ - const bt_plugin_set *pluginSet; - - switch (bt_plugin_find_all_from_dir(path, recurse, failOnLoadError, &pluginSet)) { - case BT_PLUGIN_FIND_ALL_FROM_DIR_STATUS_OK: - return ConstPluginSet::Shared::createWithoutRef(pluginSet); - case BT_PLUGIN_FIND_ALL_FROM_DIR_STATUS_NOT_FOUND: - return ConstPluginSet::Shared {}; - case BT_PLUGIN_FIND_ALL_FROM_DIR_STATUS_MEMORY_ERROR: - throw MemoryError {}; - case BT_PLUGIN_FIND_ALL_FROM_DIR_STATUS_ERROR: - throw Error {}; - } - - bt_common_abort(); -} - -} /* namespace bt2 */ - -#endif /* BABELTRACE_CPP_COMMON_BT2_PLUGIN_HPP */ diff --git a/tests/lib/test-plugin-init-fail.cpp b/tests/lib/test-plugin-init-fail.cpp index 8a0fde62..6aac20d0 100644 --- a/tests/lib/test-plugin-init-fail.cpp +++ b/tests/lib/test-plugin-init-fail.cpp @@ -8,7 +8,7 @@ #include "common/common.h" #include "cpp-common/bt2/exc.hpp" -#include "cpp-common/bt2/plugin.hpp" +#include "cpp-common/bt2/plugin-load.hpp" #include "cpp-common/bt2c/c-string-view.hpp" #include "cpp-common/vendor/fmt/core.h"