# HG changeset patch # User Chris Cannam # Date 1201284957 0 # Node ID 4bb19132da237ce5aa3da09ca6cc0fd51e436ff4 # Parent 3e3ecb45b6d13e9e1691ca28ff0fef395207a55d * 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 diff -r 3e3ecb45b6d1 -r 4bb19132da23 plugin/transform/FeatureExtractionModelTransformer.cpp --- 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()) { diff -r 3e3ecb45b6d1 -r 4bb19132da23 plugin/transform/Transform.cpp --- 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("::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")); } diff -r 3e3ecb45b6d1 -r 4bb19132da23 plugin/transform/Transform.h --- 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; diff -r 3e3ecb45b6d1 -r 4bb19132da23 plugin/transform/TransformFactory.cpp --- 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;