| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- #pragma once
- #include <string>
- #include <vector>
- #include <memory>
- #include <unordered_map>
- #include <filesystem>
- namespace lumacs {
- // Forward declarations
- class EditorCore;
- class LuaApi;
- /// @brief Represents a loaded Lua plugin.
- struct Plugin {
- std::string name;
- std::filesystem::path path;
- // Potentially add more state like loaded status, config table, etc.
- };
- /// @brief Manages the discovery, loading, and unloading of Lua plugins.
- class PluginManager {
- public:
- explicit PluginManager(EditorCore& core, LuaApi& lua_api);
- /// @brief Discovers Lua plugin files in specified directories.
- /// @param plugin_dirs A list of directories to search for plugins.
- void discover_plugins(const std::vector<std::filesystem::path>& plugin_dirs);
- /// @brief Loads a specific plugin by name.
- /// @param name The name of the plugin to load (e.g., "my_plugin").
- /// @return True if the plugin was loaded successfully, false otherwise.
- bool load_plugin(const std::string& name);
- /// @brief Unloads a specific plugin by name.
- /// @param name The name of the plugin to unload.
- /// @return True if the plugin was unloaded successfully, false otherwise.
- bool unload_plugin(const std::string& name);
- /// @brief Gets a list of all discovered plugin names.
- std::vector<std::string> get_discovered_plugins() const;
- /// @brief Gets a list of currently loaded plugin names.
- std::vector<std::string> get_loaded_plugins() const;
- private:
- [[maybe_unused]] EditorCore& core_; // Reserved for future plugin integration
- LuaApi& lua_api_;
- std::unordered_map<std::string, std::filesystem::path> discovered_plugins_;
- std::unordered_map<std::string, Plugin> loaded_plugins_;
- /// @brief Helper to execute a plugin's `on_load` function.
- void execute_on_load(const Plugin& plugin);
- /// @brief Helper to execute a plugin's `on_unload` function.
- void execute_on_unload(const Plugin& plugin);
- };
- } // namespace lumacs
|