|
LogViewer
A modern log viewer with AI-assisted analysis (Qt 6)
|
Manages plugin lifecycle and registration. More...
#include <PluginManager.hpp>

Classes | |
| struct | PluginConfigCache |
Public Member Functions | |
| PluginManager (const PluginManager &)=delete | |
| PluginManager & | operator= (const PluginManager &)=delete |
| void | SetPluginsDirectory (const std::filesystem::path &directory) |
| Sets the plugins directory. | |
| std::filesystem::path | GetPluginsDirectory () const |
| Gets the plugins directory. | |
| std::vector< std::filesystem::path > | DiscoverPlugins () |
| Discovers plugins in the plugins directory. | |
| util::Result< std::string, error::Error > | LoadPlugin (const std::filesystem::path &pluginPath) |
| Loads a plugin from file. | |
| util::Result< bool, error::Error > | UnloadPlugin (const std::string &pluginId) |
| Unloads a plugin and removes it from GetLoadedPlugins() | |
| util::Result< std::string, error::Error > | RegisterPlugin (const std::filesystem::path &sourcePath) |
| Registers a plugin file (copies to user plugins directory) | |
| util::Result< bool, error::Error > | UnregisterPlugin (const std::string &pluginId) |
| Unregisters a plugin (removes from user plugins directory) | |
| IPlugin * | GetPlugin (const std::string &pluginId) |
| Gets a plugin by ID. | |
| const std::map< std::string, PluginLoadInfo > & | GetLoadedPlugins () const |
| Gets all loaded plugins. | |
| std::vector< std::string > | GetPluginsByType (PluginType type) const |
| Gets plugins by type. | |
| util::Result< bool, error::Error > | EnablePlugin (const std::string &pluginId) |
| Enables a plugin (loads and initializes it) | |
| util::Result< bool, error::Error > | DisablePlugin (const std::string &pluginId) |
| Disables a plugin (unloads it but keeps file registered) | |
| void | SetPluginAutoLoad (const std::string &pluginId, bool autoLoad) |
| Sets plugin auto-load preference. | |
| void | RegisterObserver (IPluginObserver *observer) |
| Registers an observer for plugin lifecycle events. | |
| void | UnregisterObserver (IPluginObserver *observer) |
| Unregisters an observer. | |
| util::Result< bool, error::Error > | LoadConfiguration () |
| Loads plugin configuration. | |
| util::Result< bool, error::Error > | SaveConfiguration () |
| Saves plugin configuration. | |
| util::Result< bool, error::Error > | ValidateDependencies () const |
| Validates all plugin dependencies. | |
| std::filesystem::path | GetPluginConfigDirectory (const std::string &pluginId) const |
| Gets the configuration directory path for a specific plugin. | |
| std::filesystem::path | GetPluginConfigPath (const std::string &pluginId) const |
| Gets the configuration file path for a specific plugin. | |
| void | SetEventsContainerOpaque (void *handle) |
| void | SetEventsCallbacks (EventsContainer_GetSize_Fn sizeFn, EventsContainer_GetEventJson_Fn getEventFn) |
| void | SetHostUiCallbacks (void *hostOpaque, const PluginHostUiCallbacks &callbacks) |
Static Public Member Functions | |
| static PluginManager & | GetInstance () |
| Gets singleton instance. | |
Private Member Functions | |
| PluginManager ()=default | |
| ~PluginManager () | |
| util::Result< std::unique_ptr< IPlugin >, error::Error > | LoadPluginLibrary (const std::filesystem::path &path, const std::string &expectedApiVersion, void **outLibraryHandle, void **outPluginOpaqueHandle) |
| Loads plugin from dynamic library. | |
| void | UnloadLibrary (void *handle) |
| Unloads dynamic library. | |
| void | NotifyObservers (PluginEvent event, const std::string &pluginId, IPlugin *plugin) |
| Notifies all observers of a plugin event. | |
Private Attributes | |
| std::filesystem::path | m_pluginsDirectory |
| std::map< std::string, PluginLoadInfo > | m_plugins |
| std::map< std::string, std::filesystem::path > | m_registeredPlugins |
| std::filesystem::path | m_configPath |
| std::vector< IPluginObserver * > | m_observers |
| void * | m_eventsContainerOpaque = nullptr |
| EventsContainer_GetSize_Fn | m_eventsGetSizeFn = nullptr |
| EventsContainer_GetEventJson_Fn | m_eventsGetEventJsonFn = nullptr |
| void * | m_hostUiOpaque = nullptr |
| PluginHostUiCallbacks | m_hostUiCallbacks {0u, nullptr} |
| std::map< std::string, PluginConfigCache > | m_configCache |
| std::vector< void * > | m_dependencyHandles |
Manages plugin lifecycle and registration.
The PluginManager handles:
|
delete |
|
privatedefault |
|
private |

