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