comparison plugin/transform/Transform.h @ 350:d7c41483af8f

* Merge from transforms branch -- switch over to using Transform object properly
author Chris Cannam
date Fri, 07 Dec 2007 16:47:31 +0000
parents 21bd032ae791
children 1c6816220185
comparison
equal deleted inserted replaced
348:edda24bb85fc 350:d7c41483af8f
16 #ifndef _TRANSFORM_H_ 16 #ifndef _TRANSFORM_H_
17 #define _TRANSFORM_H_ 17 #define _TRANSFORM_H_
18 18
19 #include "base/XmlExportable.h" 19 #include "base/XmlExportable.h"
20 #include "base/Window.h" 20 #include "base/Window.h"
21 21 #include "base/RealTime.h"
22 #include <vamp-sdk/RealTime.h>
23 22
24 #include <QString> 23 #include <QString>
25 24
26 typedef QString TransformId; 25 typedef QString TransformId;
26
27 class QXmlAttributes;
27 28
28 namespace Vamp { 29 namespace Vamp {
29 class PluginBase; 30 class PluginBase;
30 } 31 }
31 32
32 class Transform : public XmlExportable 33 class Transform : public XmlExportable
33 { 34 {
34 public: 35 public:
36 /**
37 * Construct a new Transform with default data and no identifier.
38 * The Transform object will be meaningless until some data and an
39 * identifier have been set on it.
40 *
41 * To construct a Transform for use with a particular transform
42 * identifier, use TransformFactory::getDefaultTransformFor.
43 */
35 Transform(); 44 Transform();
45
46 /**
47 * Construct a Transform by parsing the given XML data string.
48 * This is the inverse of toXml.
49 */
50 Transform(QString xml);
51
36 virtual ~Transform(); 52 virtual ~Transform();
37 53
38 void setIdentifier(TransformId id) { m_id = id; } 54 /**
39 TransformId getIdentifier() const { return m_id; } 55 * Compare two Transforms. They only compare equal if every data
56 * element matches.
57 */
58 bool operator==(const Transform &);
59
60 void setIdentifier(TransformId id);
61 TransformId getIdentifier() const;
40 62
41 void setPlugin(QString pluginIdentifier); 63 void setPlugin(QString pluginIdentifier);
42 void setOutput(QString output); 64 void setOutput(QString output);
43 65
44 enum Type { FeatureExtraction, RealTimeEffect }; 66 enum Type { FeatureExtraction, RealTimeEffect };
47 QString getPluginIdentifier() const; 69 QString getPluginIdentifier() const;
48 QString getOutput() const; 70 QString getOutput() const;
49 71
50 typedef std::map<QString, float> ParameterMap; 72 typedef std::map<QString, float> ParameterMap;
51 73
52 ParameterMap getParameters() const { return m_parameters; } 74 const ParameterMap &getParameters() const;
53 void setParameters(const ParameterMap &pm) { m_parameters = pm; } 75 void setParameters(const ParameterMap &pm);
76 void setParameter(QString name, float value);
54 77
55 typedef std::map<QString, QString> ConfigurationMap; 78 typedef std::map<QString, QString> ConfigurationMap;
56 79
57 ConfigurationMap getConfiguration() const { return m_configuration; } 80 const ConfigurationMap &getConfiguration() const;
58 void setConfiguration(const ConfigurationMap &cm) { m_configuration = cm; } 81 void setConfiguration(const ConfigurationMap &cm);
82 void setConfigurationValue(QString name, QString value);
59 83
60 QString getProgram() const { return m_program; } 84 QString getProgram() const;
61 void setProgram(QString program) { m_program = program; } 85 void setProgram(QString program);
62 86
63 size_t getStepSize() const { return m_stepSize; } 87 size_t getStepSize() const;
64 void setStepSize(size_t s) { m_stepSize = s; } 88 void setStepSize(size_t s);
65 89
66 size_t getBlockSize() const { return m_blockSize; } 90 size_t getBlockSize() const;
67 void setBlockSize(size_t s) { m_blockSize = s; } 91 void setBlockSize(size_t s);
68
69 WindowType getWindowType() const { return m_windowType; }
70 void setWindowType(WindowType type) { m_windowType = type; }
71
72 Vamp::RealTime getStartTime() const { return m_startTime; }
73 void setStartTime(Vamp::RealTime t) { m_startTime = t; }
74
75 Vamp::RealTime getDuration() const { return m_duration; } // 0 -> all
76 void setDuration(Vamp::RealTime d) { m_duration = d; }
77 92
78 float getSampleRate() const { return m_sampleRate; } // 0 -> as input 93 WindowType getWindowType() const;
79 void setSampleRate(float rate) { m_sampleRate = rate; } 94 void setWindowType(WindowType type);
95
96 RealTime getStartTime() const;
97 void setStartTime(RealTime t);
98
99 RealTime getDuration() const; // 0 -> all
100 void setDuration(RealTime d);
101
102 float getSampleRate() const; // 0 -> as input
103 void setSampleRate(float rate);
80 104
81 void toXml(QTextStream &stream, QString indent = "", 105 void toXml(QTextStream &stream, QString indent = "",
82 QString extraAttributes = "") const; 106 QString extraAttributes = "") const;
83 107
84 static Transform fromXmlString(QString xml); 108 /**
109 * Set the main transform data from the given XML attributes.
110 * This does not set the parameters or configuration, which are
111 * exported to separate XML elements rather than attributes of the
112 * transform element.
113 */
114 void setFromXmlAttributes(const QXmlAttributes &);
85 115
86 protected: 116 protected:
87 TransformId m_id; // pluginid:output, that is type:soname:label:output 117 TransformId m_id; // pluginid:output, that is type:soname:label:output
88 118
89 static QString createIdentifier 119 static QString createIdentifier
97 ConfigurationMap m_configuration; 127 ConfigurationMap m_configuration;
98 QString m_program; 128 QString m_program;
99 size_t m_stepSize; 129 size_t m_stepSize;
100 size_t m_blockSize; 130 size_t m_blockSize;
101 WindowType m_windowType; 131 WindowType m_windowType;
102 Vamp::RealTime m_startTime; 132 RealTime m_startTime;
103 Vamp::RealTime m_duration; 133 RealTime m_duration;
104 float m_sampleRate; 134 float m_sampleRate;
105 }; 135 };
106 136
107 #endif 137 #endif
108 138