annotate plugin/PluginInstance.h @ 53:7fcdc6df4853

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