Mercurial > hg > svcore
changeset 366:4bb19132da23
* Add plugin version to Transform record
* Warn when the plugin version being used to restore or regenerate a layer
is not the same as the one originally used to create it
author | Chris Cannam |
---|---|
date | Fri, 25 Jan 2008 18:15:57 +0000 |
parents | 3e3ecb45b6d1 |
children | 722bc705775a |
files | plugin/transform/FeatureExtractionModelTransformer.cpp plugin/transform/Transform.cpp plugin/transform/Transform.h plugin/transform/TransformFactory.cpp |
diffstat | 4 files changed, 50 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/plugin/transform/FeatureExtractionModelTransformer.cpp Thu Jan 24 22:49:19 2008 +0000 +++ b/plugin/transform/FeatureExtractionModelTransformer.cpp Fri Jan 25 18:15:57 2008 +0000 @@ -128,6 +128,21 @@ } } + if (m_transform.getPluginVersion() != "") { + QString pv = QString("%1").arg(m_plugin->getPluginVersion()); + if (pv != m_transform.getPluginVersion()) { + QString vm = tr("Transform was configured for version %1 of plugin \"%2\", but the plugin being used is version %3") + .arg(m_transform.getPluginVersion()) + .arg(pluginId) + .arg(pv); + if (m_message != "") { + m_message = QString("%1; %2").arg(vm).arg(m_message); + } else { + m_message = vm; + } + } + } + Vamp::Plugin::OutputList outputs = m_plugin->getOutputDescriptors(); if (outputs.empty()) {
--- a/plugin/transform/Transform.cpp Thu Jan 24 22:49:19 2008 +0000 +++ b/plugin/transform/Transform.cpp Fri Jan 25 18:15:57 2008 +0000 @@ -236,6 +236,18 @@ } QString +Transform::getPluginVersion() const +{ + return m_pluginVersion; +} + +void +Transform::setPluginVersion(QString version) +{ + m_pluginVersion = version; +} + +QString Transform::getProgram() const { return m_program; @@ -328,16 +340,20 @@ bool haveContent = true; if (m_parameters.empty() && m_configuration.empty()) haveContent = false; - out << QString("<transform id=\"%1\" program=\"%2\" stepSize=\"%3\" blockSize=\"%4\" windowType=\"%5\" startTime=\"%6\" duration=\"%7\" sampleRate=\"%8\" %9") + out << QString("<transform id=\"%1\" pluginVersion=\"%2\" program=\"%3\" stepSize=\"%4\" blockSize=\"%5\" windowType=\"%6\" startTime=\"%7\" duration=\"%8\" sampleRate=\"%9\"") .arg(encodeEntities(m_id)) + .arg(encodeEntities(m_pluginVersion)) .arg(encodeEntities(m_program)) .arg(m_stepSize) .arg(m_blockSize) .arg(encodeEntities(Window<float>::getNameForType(m_windowType).c_str())) .arg(encodeEntities(m_startTime.toString().c_str())) .arg(encodeEntities(m_duration.toString().c_str())) - .arg(m_sampleRate) - .arg(extraAttributes); + .arg(m_sampleRate); + + if (extraAttributes != "") { + out << " " << extraAttributes; + } if (haveContent) { @@ -374,6 +390,10 @@ setIdentifier(attrs.value("id")); } + if (attrs.value("pluginVersion") != "") { + setPluginVersion(attrs.value("pluginVersion")); + } + if (attrs.value("program") != "") { setProgram(attrs.value("program")); }
--- a/plugin/transform/Transform.h Thu Jan 24 22:49:19 2008 +0000 +++ b/plugin/transform/Transform.h Fri Jan 25 18:15:57 2008 +0000 @@ -87,6 +87,9 @@ void setConfiguration(const ConfigurationMap &cm); void setConfigurationValue(QString name, QString value); + QString getPluginVersion() const; + void setPluginVersion(QString version); + QString getProgram() const; void setProgram(QString program); @@ -116,6 +119,13 @@ * This does not set the parameters or configuration, which are * exported to separate XML elements rather than attributes of the * transform element. + * + * Note that this only sets those attributes which are actually + * present in the argument. Any attributes not defined in the + * attribute will remain unchanged in the Transform. If your aim + * is to create a transform exactly matching the given attributes, + * ensure you start from an empty transform rather than one that + * has already been configured. */ void setFromXmlAttributes(const QXmlAttributes &); @@ -131,6 +141,7 @@ ParameterMap m_parameters; ConfigurationMap m_configuration; + QString m_pluginVersion; QString m_program; size_t m_stepSize; size_t m_blockSize;
--- a/plugin/transform/TransformFactory.cpp Thu Jan 24 22:49:19 2008 +0000 +++ b/plugin/transform/TransformFactory.cpp Fri Jan 25 18:15:57 2008 +0000 @@ -449,6 +449,7 @@ Vamp::PluginBase *plugin = instantiateDefaultPluginFor(id, rate); if (plugin) { + t.setPluginVersion(QString("%1").arg(plugin->getPluginVersion())); setParametersFromPlugin(t, plugin); makeContextConsistentWithPlugin(t, plugin); delete plugin;