1 #pragma once 2 3 #include <hex.hpp> 4 5 #include <hex/views/view.hpp> 6 #include <hex/providers/provider.hpp> 7 8 #include <string_view> 9 10 namespace hex { 11 12 class Plugin { 13 public: 14 Plugin(std::string_view path); 15 Plugin(const Plugin&) = delete; 16 Plugin(Plugin &&other); 17 ~Plugin(); 18 19 void initializePlugin() const; 20 21 private: 22 using InitializePluginFunc = void(*)(); 23 24 void *m_handle = nullptr; 25 26 InitializePluginFunc m_initializePluginFunction = nullptr; 27 }; 28 29 class PluginHandler { 30 public: 31 PluginHandler() = delete; 32 33 static void load(std::string_view pluginFolder); 34 static void unload(); 35 static void reload(); 36 getPlugins()37 static const auto& getPlugins() { 38 return PluginHandler::s_plugins; 39 } 40 41 private: 42 static inline std::string s_pluginFolder; 43 static inline std::vector<Plugin> s_plugins; 44 }; 45 46 }