2025-02-18 04:10:35 +00:00
|
|
|
#pragma once
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
#include "error.hpp"
|
2025-02-23 08:26:49 +00:00
|
|
|
#include <filesystem>
|
|
|
|
#include <dlfcn.h>
|
|
|
|
#include <iostream>
|
2025-02-23 09:04:50 +00:00
|
|
|
#include "module_interface.hpp"
|
2025-02-18 04:10:35 +00:00
|
|
|
|
|
|
|
class ModuleLoader {
|
|
|
|
public:
|
2025-02-23 09:20:52 +00:00
|
|
|
// initializer
|
2025-02-18 04:10:35 +00:00
|
|
|
explicit ModuleLoader(std::string module_path = "/usr/lib/dpm/modules/");
|
2025-02-23 08:26:49 +00:00
|
|
|
DPMError list_available_modules(std::vector<std::string>& modules) const;
|
|
|
|
DPMError get_module_path(std::string& path) const;
|
2025-02-18 04:10:35 +00:00
|
|
|
|
2025-02-23 08:26:49 +00:00
|
|
|
// Load and execute methods
|
|
|
|
DPMError load_module(const std::string& module_name, void*& module_handle) const;
|
2025-02-23 09:04:50 +00:00
|
|
|
DPMError execute_module(const std::string& module_name, const std::string& command) const;
|
2025-02-23 08:26:49 +00:00
|
|
|
|
|
|
|
// Get module version
|
|
|
|
DPMError get_module_version(void* module_handle, std::string& version) const;
|
|
|
|
|
|
|
|
// Get module description
|
|
|
|
DPMError get_module_description(void* module_handle, std::string& description) const;
|
|
|
|
|
|
|
|
// Check if all required symbols from module_interface.hpp are exported by the module
|
|
|
|
DPMError validate_module_interface(void* module_handle, std::vector<std::string>& missing_symbols) const;
|
2025-02-18 04:10:35 +00:00
|
|
|
|
|
|
|
private:
|
2025-02-23 09:10:51 +00:00
|
|
|
std::string _module_path;
|
2025-02-18 04:10:35 +00:00
|
|
|
};
|