2020-12-22 17:10:01 +00:00
|
|
|
#pragma once
|
|
|
|
|
2020-12-27 14:39:06 +00:00
|
|
|
#include <hex.hpp>
|
|
|
|
|
2020-12-22 17:10:01 +00:00
|
|
|
#include "views/view.hpp"
|
2020-12-27 14:39:06 +00:00
|
|
|
#include "providers/provider.hpp"
|
2020-12-22 17:10:01 +00:00
|
|
|
|
|
|
|
#include <string_view>
|
|
|
|
|
|
|
|
namespace hex {
|
|
|
|
|
|
|
|
class Plugin {
|
|
|
|
public:
|
|
|
|
Plugin(std::string_view path);
|
|
|
|
~Plugin();
|
|
|
|
|
2021-01-03 23:19:56 +00:00
|
|
|
void initializePlugin(SharedData &sharedData) const;
|
2020-12-22 17:10:01 +00:00
|
|
|
View* createView() const;
|
|
|
|
void drawToolsEntry() const;
|
|
|
|
|
|
|
|
private:
|
2021-01-03 23:19:56 +00:00
|
|
|
using InitializePluginFunc = void(*)(SharedData &sharedData);
|
2020-12-22 17:10:01 +00:00
|
|
|
using CreateViewFunc = View*(*)();
|
|
|
|
using DrawToolsEntryFunc = void(*)();
|
|
|
|
|
|
|
|
void *m_handle = nullptr;
|
|
|
|
|
2020-12-27 14:39:06 +00:00
|
|
|
InitializePluginFunc m_initializePluginFunction = nullptr;
|
2020-12-22 17:10:01 +00:00
|
|
|
CreateViewFunc m_createViewFunction = nullptr;
|
|
|
|
DrawToolsEntryFunc m_drawToolsEntryFunction = nullptr;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
class PluginHandler {
|
|
|
|
public:
|
|
|
|
PluginHandler() = delete;
|
|
|
|
|
|
|
|
static void load(std::string_view pluginFolder);
|
|
|
|
static void unload();
|
|
|
|
static void reload();
|
|
|
|
|
|
|
|
static const auto& getPlugins() {
|
|
|
|
return PluginHandler::s_plugins;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
static inline std::string s_pluginFolder;
|
|
|
|
static inline std::vector<Plugin> s_plugins;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|