Plugin structure
Plugin class
The heart of every plugin is the class deriving from one of the ManiVault base plugin classes (ViewPlugin, AnalysisPlugin, etc.). This class represents an opened instance of that specific plugin. An example plugin class derived from ViewPlugin is shown below:
class ExampleViewPlugin : public ViewPlugin
{
Q_OBJECT
public:
/**
* Constructor
* @param factory Pointer to the plugin factory
*/
ExampleViewPlugin(const PluginFactory* factory) { }
/** Destructor */
~ExampleViewPlugin() override = default;
/** This function is called by the core after the view plugin has been created */
void init() override { }
};
At minimum the plugin class consists of:
A constructor, responsible for initializing the plugin members
A destructor, responsible for correctly cleaning up data if the plugin is closed by the user
An init() function, responsible for initializing the plugin after it has been added to the system
Plugin factory
Factories create plugin and are used for setting up meta data, like names, supported data types, icons, links to README and documentation.
A bare-bone example looks like this:
class ExampleViewPluginFactory : public ViewPluginFactory
{
Q_INTERFACES(mv::plugin::ViewPluginFactory mv::plugin::PluginFactory)
Q_OBJECT
Q_PLUGIN_METADATA(IID "studio.manivault.ExampleViewPlugin"
FILE "PluginInfo.json")
public:
/** Default constructor */
ExampleViewPluginFactory();
/** Creates an instance of the example view plugin */
ViewPlugin* produce() override;
/** Returns the data types that are supported by the example view plugin */
mv::DataTypes supportedDataTypes() const override;
/**
* Get plugin trigger actions given \p datasets
* @param datasets Vector of input datasets
* @return Vector of plugin trigger actions
*/
PluginTriggerActions getPluginTriggerActions(const mv::Datasets& datasets) const override;
};
Plugin Config File
Each plugin must be accompanied by a config file, above called PluginInfo.json.
This file contains meta data which is read at build time.
Example for a Loader type plugin:
{
"name" : "Example Loader",
"menuName" : "Example (.xmp)",
"version" : {
"plugin" : "1.4",
"core" : ["1.3"]
},
"type" : "Loader",
"dependencies" : ["Points"]
}
Required fields:
name: Name of the plugindependencies: Documents runtime dependencies, other ManiVault (data) plugins
Optional:
type: Plugin type, may be handled by CMake helper functionmv_handle_plugin_configversion::plugin: Version of the plugin, is handled by CMake helper functionmv_handle_plugin_configversion::core: Version(s) of the core that this plugin version has been tested againstmenuName: Entry in drop down menus [Only Loader and Writer types]
The CMake helper function mv_handle_plugin_config may be used to automatically append plugin version and the version of the core that the plugin is built against to the plugin library file. When using this function, version::plugin becomes a required field as well.
The CMake entry:
mv_handle_plugin_config(${PROJECT})
will automatically append the plugin version and the core version that is currently build against (not the exact version from the PluginInfo.json) to output library name, e.g. for the ScatterplotPlugin:
ScatterplotPlugin_p1.0.0_c1.4.0.dllon WindowslibScatterplotPlugin_p1.0.0_c1.4.0.dylibon MaclibScatterplotPlugin_p1.0.0_c1.4.0.soon Linux