Mercurial > hg > svcore
diff plugin/PluginInstance.h @ 50:080ad875395a
* Pull out parameter/description query methods from FeatureExtractionPlugin
into new PluginInstance base class
author | Chris Cannam |
---|---|
date | Mon, 20 Mar 2006 12:04:06 +0000 |
parents | |
children | d397ea0a79f5 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/plugin/PluginInstance.h Mon Mar 20 12:04:06 2006 +0000 @@ -0,0 +1,152 @@ +/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ + +/* + A waveform viewer and audio annotation editor. + Chris Cannam, Queen Mary University of London, 2005-2006 + + This is experimental software. Not for distribution. +*/ + +#ifndef _PLUGIN_INSTANCE_H_ +#define _PLUGIN_INSTANCE_H_ + +#include <string> +#include <vector> + +/** + * A base class for plugins with optional configurable parameters, + * programs, etc. + * + * This does not provide the necessary interfaces to instantiate or + * run a plugin -- that depends on the plugin subclass, as different + * plugin types may have quite different operating structures. This + * class just specifies the necessary interface to show editable + * controls for the plugin to the user. + */ + +class PluginInstance +{ +public: + /** + * Get the computer-usable name of the plugin. This should be + * reasonably short and contain no whitespace or punctuation + * characters. It may be shown to the user, but it won't be the + * main method for a user to identify a plugin (that will be the + * description, below). + */ + virtual std::string getName() const = 0; + + /** + * Get a human-readable description of the plugin. This should be + * self-contained, as it may be shown to the user in isolation + * without also showing the plugin's "name". + */ + virtual std::string getDescription() const = 0; + + /** + * Get the name of the author or vendor of the plugin in + * human-readable form. + */ + virtual std::string getMaker() const = 0; + + /** + * Get the version number of the plugin. + */ + virtual int getPluginVersion() const = 0; + + /** + * Get the copyright statement or licensing summary of the plugin. + */ + virtual std::string getCopyright() const = 0; + + + struct ParameterDescriptor + { + /** + * The name of the parameter, in computer-usable form. Should + * be reasonably short and without whitespace or punctuation. + */ + std::string name; + + /** + * The human-readable name of the parameter. + */ + std::string description; + + /** + * The unit of the parameter, in human-readable form. + */ + std::string unit; + + /** + * The minimum value of the parameter. + */ + float minValue; + + /** + * The maximum value of the parameter. + */ + float maxValue; + + /** + * The default value of the parameter. + */ + float defaultValue; + + /** + * True if the parameter values are quantized to a particular + * resolution. + */ + bool isQuantized; + + /** + * Quantization resolution of the parameter values (e.g. 1.0 + * if they are all integers). Undefined if isQuantized is + * false. + */ + float quantizeStep; + }; + + typedef std::vector<ParameterDescriptor> ParameterList; + + /** + * Get the controllable parameters of this plugin. + */ + virtual ParameterList getParameterDescriptors() const { + return ParameterList(); + } + + /** + * Get the value of a named parameter. The argument is the name + * field from that parameter's descriptor. + */ + virtual float getParameter(std::string) const { return 0.0; } + + /** + * Set a named parameter. The first argument is the name field + * from that parameter's descriptor. + */ + virtual void setParameter(std::string, float) { } + + + typedef std::vector<std::string> ProgramList; + + /** + * Get the program settings available in this plugin. + * The programs must have unique names. + */ + virtual ProgramList getPrograms() const { return ProgramList(); } + + /** + * Get the current program. + */ + virtual std::string getCurrentProgram() const { return ""; } + + /** + * Select a program. (If the given program name is not one of the + * available programs, do nothing.) + */ + virtual void selectProgram(std::string) { } +}; + +#endif