impr: Split up optional provider features into multiple abstract interfaces

This commit is contained in:
WerWolv
2025-07-14 00:37:12 +02:00
parent b94519362c
commit 18e02fbf5c
22 changed files with 155 additions and 124 deletions

View File

@@ -9,7 +9,9 @@
namespace hex::plugin::builtin {
class DiskProvider : public hex::prv::Provider {
class DiskProvider : public prv::Provider,
public prv::IProviderDataDescription,
public prv::IProviderLoadInterface {
public:
DiskProvider() = default;
~DiskProvider() override = default;
@@ -32,7 +34,6 @@ namespace hex::plugin::builtin {
[[nodiscard]] std::string getName() const override;
[[nodiscard]] std::vector<Description> getDataDescription() const override;
[[nodiscard]] bool hasLoadInterface() const override { return true; }
bool drawLoadInterface() override;
void loadSettings(const nlohmann::json &settings) override;

View File

@@ -9,7 +9,10 @@
namespace hex::plugin::builtin {
class FileProvider : public hex::prv::Provider {
class FileProvider : public prv::Provider,
public prv::IProviderDataDescription,
public prv::IProviderFilePicker,
public prv::IProviderMenuItems {
public:
FileProvider() = default;
~FileProvider() override = default;
@@ -31,12 +34,10 @@ namespace hex::plugin::builtin {
void saveAs(const std::fs::path &path) override;
[[nodiscard]] std::string getName() const override;
[[nodiscard]] std::vector<Description> getDataDescription() const override;
std::variant<std::string, i128> queryInformation(const std::string &category, const std::string &argument) override;
[[nodiscard]] bool hasFilePicker() const override { return true; }
[[nodiscard]] std::vector<Description> getDataDescription() const override;
[[nodiscard]] bool handleFilePicker() override;
std::vector<MenuEntry> getMenuEntries() override;
void setPath(const std::fs::path &path);

View File

@@ -12,7 +12,9 @@
namespace hex::plugin::builtin {
class GDBProvider : public hex::prv::CachedProvider {
class GDBProvider : public prv::CachedProvider,
public prv::IProviderDataDescription,
public prv::IProviderLoadInterface {
public:
GDBProvider();
~GDBProvider() override = default;
@@ -37,7 +39,6 @@ namespace hex::plugin::builtin {
[[nodiscard]] bool isConnected() const;
[[nodiscard]] bool hasLoadInterface() const override { return true; }
bool drawLoadInterface() override;
void loadSettings(const nlohmann::json &settings) override;

View File

@@ -6,7 +6,9 @@
namespace hex::plugin::builtin {
class IntelHexProvider : public hex::prv::Provider {
class IntelHexProvider : public hex::prv::Provider,
public hex::prv::IProviderDataDescription,
public hex::prv::IProviderFilePicker {
public:
IntelHexProvider() = default;
~IntelHexProvider() override = default;
@@ -36,7 +38,6 @@ namespace hex::plugin::builtin {
return "hex.builtin.provider.intel_hex";
}
[[nodiscard]] bool hasFilePicker() const override { return true; }
[[nodiscard]] bool handleFilePicker() override;
std::pair<Region, bool> getRegionValidity(u64 address) const override;

View File

@@ -4,7 +4,8 @@
namespace hex::plugin::builtin {
class MemoryFileProvider : public hex::prv::Provider {
class MemoryFileProvider : public hex::prv::Provider,
public prv::IProviderMenuItems {
public:
explicit MemoryFileProvider() = default;
~MemoryFileProvider() override = default;
@@ -28,7 +29,6 @@ namespace hex::plugin::builtin {
void save() override;
[[nodiscard]] std::string getName() const override;
[[nodiscard]] std::vector<Description> getDataDescription() const override { return { }; }
std::vector<MenuEntry> getMenuEntries() override;

View File

@@ -42,7 +42,6 @@ namespace hex::plugin::builtin {
[[nodiscard]] u64 getActualSize() const override { return 0x00; }
[[nodiscard]] std::string getName() const override { return "ImHex"; }
[[nodiscard]] std::vector<Description> getDataDescription() const override { return { }; }
void loadSettings(const nlohmann::json &settings) override { std::ignore = settings; }
[[nodiscard]] nlohmann::json storeSettings(nlohmann::json settings) const override { return settings; }

View File

@@ -23,7 +23,10 @@
namespace hex::plugin::builtin {
class ProcessMemoryProvider : public hex::prv::Provider {
class ProcessMemoryProvider : public prv::Provider,
public prv::IProviderDataDescription,
public prv::IProviderLoadInterface,
public prv::IProviderSidebarInterface {
public:
ProcessMemoryProvider() = default;
~ProcessMemoryProvider() override = default;
@@ -58,10 +61,8 @@ namespace hex::plugin::builtin {
[[nodiscard]] bool open() override;
void close() override;
[[nodiscard]] bool hasLoadInterface() const override { return true; }
[[nodiscard]] bool hasInterface() const override { return true; }
bool drawLoadInterface() override;
void drawInterface() override;
void drawSidebarInterface() override;
void loadSettings(const nlohmann::json &) override {}
[[nodiscard]] nlohmann::json storeSettings(nlohmann::json) const override { return { }; }

View File

@@ -8,7 +8,9 @@
namespace hex::plugin::builtin {
class UDPProvider : public hex::prv::Provider {
class UDPProvider : public hex::prv::Provider,
public hex::prv::IProviderSidebarInterface,
public hex::prv::IProviderLoadInterface {
public:
UDPProvider() = default;
~UDPProvider() override = default;
@@ -24,11 +26,8 @@ namespace hex::plugin::builtin {
[[nodiscard]] u64 getActualSize() const override;
[[nodiscard]] bool hasLoadInterface() const override { return true; }
[[nodiscard]] bool drawLoadInterface() override;
bool hasInterface() const override { return true; }
void drawInterface() override;
void drawSidebarInterface() override;
[[nodiscard]] bool open() override;
void close() override;

View File

@@ -4,7 +4,9 @@
namespace hex::plugin::builtin {
class ViewProvider : public hex::prv::Provider {
class ViewProvider : public prv::Provider,
public prv::IProviderDataDescription,
public prv::IProviderMenuItems {
public:
ViewProvider() = default;
~ViewProvider() override = default;
@@ -48,7 +50,7 @@ namespace hex::plugin::builtin {
void setBaseAddress(u64 address) override { std::ignore = address; }
void setProvider(u64 startAddress, size_t size, hex::prv::Provider *provider);
void setProvider(u64 startAddress, size_t size, Provider *provider);
void setName(const std::string &name);
[[nodiscard]] std::pair<Region, bool> getRegionValidity(u64 address) const override;