OpenCPN Partial API docs
Loading...
Searching...
No Matches
PluginLoader Class Reference

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.
 
PlugInContainerLoadPlugIn (const wxString &plugin_file)
 Load given plugin file from disk into GetPlugInArray() list.
 
PlugInContainerLoadPlugIn (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 PluginLoaderGetInstance ()
 
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.
 

Detailed Description

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.

Member Function Documentation

◆ CheckPluginCompatibility()

bool PluginLoader::CheckPluginCompatibility ( const wxString &  plugin_file)

Check plugin compatibiliet w r t library type.

Very platform dependent.

Returns
true if library is deemed compatible.

Definition at line 1212 of file plugin_loader.cpp.

◆ DeactivateAllPlugIns()

bool PluginLoader::DeactivateAllPlugIns ( )

Deactivate all plugins.

Definition at line 1033 of file plugin_loader.cpp.

◆ DeactivatePlugIn() [1/2]

bool PluginLoader::DeactivatePlugIn ( const PlugInData pic)

Deactivate given plugin.

Definition at line 867 of file plugin_loader.cpp.

◆ DeactivatePlugIn() [2/2]

bool PluginLoader::DeactivatePlugIn ( PlugInContainer pic)

Deactivate given plugin.

Definition at line 855 of file plugin_loader.cpp.

◆ GetInstance()

PluginLoader * PluginLoader::GetInstance ( )
static

Definition at line 340 of file plugin_loader.cpp.

◆ GetPlugInArray()

const ArrayOfPlugIns * PluginLoader::GetPlugInArray ( )
inline

Return list of currently loaded plugins.

Definition at line 266 of file plugin_loader.h.

◆ GetPluginDefaultIcon()

const wxBitmap * PluginLoader::GetPluginDefaultIcon ( )

Definition at line 437 of file plugin_loader.cpp.

◆ GetPluginVersion()

std::string PluginLoader::GetPluginVersion ( const PlugInData  pd,
std::function< const PluginMetadata(const std::string &)>  get_metadata 
)
static

Return version string for a plugin, possibly with an "Imported" suffix.

Definition at line 199 of file plugin_loader.cpp.

◆ IsPlugInAvailable()

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.

◆ LoadAllPlugIns()

bool PluginLoader::LoadAllPlugIns ( bool  enabled_plugins,
bool  keep_orphans = false 
)

Update catalog with imported metadata and load all plugin library files.

Parameters
enabled_pluginsIf true, only load enabled plugins
keep_orphansIf true, don't scrub plugins not available in the catalog.
Returns
false on load errors, else true.

Definition at line 466 of file plugin_loader.cpp.

◆ LoadPlugIn() [1/2]

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.

◆ LoadPlugIn() [2/2]

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.

◆ MarkAsLoadable()

void PluginLoader::MarkAsLoadable ( const std::string &  library_path)
static

Mark a library file (complete path) as loadable i.

e., remove possible stamp

Definition at line 195 of file plugin_loader.cpp.

◆ MetadataByName()

PluginMetadata PluginLoader::MetadataByName ( const std::string &  name)
static

Find metadata for given plugin.

Definition at line 907 of file plugin_loader.cpp.

◆ NotifySetupOptionsPlugin()

void PluginLoader::NotifySetupOptionsPlugin ( const PlugInData pic)

Definition at line 371 of file plugin_loader.cpp.

◆ RemovePlugin()

void PluginLoader::RemovePlugin ( const PlugInData pd)

Remove a plugin from *GetPluginArray().


Definition at line 447 of file plugin_loader.cpp.

◆ SetEnabled()

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.

◆ SetOnDeactivateCb()

void PluginLoader::SetOnDeactivateCb ( std::function< void(const PlugInContainer *)>  cb)
inline

Callback invoked in late stage on deactivating a plugin.

Definition at line 216 of file plugin_loader.h.

◆ SetPluginDefaultIcon()

void PluginLoader::SetPluginDefaultIcon ( const wxBitmap *  bitmap)

Definition at line 442 of file plugin_loader.cpp.

◆ SetSetupOptions()

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.

◆ SetToolboxPanel()

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.

◆ ShowPreferencesDialog()

void PluginLoader::ShowPreferencesDialog ( const PlugInData pd,
wxWindow *  parent 
)

Display the preferences dialog for a plugin.

Definition at line 364 of file plugin_loader.cpp.

◆ SortPlugins()

void PluginLoader::SortPlugins ( int(*)(PlugInContainer **, PlugInContainer **)  cmp_func)

Sort GetPluginArray().

Definition at line 461 of file plugin_loader.cpp.

◆ UnLoadAllPlugIns()

bool PluginLoader::UnLoadAllPlugIns ( )

Unload allplugins i.

e., release the dynamic libraries.

Definition at line 1023 of file plugin_loader.cpp.

◆ UnLoadPlugIn()

bool PluginLoader::UnLoadPlugIn ( size_t  ix)

Unload, delete and remove item ix in GetPlugInArray().

Definition at line 877 of file plugin_loader.cpp.

◆ UpdateManagedPlugins()

void PluginLoader::UpdateManagedPlugins ( bool  keep_orphans)

Update all managed plugins i.

e., everything besides system, imported or legacy plugins.

Parameters
keep_orphansIf 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.

◆ UpdatePlugin()

void PluginLoader::UpdatePlugin ( PlugInContainer plugin,
const PluginMetadata md 
)
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.

◆ UpdatePlugIns()

bool PluginLoader::UpdatePlugIns ( )

Update the GetPlugInArray() list by reloading all plugins from disk.

Definition at line 793 of file plugin_loader.cpp.

Member Data Documentation

◆ evt_deactivate_plugin

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.

◆ evt_load_directory

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.

◆ evt_load_plugin

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.

◆ evt_plugin_loadall_finalize

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.

◆ evt_pluglist_change

EventVar PluginLoader::evt_pluglist_change

Notified without data when the GetPlugInArray() list is changed.

Definition at line 185 of file plugin_loader.h.

◆ evt_update_chart_types

EventVar PluginLoader::evt_update_chart_types

Notified without data after all plugins loaded ot updated.

Definition at line 194 of file plugin_loader.h.


The documentation for this class was generated from the following files: