#pragma once #include #include #include #include #include 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& 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 get_discovered_plugins() const; /// @brief Gets a list of currently loaded plugin names. std::vector get_loaded_plugins() const; private: EditorCore& core_; LuaApi& lua_api_; std::unordered_map discovered_plugins_; std::unordered_map 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