annotate 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
rev   line source
Chris@50 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@50 2
Chris@50 3 /*
Chris@50 4 A waveform viewer and audio annotation editor.
Chris@50 5 Chris Cannam, Queen Mary University of London, 2005-2006
Chris@50 6
Chris@50 7 This is experimental software. Not for distribution.
Chris@50 8 */
Chris@50 9
Chris@50 10 #ifndef _PLUGIN_INSTANCE_H_
Chris@50 11 #define _PLUGIN_INSTANCE_H_
Chris@50 12
Chris@50 13 #include <string>
Chris@50 14 #include <vector>
Chris@50 15
Chris@50 16 /**
Chris@50 17 * A base class for plugins with optional configurable parameters,
Chris@50 18 * programs, etc.
Chris@50 19 *
Chris@50 20 * This does not provide the necessary interfaces to instantiate or
Chris@50 21 * run a plugin -- that depends on the plugin subclass, as different
Chris@50 22 * plugin types may have quite different operating structures. This
Chris@50 23 * class just specifies the necessary interface to show editable
Chris@50 24 * controls for the plugin to the user.
Chris@50 25 */
Chris@50 26
Chris@50 27 class PluginInstance
Chris@50 28 {
Chris@50 29 public:
Chris@50 30 /**
Chris@50 31 * Get the computer-usable name of the plugin. This should be
Chris@50 32 * reasonably short and contain no whitespace or punctuation
Chris@50 33 * characters. It may be shown to the user, but it won't be the
Chris@50 34 * main method for a user to identify a plugin (that will be the
Chris@50 35 * description, below).
Chris@50 36 */
Chris@50 37 virtual std::string getName() const = 0;
Chris@50 38
Chris@50 39 /**
Chris@50 40 * Get a human-readable description of the plugin. This should be
Chris@50 41 * self-contained, as it may be shown to the user in isolation
Chris@50 42 * without also showing the plugin's "name".
Chris@50 43 */
Chris@50 44 virtual std::string getDescription() const = 0;
Chris@50 45
Chris@50 46 /**
Chris@50 47 * Get the name of the author or vendor of the plugin in
Chris@50 48 * human-readable form.
Chris@50 49 */
Chris@50 50 virtual std::string getMaker() const = 0;
Chris@50 51
Chris@50 52 /**
Chris@50 53 * Get the version number of the plugin.
Chris@50 54 */
Chris@50 55 virtual int getPluginVersion() const = 0;
Chris@50 56
Chris@50 57 /**
Chris@50 58 * Get the copyright statement or licensing summary of the plugin.
Chris@50 59 */
Chris@50 60 virtual std::string getCopyright() const = 0;
Chris@50 61
Chris@50 62
Chris@50 63 struct ParameterDescriptor
Chris@50 64 {
Chris@50 65 /**
Chris@50 66 * The name of the parameter, in computer-usable form. Should
Chris@50 67 * be reasonably short and without whitespace or punctuation.
Chris@50 68 */
Chris@50 69 std::string name;
Chris@50 70
Chris@50 71 /**
Chris@50 72 * The human-readable name of the parameter.
Chris@50 73 */
Chris@50 74 std::string description;
Chris@50 75
Chris@50 76 /**
Chris@50 77 * The unit of the parameter, in human-readable form.
Chris@50 78 */
Chris@50 79 std::string unit;
Chris@50 80
Chris@50 81 /**
Chris@50 82 * The minimum value of the parameter.
Chris@50 83 */
Chris@50 84 float minValue;
Chris@50 85
Chris@50 86 /**
Chris@50 87 * The maximum value of the parameter.
Chris@50 88 */
Chris@50 89 float maxValue;
Chris@50 90
Chris@50 91 /**
Chris@50 92 * The default value of the parameter.
Chris@50 93 */
Chris@50 94 float defaultValue;
Chris@50 95
Chris@50 96 /**
Chris@50 97 * True if the parameter values are quantized to a particular
Chris@50 98 * resolution.
Chris@50 99 */
Chris@50 100 bool isQuantized;
Chris@50 101
Chris@50 102 /**
Chris@50 103 * Quantization resolution of the parameter values (e.g. 1.0
Chris@50 104 * if they are all integers). Undefined if isQuantized is
Chris@50 105 * false.
Chris@50 106 */
Chris@50 107 float quantizeStep;
Chris@50 108 };
Chris@50 109
Chris@50 110 typedef std::vector<ParameterDescriptor> ParameterList;
Chris@50 111
Chris@50 112 /**
Chris@50 113 * Get the controllable parameters of this plugin.
Chris@50 114 */
Chris@50 115 virtual ParameterList getParameterDescriptors() const {
Chris@50 116 return ParameterList();
Chris@50 117 }
Chris@50 118
Chris@50 119 /**
Chris@50 120 * Get the value of a named parameter. The argument is the name
Chris@50 121 * field from that parameter's descriptor.
Chris@50 122 */
Chris@50 123 virtual float getParameter(std::string) const { return 0.0; }
Chris@50 124
Chris@50 125 /**
Chris@50 126 * Set a named parameter. The first argument is the name field
Chris@50 127 * from that parameter's descriptor.
Chris@50 128 */
Chris@50 129 virtual void setParameter(std::string, float) { }
Chris@50 130
Chris@50 131
Chris@50 132 typedef std::vector<std::string> ProgramList;
Chris@50 133
Chris@50 134 /**
Chris@50 135 * Get the program settings available in this plugin.
Chris@50 136 * The programs must have unique names.
Chris@50 137 */
Chris@50 138 virtual ProgramList getPrograms() const { return ProgramList(); }
Chris@50 139
Chris@50 140 /**
Chris@50 141 * Get the current program.
Chris@50 142 */
Chris@50 143 virtual std::string getCurrentProgram() const { return ""; }
Chris@50 144
Chris@50 145 /**
Chris@50 146 * Select a program. (If the given program name is not one of the
Chris@50 147 * available programs, do nothing.)
Chris@50 148 */
Chris@50 149 virtual void selectProgram(std::string) { }
Chris@50 150 };
Chris@50 151
Chris@50 152 #endif