NexusForce 1.0.0
A Modern C++ Library with extended functionality, web components, and utility libraries
载入中...
搜索中...
未找到
iplugin.hpp
浏览该文件的文档.
1#ifndef NEFORCE_PLUGIN_IPLUGIN_HPP__
2#define NEFORCE_PLUGIN_IPLUGIN_HPP__
3
11
14NEFORCE_BEGIN_NAMESPACE__
15
21
29 string name;
30 string version;
31 string author;
32 string description;
33 string library_path;
34};
35
36
44struct iplugin {
45 virtual ~iplugin() = default;
46
51 virtual const plugin_info& get_info() const = 0;
52
58 virtual void initialize() = 0;
59
63 virtual void execute() = 0;
64
70 virtual void shutdown() = 0;
71};
72
81public:
82 using deleter_type = void (*)(iplugin*);
83
84private:
85 deleter_type func_ = nullptr;
86
87public:
91 plugin_deleter() noexcept = default;
92
96 ~plugin_deleter() = default;
97
102 explicit plugin_deleter(deleter_type func) noexcept :
103 func_(func) {}
104
105 plugin_deleter(const plugin_deleter&) = delete;
106 plugin_deleter& operator=(const plugin_deleter&) = delete;
107
112 plugin_deleter(plugin_deleter&& other) noexcept :
113 func_(other.func_) {
114 other.func_ = nullptr;
115 }
116
123 func_ = other.func_;
124 other.func_ = nullptr;
125 return *this;
126 }
127
135 if (plugin) {
136 func_(plugin);
137 }
138 }
139
146 plugin_deleter rebind() && noexcept { return plugin_deleter(_NEFORCE move(*this)); }
147};
148
156 // Plugin
158
159NEFORCE_END_NAMESPACE__
160#endif // NEFORCE_PLUGIN_IPLUGIN_HPP__
独占智能指针
NEFORCE_INLINE17 constexpr bool is_nothrow_invocable_v
is_nothrow_invocable的便捷变量模板
unique_ptr< iplugin, plugin_deleter > plugin_ptr
插件唯一指针类型
constexpr Iterator2 move(Iterator1 first, Iterator1 last, Iterator2 result) noexcept(noexcept(inner::__move_aux(first, last, result)))
移动范围元素
字符串类型别名和实用函数
插件接口基类
virtual const plugin_info & get_info() const =0
获取插件信息
virtual void initialize()=0
初始化插件
virtual void execute()=0
执行插件的主要功能
virtual void shutdown()=0
关闭插件
插件自定义删除器
plugin_deleter() noexcept=default
默认构造函数
void operator()(iplugin *plugin) const noexcept(is_nothrow_invocable_v< deleter_type, iplugin * >)
函数调用运算符
void(*)(iplugin *) deleter_type
删除函数类型
plugin_deleter(plugin_deleter &&other) noexcept
移动构造函数
plugin_deleter & operator=(plugin_deleter &&other) noexcept
移动赋值运算符
plugin_deleter rebind() &&noexcept
重新绑定删除器
插件信息结构
string description
插件描述
string name
插件名称
string version
插件版本
string library_path
插件库路径
string author
插件作者
独占智能指针