2020-12-22 18:10:01 +01:00
|
|
|
#pragma once
|
|
|
|
|
2020-12-27 15:39:06 +01:00
|
|
|
#include <hex.hpp>
|
|
|
|
|
2020-12-22 18:10:01 +01:00
|
|
|
#include "views/view.hpp"
|
2020-12-27 15:39:06 +01:00
|
|
|
#include "providers/provider.hpp"
|
2020-12-22 18:10:01 +01:00
|
|
|
|
|
|
|
#include <string_view>
|
|
|
|
|
|
|
|
namespace hex {
|
|
|
|
|
|
|
|
class Plugin {
|
|
|
|
public:
|
|
|
|
Plugin(std::string_view path);
|
|
|
|
~Plugin();
|
|
|
|
|
2021-01-04 00:19:56 +01:00
|
|
|
void initializePlugin(SharedData &sharedData) const;
|
2020-12-22 18:10:01 +01:00
|
|
|
View* createView() const;
|
|
|
|
void drawToolsEntry() const;
|
|
|
|
|
|
|
|
private:
|
2021-01-04 00:19:56 +01:00
|
|
|
using InitializePluginFunc = void(*)(SharedData &sharedData);
|
2020-12-22 18:10:01 +01:00
|
|
|
using CreateViewFunc = View*(*)();
|
|
|
|
using DrawToolsEntryFunc = void(*)();
|
|
|
|
|
|
|
|
void *m_handle = nullptr;
|
|
|
|
|
2020-12-27 15:39:06 +01:00
|
|
|
InitializePluginFunc m_initializePluginFunction = nullptr;
|
2020-12-22 18:10:01 +01: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;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|