MSTL 1.4.0
A Modern C++ Library with extended functionality, web components, and utility libraries
载入中...
搜索中...
未找到
iplugin.hpp
1#ifndef MSTL_PLUGIN_IPLUGIN_HPP__
2#define MSTL_PLUGIN_IPLUGIN_HPP__
3#include "MSTL/core/string/string.hpp"
6
7struct plugin_info {
8 string name;
9 string version;
10 string author;
11 string description;
12 string library_path;
13};
14
15struct iplugin {
16 virtual ~iplugin() = default;
17 virtual const plugin_info& get_info() const = 0;
18 virtual void initialize() = 0;
19 virtual void execute() = 0;
20 virtual void shutdown() = 0;
21};
22
23struct plugin_deleter {
24private:
25 void(* func_)(iplugin*) = nullptr;
26
27public:
28 plugin_deleter() noexcept = default;
29 ~plugin_deleter() = default;
30
31 explicit plugin_deleter(void(* func)(iplugin*)) noexcept : func_(func) {}
32
33 plugin_deleter(const plugin_deleter&) = delete;
34 plugin_deleter& operator =(const plugin_deleter&) = delete;
35 plugin_deleter(plugin_deleter&& pd) noexcept : func_(pd.func_) {
36 pd.func_ = nullptr;
37 }
38 plugin_deleter& operator =(plugin_deleter&& pd) noexcept {
39 func_ = pd.func_;
40 pd.func_ = nullptr;
41 return *this;
42 }
43
44 void operator ()(iplugin* p) const {
45 if (p) func_(p);
46 }
47
48 plugin_deleter rebind() && noexcept {
49 return plugin_deleter(move(*this));
50 }
51};
52
54
56#endif // MSTL_PLUGIN_IPLUGIN_HPP__
独占智能指针
#define MSTL_END_NAMESPACE__
结束全局命名空间MSTL
#define MSTL_BEGIN_NAMESPACE__
开始全局命名空间MSTL
constexpr Iterator2 move(Iterator1 first, Iterator1 last, Iterator2 result)
移动范围元素
constexpr T initialize() noexcept(is_nothrow_default_constructible< T >::value)
返回类型T的默认初始化值
MSTL独占智能指针