Cleaning up initial commit and restructured some of the execution flow, fixed returns and reference mgmt

This commit is contained in:
Chris Punches
2025-02-23 03:26:49 -05:00
parent 1ce163ef29
commit 932c40275f
7 changed files with 292 additions and 105 deletions

View File

@@ -2,6 +2,11 @@
#include <string>
#include <vector>
#include "error.hpp"
#include "dpm_interface.hpp"
#include <filesystem>
#include <dlfcn.h>
#include <iostream>
#include <module_interface.hpp>
// Forward declaration to avoid circular dependency
struct CommandArgs;
@@ -9,14 +14,22 @@ struct CommandArgs;
class ModuleLoader {
public:
explicit ModuleLoader(std::string module_path = "/usr/lib/dpm/modules/");
DPMError check_module_path() const;
std::pair<std::vector<std::string>, DPMError> list_available_modules() const;
const std::string& get_module_path() const { return module_path_; }
std::string get_absolute_module_path() const;
DPMError list_available_modules(std::vector<std::string>& modules) const;
DPMError get_module_path(std::string& path) const;
DPMError get_absolute_module_path(std::string& abs_path) const;
// Split into two separate methods
void* load_module(const std::string& module_name) const;
int execute_module(void* module_handle, const std::string& command) const;
// Load and execute methods
DPMError load_module(const std::string& module_name, void*& module_handle) const;
DPMError execute_module(void* module_handle, const std::string& command) const;
// 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;
private:
std::string module_path_;