PluginFactory
The plugin factory is responsible for creating plugins of a certain type. Each plugin must be accompanied by a factory, the example plugins repository contains several examples that show how to achieve this.
Qualified name: mv::plugin::PluginFactory
-
class PluginFactory : public mv::gui::WidgetAction
Subclassed by mv::plugin::AnalysisPluginFactory, mv::plugin::LoaderPluginFactory, mv::plugin::RawDataFactory, mv::plugin::TransformationPluginFactory, mv::plugin::ViewPluginFactory, mv::plugin::WriterPluginFactory
Public Functions
-
PluginFactory(Type type, const QString &title)
Constructor.
- Parameters:
type – The plugin type
title – The plugin factory title
-
~PluginFactory() override = default
No need for custom destructor.
-
virtual void initialize()
Perform post-construction initialization.
-
const QIcon &getCategoryIcon() const
Get plugin category icon.
- Returns:
Category icon
-
virtual QString getGlobalSettingsPrefix() const final
Get settings prefix.
- Returns:
Plugin factory global settings prefix
-
virtual gui::PluginGlobalSettingsGroupAction *getGlobalSettingsGroupAction() const
Get global settings group action.
- Returns:
Pointer to plugin global settings group action (maybe nullptr if plugin does not have global settings)
-
void setGlobalSettingsGroupAction(gui::PluginGlobalSettingsGroupAction *pluginGlobalSettingsGroupAction)
Set plugin global settings group action to
pluginGlobalSettingsGroupAction.- Parameters:
pluginGlobalSettingsGroupAction – Pointer to plugin global settings group action (maybe a nullptr)
-
gui::PluginStatusBarAction *getStatusBarAction() const
Get plugin status bar action.
- Returns:
Pointer to plugin status bar action (maybe nullptr)
-
void setStatusBarAction(gui::PluginStatusBarAction *statusBarAction)
Set plugin status bar action to
statusBarAction.- Parameters:
statusBarAction – Pointer to plugin status bar action (maybe a nullptr)
-
virtual bool hasHelp() const
Get whether the plugin has help information or not.
- Returns:
Boolean determining whether the plugin has help information or not
-
virtual QUrl getReadmeMarkdownUrl() const
Get the read me markdown file URL.
- Returns:
URL of the read me markdown file
-
virtual QUrl getRepositoryUrl() const
Get the URL of the GitHub repository.
- Returns:
URL of the GitHub repository (or readme markdown URL if set)
-
virtual QString getDefaultBranch() const
Get the name of the default branch.
- Returns:
Name of the default branch
-
QString getGuiName() const
Get the menu name of the plugin.
-
void setGuiName(const QString &guiName)
Set the GUI name of the plugin.
- Parameters:
guiName – GUI name of the plugin
-
void setVersion(const util::Version &version)
Set the plugin version to
version.- Parameters:
version – Plugin semantic version
-
bool mayProduce() const
Get whether a plugin may be produced.
- Returns:
Boolean determining whether a plugin may be produced
-
inline virtual mv::DataTypes supportedDataTypes() const
Get the data types that the plugin supports.
- Returns:
Supported data types
-
virtual gui::PluginTriggerAction &getPluginTriggerAction()
Get the trigger action that produces an instance of the plugin.
- Returns:
Reference to a trigger action that produces an instance of the plugin
-
inline virtual gui::PluginTriggerActions getPluginTriggerActions(const Datasets &datasets) const
Get plugin trigger actions given
datasets.- Parameters:
datasets – Vector of input datasets
- Returns:
Vector of plugin trigger actions
-
inline virtual gui::PluginTriggerActions getPluginTriggerActions(const DataTypes &dataTypes) const
Get plugin trigger actions given
dataTypes.- Parameters:
dataTypes – Vector of input data types
- Returns:
Vector of plugin trigger actions
-
void setAllowPluginCreationFromStandardGui(bool allowPluginCreationFromStandardGui)
Set whether the plugin may be produced from the standard GUI to
allowPluginCreationFromStandardGui.- Parameters:
allowPluginCreationFromStandardGui – Boolean determining whether a plugin instance may be created from the standard GUI (e.g. main menu etc.)
-
bool getAllowPluginCreationFromStandardGui() const
Get whether the plugin may be produced from the standard GUI.
- Returns:
Boolean determining whether a plugin instance may be created from the standard GUI (e.g. main menu etc.)
-
inline virtual gui::ScriptTriggerActions getScriptTriggerActions(const Datasets &datasets) const
Get script trigger actions given
datasets.Example:
ScriptTriggerActions scriptTriggerActions; if (datasets.count() == 1 && datasets.first()->getDataType() == PointType) scriptTriggerActions << new ScriptTriggerAction(nullptr, std::make_shared<PythonScript>(“Min”, Script::Type::Analysis, “”, datasets), “Analysis/Min”); return scriptTriggerActions;
- Parameters:
datasets – Vector of input datasets
- Returns:
Vector of script trigger actions
-
std::uint32_t getNumberOfInstances() const
Get number of plugin instances currently loaded.
- Returns:
Number of plugin instances currently loaded
-
void setNumberOfInstances(std::uint32_t numberOfInstances)
Set number of plugin instances currently loaded.
- Parameters:
numberOfInstances – Number of plugin instances currently loaded
-
std::uint32_t getNumberOfInstancesProduced() const
Get number of plugin instances produced in total.
- Returns:
Number of plugin instances produced in total
-
void setNumberOfInstancesProduced(std::uint32_t numberOfInstancesProduced)
Set number of plugin instances produced in total.
- Parameters:
numberOfInstancesProduced – Number of plugin instances produced in total
-
std::uint32_t getMaximumNumberOfInstances() const
Get maximum number of allowed plugin instances.
-
void setMaximumNumberOfInstances(std::uint32_t maximumNumberOfInstances)
Set maximum number of allowed plugin instances.
- Parameters:
maximumNumberOfInstances – Maximum number of allowed plugin instances
-
virtual void viewShortcutMap()
View the shortcut map.
-
PluginMetadata &getPluginMetadata()
Get plugin metadata.
- Returns:
Reference to plugin metadata
-
const PluginMetadata &getPluginMetadata() const
Get plugin metadata.
- Returns:
Reference to plugin metadata
-
void numberOfInstancesChanged(std::uint32_t numberOfInstances)
Signals that the number of instances changed to
numberOfInstances.- Parameters:
numberOfInstances – Number of plugin instances
-
void numberOfInstancesProducedChanged(std::uint32_t numberOfInstancesProduced)
Signals that the number of instances produced in total changed to
numberOfInstancesProduced.- Parameters:
numberOfInstancesProduced – Number of plugin instances produced in total
-
void pluginGlobalSettingsGroupActionChanged(gui::PluginGlobalSettingsGroupAction *pluginGlobalSettingsGroupAction)
Signals that the plugin global settings group action changed to
pluginGlobalSettingsGroupAction.- Parameters:
pluginGlobalSettingsGroupAction – Pointer to plugin global settings group action (maybe a nullptr)
-
void statusBarActionChanged(gui::PluginStatusBarAction *statusBarAction)
Signals that the plugin status bar action changed to
statusBarAction.- Parameters:
statusBarAction – Pointer to plugin status bar action (maybe a nullptr)
-
void pluginTitleChanged(const QString &previousPluginTitle, const QString ¤tPluginTitle)
Signals that the plugin title changed from
previousPluginTitletocurrentPluginTitle.- Parameters:
previousPluginTitle – Previous plugin title
currentPluginTitle – Current plugin title
-
void descriptionChanged(const QString &previousDescription, const QString ¤tDescription)
Signals that the description changed from
previousDescriptiontocurrentDescription.- Parameters:
previousDescription – Previous description
currentDescription – Current description
-
void summaryChanged(const QString &previousSummary, const QString ¤tSummary)
Signals that the summary changed from
previousSummarytocurrentSummary.- Parameters:
previousSummary – Previous summary
currentSummary – Current summary
-
void authorsChanged(const QStringList previousAuthors, const QStringList ¤tAuthors)
Signals that the authors changed from
previousAuthorstocurrentAuthors.- Parameters:
previousAuthors – Previous authors
currentAuthors – Current authors
-
void copyrightNoticeChanged(const QString &previousCopyrightNotice, const QString ¤tCopyrightNotice)
Signals that the copyright notice changed from
previousCopyrightNoticetocurrentCopyrightNotice.- Parameters:
previousCopyrightNotice – Previous copyright notice
currentCopyrightNotice – Current copyright notice
-
void aboutMarkdownChanged(const QString &previousAboutMarkdown, const QString ¤tAboutMarkdown)
Signals that the about text in Markdown format changed from
previousAboutMarkdowntocurrentAboutMarkdown.- Parameters:
previousAboutMarkdown – Previous about text in Markdown format
currentAboutMarkdown – Current about text in Markdown format
Public Static Functions
-
static inline void initializePluginTriggerActions(gui::PluginTriggerActions &pluginTriggerActions)
Initializes a list of plugin trigger actions.
- Parameters:
pluginTriggerActions – List of plugin trigger actions to be initialized
Protected Functions
-
void setCategoryIconByName(const QString &category)
Set category icon by name.
- Parameters:
category – Category name
Protected Static Functions
-
static QStringList getDatasetTypesAsStringList(const Datasets &datasets)
Get sequence of input datasets as a string list.
- Parameters:
datasets – Sequence of input datasets (order in which they were selected in the data hierarchy)
- Returns:
String list of input dataset types
-
static bool areAllDatasetsOfTheSameType(const Datasets &datasets, const DataType &dataType)
Determine whether all datasets are of the same data type.
- Parameters:
datasets – Sequence of input datasets (order in which they were selected in the data hierarchy)
dataType – Type of data
- Returns:
Whether each dataset is of the same data type
-
static std::uint16_t getNumberOfDatasetsForType(const Datasets &datasets, const DataType &dataType)
Get number of datasets for
dataType.- Parameters:
dataType – Data type
- Returns:
Number of datasets of
datasetType
-
PluginFactory(Type type, const QString &title)