1#ifndef MSTL_PLUGIN_PLUGIN_MANAGER_HPP__
2#define MSTL_PLUGIN_PLUGIN_MANAGER_HPP__
4#include "MSTL/core/container/unordered_map.hpp"
5#include "plugin_entry.hpp"
6#include "dynamic_library.hpp"
9class MSTL_API plugin_manager {
11 using library_ptr = unique_ptr<dynamic_library>;
14 mutable mutex mutex_{};
15 unordered_map<string, plugin_ptr> plugins_{};
16 unordered_map<string, library_ptr> libraries_{};
17 unordered_map<string, string> plugin_to_library_{};
19 plugin_manager() =
default;\
22 plugin_manager(
const plugin_manager&) =
delete;
23 plugin_manager& operator =(
const plugin_manager&) =
delete;
24 plugin_manager(plugin_manager&&) =
delete;
25 plugin_manager& operator =(plugin_manager&&) =
delete;
28 static plugin_manager& instance() {
29 static plugin_manager manager;
33 size_t load_plugins(
const string& dir_path);
34 void load_plugin(string_view filepath);
35 bool unload_plugin(
const string& name);
37 MSTL_NODISCARD iplugin* get_plugin(
const string &name);
38 MSTL_NODISCARD vector<string> list_plugins()
const;
40 void initialize_all();
41 void shutdown_all() noexcept;
#define MSTL_END_NAMESPACE__
结束全局命名空间MSTL
#define MSTL_BEGIN_NAMESPACE__
开始全局命名空间MSTL