HAL
plugin_manager.cpp
Go to the documentation of this file.
2 
3 namespace hal
4 {
6  {
7  auto py_plugin_manager = m.def_submodule("plugin_manager");
8 
9  py_plugin_manager.def("get_plugin_names", &plugin_manager::get_plugin_names, R"(
10  Get the names of all loaded plugins.
11 
12  :returns: The set of plugin names.
13  :rtype: set(str)
14  )");
15 
16  py_plugin_manager.def("load_all_plugins", &plugin_manager::load_all_plugins, py::arg("directory_names") = std::vector<std::filesystem::path>(), R"(
17  Load all plugins in the specified directories.
18  If directory is empty, the default directories will be searched.
19 
20  :param directory_names: A list of directory paths.
21  :type directory_names: pathlib.Path
22  :returns: True on success, false otherwise.
23  :rtype: bool
24  )");
25 
26  py_plugin_manager.def("load", &plugin_manager::load, py::arg("plugin_name"), py::arg("file_path"), R"(
27  Load a single plugin by specifying its name and file path.
28 
29  :param str plugin_name: The desired name that is unique in the framework.
30  :param file_path: The path to the plugin file.
31  :type file_path: pathlib.Path
32  :returns: True on success, false otherwise.
33  :rtype: bool
34  )");
35 
36  py_plugin_manager.def("unload_all_plugins", &plugin_manager::unload_all_plugins, R"(
37  Releases all plugins and their associated resources.
38 
39  :returns: True on success, false otherwise.
40  :rtype: bool
41  )");
42 
43  py_plugin_manager.def("unload", &plugin_manager::unload, py::arg("plugin_name"), R"(
44  Releases a single plugin and its associated ressources.
45 
46  :param str plugin_name: The name of the plugin to unload.
47  :returns: True on success, false otherwise.
48  :rtype: bool
49  )");
50 
51  py_plugin_manager.def(
52  "get_plugin_instance",
53  [](const std::string& plugin_name) -> BasePluginInterface* { return plugin_manager::get_plugin_instance<BasePluginInterface>(plugin_name, true); },
54  py::arg("plugin_name"),
55  R"(
56  Gets the basic interface for a plugin specified by name.
57  By default calls the initialize() function of the plugin.
58 
59  :param str plugin_name: The name of the plugin.
60  :returns: The basic plugin interface.
61  :rtype: hal_py.BasePluginInterface
62  )");
63  }
64 } // namespace hal
void plugin_manager_init(py::module &m)
const Module * module(const Gate *g, const NodeBoxes &boxes)
bool unload(const std::string &plugin_name)
std::set< std::string > get_plugin_names()
bool load_all_plugins(const std::vector< std::filesystem::path > &directory_names)
bool load(const std::string &plugin_name, const std::filesystem::path &file_path_or_empty)