OpenCPN Partial API docs
|
PluginLoader is a backend module without any direct GUI functionality. More...
#include <plugin_loader.h>
Public Member Functions | |
bool | LoadAllPlugIns (bool enabled_plugins, bool keep_orphans=false) |
Update catalog with imported metadata and load all plugin library files. | |
const wxBitmap * | GetPluginDefaultIcon () |
void | SetPluginDefaultIcon (const wxBitmap *bitmap) |
void | SetOnDeactivateCb (std::function< void(const PlugInContainer *)> cb) |
Callback invoked in late stage on deactivating a plugin. | |
void | ShowPreferencesDialog (const PlugInData &pd, wxWindow *parent) |
Display the preferences dialog for a plugin. | |
void | NotifySetupOptionsPlugin (const PlugInData *pic) |
void | RemovePlugin (const PlugInData &pd) |
Remove a plugin from *GetPluginArray(). | |
void | SortPlugins (int(*cmp_func)(PlugInContainer **, PlugInContainer **)) |
Sort GetPluginArray(). | |
bool | UnLoadPlugIn (size_t ix) |
Unload, delete and remove item ix in GetPlugInArray(). | |
bool | UnLoadAllPlugIns () |
Unload allplugins i. | |
bool | DeactivateAllPlugIns () |
Deactivate all plugins. | |
bool | DeactivatePlugIn (PlugInContainer *pic) |
Deactivate given plugin. | |
bool | DeactivatePlugIn (const PlugInData &pic) |
Deactivate given plugin. | |
bool | UpdatePlugIns () |
Update the GetPlugInArray() list by reloading all plugins from disk. | |
void | UpdateManagedPlugins (bool keep_orphans) |
Update all managed plugins i. | |
PlugInContainer * | LoadPlugIn (const wxString &plugin_file) |
Load given plugin file from disk into GetPlugInArray() list. | |
PlugInContainer * | LoadPlugIn (const wxString &plugin_file, PlugInContainer *pic) |
Load given plugin file from disk into GetPlugInArray() list. | |
const ArrayOfPlugIns * | GetPlugInArray () |
Return list of currently loaded plugins. | |
bool | IsPlugInAvailable (const wxString &commonName) |
Return true if a plugin with given name exists in GetPlugInArray() | |
bool | CheckPluginCompatibility (const wxString &plugin_file) |
Check plugin compatibiliet w r t library type. | |
void | SetEnabled (const wxString &common_name, bool enabled) |
Update enabled/disabled state for plugin with given name. | |
void | SetToolboxPanel (const wxString &common_name, bool value) |
Update m_toolbox_panel state for plugin with given name. | |
void | SetSetupOptions (const wxString &common_name, bool value) |
Update m_has_setup_options state for plugin with given name. | |
Static Public Member Functions | |
static PluginLoader * | GetInstance () |
static void | MarkAsLoadable (const std::string &library_path) |
Mark a library file (complete path) as loadable i. | |
static void | UpdatePlugin (PlugInContainer *plugin, const PluginMetadata &md) |
Update PlugInContainer status using data from PluginMetadata and manifest. | |
static std::string | GetPluginVersion (const PlugInData pd, std::function< const PluginMetadata(const std::string &)> get_metadata) |
Return version string for a plugin, possibly with an "Imported" suffix. | |
static PluginMetadata | MetadataByName (const std::string &name) |
Find metadata for given plugin. | |
Public Attributes | |
EventVar | evt_load_directory |
Notified without data when loader starts loading from a new directory. | |
EventVar | evt_load_plugin |
Notified with a PlugInContainer* pointer when a plugin is loaded. | |
EventVar | evt_pluglist_change |
Notified without data when the GetPlugInArray() list is changed. | |
EventVar | evt_deactivate_plugin |
Carries a malloc'ed read-only copy of a PlugInContainer owned: by listener. | |
EventVar | evt_update_chart_types |
Notified without data after all plugins loaded ot updated. | |
EventVar | evt_plugin_loadall_finalize |
Emitted after all plugins are loaded. | |
PluginLoader is a backend module without any direct GUI functionality.
Instead, it generates events listed here. Each event is mirrored by a public variable, by convention having the same name in lower case.
The general usage pattern to process events, here using EVT_LOAD_PLUGIN:
PluginLoader::GetInstance()->evt_load_plugin.listen(this, EVT_LOAD_PLUGIN) Bind(EVT_LOAD_PLUGIN, [&](ObservedEvt ev) { code to run on event... });
The code in plugin_loader uses evt_load_plugin.Notify() to trigger the event. Notify() might have a string or void* argument; these are available as ev.GetString() or ev.GetClientData() . There is a also a generic std::shared_ptr available as using GetSharedPtr();
See: PlugInManager::PlugInManager() in pluginmanager.cpp
Definition at line 151 of file plugin_loader.h.
bool PluginLoader::CheckPluginCompatibility | ( | const wxString & | plugin_file | ) |
Check plugin compatibiliet w r t library type.
Very platform dependent.
Definition at line 1212 of file plugin_loader.cpp.
bool PluginLoader::DeactivateAllPlugIns | ( | ) |
Deactivate all plugins.
Definition at line 1033 of file plugin_loader.cpp.
bool PluginLoader::DeactivatePlugIn | ( | const PlugInData & | pic | ) |
Deactivate given plugin.
Definition at line 867 of file plugin_loader.cpp.
bool PluginLoader::DeactivatePlugIn | ( | PlugInContainer * | pic | ) |
Deactivate given plugin.
Definition at line 855 of file plugin_loader.cpp.
|
static |
Definition at line 340 of file plugin_loader.cpp.
|
inline |
Return list of currently loaded plugins.
Definition at line 266 of file plugin_loader.h.
const wxBitmap * PluginLoader::GetPluginDefaultIcon | ( | ) |
Definition at line 437 of file plugin_loader.cpp.
|
static |
Return version string for a plugin, possibly with an "Imported" suffix.
Definition at line 199 of file plugin_loader.cpp.
bool PluginLoader::IsPlugInAvailable | ( | const wxString & | commonName | ) |
Return true if a plugin with given name exists in GetPlugInArray()
Definition at line 356 of file plugin_loader.cpp.
bool PluginLoader::LoadAllPlugIns | ( | bool | enabled_plugins, |
bool | keep_orphans = false |
||
) |
Update catalog with imported metadata and load all plugin library files.
enabled_plugins | If true, only load enabled plugins |
keep_orphans | If true, don't scrub plugins not available in the catalog. |
Definition at line 466 of file plugin_loader.cpp.
PlugInContainer * PluginLoader::LoadPlugIn | ( | const wxString & | plugin_file | ) |
Load given plugin file from disk into GetPlugInArray() list.
Definition at line 1454 of file plugin_loader.cpp.
PlugInContainer * PluginLoader::LoadPlugIn | ( | const wxString & | plugin_file, |
PlugInContainer * | pic | ||
) |
Load given plugin file from disk into GetPlugInArray() list.
Definition at line 1464 of file plugin_loader.cpp.
|
static |
Mark a library file (complete path) as loadable i.
e., remove possible stamp
Definition at line 195 of file plugin_loader.cpp.
|
static |
Find metadata for given plugin.
Definition at line 907 of file plugin_loader.cpp.
void PluginLoader::NotifySetupOptionsPlugin | ( | const PlugInData * | pic | ) |
Definition at line 371 of file plugin_loader.cpp.
void PluginLoader::RemovePlugin | ( | const PlugInData & | pd | ) |
void PluginLoader::SetEnabled | ( | const wxString & | common_name, |
bool | enabled | ||
) |
Update enabled/disabled state for plugin with given name.
Definition at line 406 of file plugin_loader.cpp.
|
inline |
Callback invoked in late stage on deactivating a plugin.
Definition at line 216 of file plugin_loader.h.
void PluginLoader::SetPluginDefaultIcon | ( | const wxBitmap * | bitmap | ) |
Definition at line 442 of file plugin_loader.cpp.
void PluginLoader::SetSetupOptions | ( | const wxString & | common_name, |
bool | value | ||
) |
Update m_has_setup_options state for plugin with given name.
Definition at line 426 of file plugin_loader.cpp.
void PluginLoader::SetToolboxPanel | ( | const wxString & | common_name, |
bool | value | ||
) |
Update m_toolbox_panel state for plugin with given name.
Definition at line 415 of file plugin_loader.cpp.
void PluginLoader::ShowPreferencesDialog | ( | const PlugInData & | pd, |
wxWindow * | parent | ||
) |
Display the preferences dialog for a plugin.
Definition at line 364 of file plugin_loader.cpp.
void PluginLoader::SortPlugins | ( | int(*)(PlugInContainer **, PlugInContainer **) | cmp_func | ) |
Sort GetPluginArray().
Definition at line 461 of file plugin_loader.cpp.
bool PluginLoader::UnLoadAllPlugIns | ( | ) |
Unload allplugins i.
e., release the dynamic libraries.
Definition at line 1023 of file plugin_loader.cpp.
bool PluginLoader::UnLoadPlugIn | ( | size_t | ix | ) |
Unload, delete and remove item ix in GetPlugInArray().
Definition at line 877 of file plugin_loader.cpp.
void PluginLoader::UpdateManagedPlugins | ( | bool | keep_orphans | ) |
Update all managed plugins i.
e., everything besides system, imported or legacy plugins.
keep_orphans | If true, Keep any inactive/uninstalled managed plugins that are no longer available in the current catalog. Otherwise, remove them. Orphans usuall occur after reverting from Alpha/Beta catalog back to master. |
Definition at line 965 of file plugin_loader.cpp.
|
static |
Update PlugInContainer status using data from PluginMetadata and manifest.
Update PlugInContainer using data from PluginMetadata and manifest.
Definition at line 938 of file plugin_loader.cpp.
bool PluginLoader::UpdatePlugIns | ( | ) |
Update the GetPlugInArray() list by reloading all plugins from disk.
Definition at line 793 of file plugin_loader.cpp.
EventVar PluginLoader::evt_deactivate_plugin |
Carries a malloc'ed read-only copy of a PlugInContainer owned: by listener.
Definition at line 191 of file plugin_loader.h.
EventVar PluginLoader::evt_load_directory |
Notified without data when loader starts loading from a new directory.
Definition at line 176 of file plugin_loader.h.
EventVar PluginLoader::evt_load_plugin |
Notified with a PlugInContainer* pointer when a plugin is loaded.
The pointer should be treated as const and is owned by loader
Definition at line 182 of file plugin_loader.h.
EventVar PluginLoader::evt_plugin_loadall_finalize |
Emitted after all plugins are loaded.
Event carries a std::vector<LoadError> available though GetSharedPtr()
Definition at line 200 of file plugin_loader.h.
EventVar PluginLoader::evt_pluglist_change |
Notified without data when the GetPlugInArray() list is changed.
Definition at line 185 of file plugin_loader.h.
EventVar PluginLoader::evt_update_chart_types |
Notified without data after all plugins loaded ot updated.
Definition at line 194 of file plugin_loader.h.