| util::Result< bool, error::Error > plugin::PluginManager::DisablePlugin | ( | const std::string & | pluginId | ) |
Disables a plugin (unloads it but keeps file registered)
| pluginId | Plugin identifier |


| std::vector< std::filesystem::path > plugin::PluginManager::DiscoverPlugins | ( | ) |
Discovers plugins in the plugins directory.

| util::Result< bool, error::Error > plugin::PluginManager::EnablePlugin | ( | const std::string & | pluginId | ) |
Enables a plugin (loads and initializes it)
| pluginId | Plugin identifier |

|
static |
Gets singleton instance.


| const std::map< std::string, PluginLoadInfo > & plugin::PluginManager::GetLoadedPlugins | ( | ) | const |
Gets all loaded plugins.
| IPlugin * plugin::PluginManager::GetPlugin | ( | const std::string & | pluginId | ) |
Gets a plugin by ID.
| pluginId | Plugin identifier |

| std::filesystem::path plugin::PluginManager::GetPluginConfigDirectory | ( | const std::string & | pluginId | ) | const |
Gets the configuration directory path for a specific plugin.
| pluginId | Plugin identifier |


| std::filesystem::path plugin::PluginManager::GetPluginConfigPath | ( | const std::string & | pluginId | ) | const |
Gets the configuration file path for a specific plugin.
| pluginId | Plugin identifier |

| std::vector< std::string > plugin::PluginManager::GetPluginsByType | ( | PluginType | type | ) | const |
Gets plugins by type.
| type | Plugin type filter |
| std::filesystem::path plugin::PluginManager::GetPluginsDirectory | ( | ) | const |
Gets the plugins directory.
| util::Result< bool, error::Error > plugin::PluginManager::LoadConfiguration | ( | ) |
Loads plugin configuration.

| util::Result< std::string, error::Error > plugin::PluginManager::LoadPlugin | ( | const std::filesystem::path & | pluginPath | ) |
Loads a plugin from file.
| pluginPath | Path to plugin library |


|
private |
Loads plugin from dynamic library.
| path | Plugin library path |


|
private |
Notifies all observers of a plugin event.
| event | Type of event |
| pluginId | ID of the plugin |
| plugin | Pointer to plugin instance (nullptr for unload/unregister) |

|
delete |
| void plugin::PluginManager::RegisterObserver | ( | IPluginObserver * | observer | ) |
Registers an observer for plugin lifecycle events.
| observer | Observer to register |


| util::Result< std::string, error::Error > plugin::PluginManager::RegisterPlugin | ( | const std::filesystem::path & | sourcePath | ) |
Registers a plugin file (copies to user plugins directory)
Fails if a plugin with the same id is loaded (unload it first to update). If the id was registered from another folder of the user plugins directory, that superseded folder is deleted once the new copy loads.
| sourcePath | Path to plugin file to register |

| util::Result< bool, error::Error > plugin::PluginManager::SaveConfiguration | ( | ) |
Saves plugin configuration.


|
inline |

|
inline |

|
inline |

| void plugin::PluginManager::SetPluginAutoLoad | ( | const std::string & | pluginId, |
| bool | autoLoad | ||
| ) |
Sets plugin auto-load preference.
| pluginId | Plugin identifier |
| autoLoad | Auto-load on startup |


| void plugin::PluginManager::SetPluginsDirectory | ( | const std::filesystem::path & | directory | ) |
Sets the plugins directory.
| directory | Path to plugins directory |

|
private |
Unloads dynamic library.
| handle | Library handle |


| util::Result< bool, error::Error > plugin::PluginManager::UnloadPlugin | ( | const std::string & | pluginId | ) |
Unloads a plugin and removes it from GetLoadedPlugins()
It stays registered, so EnablePlugin() or LoadPlugin() can load it again.
| pluginId | Plugin identifier |


| void plugin::PluginManager::UnregisterObserver | ( | IPluginObserver * | observer | ) |
Unregisters an observer.
| observer | Observer to unregister |

| util::Result< bool, error::Error > plugin::PluginManager::UnregisterPlugin | ( | const std::string & | pluginId | ) |
Unregisters a plugin (removes from user plugins directory)
| pluginId | Plugin identifier |

| util::Result< bool, error::Error > plugin::PluginManager::ValidateDependencies | ( | ) | const |
Validates all plugin dependencies.

|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |