# HG changeset patch # User Chris Cannam # Date 1587404747 -3600 # Node ID 6f626cfdba5187f8ef94025bbe8d867bfe1f5b7a # Parent 5b1b03c1d8d47819570f481fc7582e4dbfc3d527 Pull out Provider struct diff -r 5b1b03c1d8d4 -r 6f626cfdba51 files.pri --- a/files.pri Mon Apr 20 15:42:51 2020 +0100 +++ b/files.pri Mon Apr 20 18:45:47 2020 +0100 @@ -109,7 +109,6 @@ data/osc/OSCMessage.h \ data/osc/OSCMessageCallback.h \ data/osc/OSCQueue.h \ - plugin/PluginScan.h \ plugin/DSSIPluginFactory.h \ plugin/DSSIPluginInstance.h \ plugin/FeatureExtractionPluginFactory.h \ @@ -119,7 +118,9 @@ plugin/PiperVampPluginFactory.h \ plugin/PluginIdentifier.h \ plugin/PluginPathSetter.h \ + plugin/PluginScan.h \ plugin/PluginXml.h \ + plugin/Provider.h \ plugin/RealTimePluginFactory.h \ plugin/RealTimePluginInstance.h \ plugin/api/dssi.h \ diff -r 5b1b03c1d8d4 -r 6f626cfdba51 plugin/Provider.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/plugin/Provider.h Mon Apr 20 18:45:47 2020 +0100 @@ -0,0 +1,72 @@ +/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ + +/* + Sonic Visualiser + An audio file viewer and annotation editor. + Centre for Digital Music, Queen Mary, University of London. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. See the file + COPYING included with this distribution for more information. +*/ + +#ifndef SV_PROVIDER_H +#define SV_PROVIDER_H + +#include + +#include + +struct Provider +{ + QString infoUrl; + QString downloadUrl; + + enum DownloadType { + DownloadSourceCode, + DownloadWindows, + DownloadMac, + DownloadLinux32, + DownloadLinux64, + DownloadOther + }; + std::set downloadTypes; + + std::map foundInPacks; // pack name -> pack url + + bool hasSourceDownload() const { + return downloadTypes.find(DownloadSourceCode) != downloadTypes.end(); + } + + bool hasDownloadForThisPlatform() const { +#ifdef Q_OS_WIN32 + return downloadTypes.find(DownloadWindows) != downloadTypes.end(); +#endif +#ifdef Q_OS_MAC + return downloadTypes.find(DownloadMac) != downloadTypes.end(); +#endif +#ifdef Q_OS_LINUX + if (sizeof(void *) == 8) { + return downloadTypes.find(DownloadLinux64) != downloadTypes.end(); + } else { + return downloadTypes.find(DownloadLinux32) != downloadTypes.end(); + } +#endif + return false; + } + + bool operator==(const Provider &other) { + return + other.infoUrl == infoUrl && + other.downloadUrl == downloadUrl && + other.downloadTypes == downloadTypes && + other.foundInPacks == foundInPacks; + } + bool operator!=(const Provider &other) { + return !operator==(other); + } +}; + +#endif diff -r 5b1b03c1d8d4 -r 6f626cfdba51 rdf/PluginRDFDescription.cpp --- a/rdf/PluginRDFDescription.cpp Mon Apr 20 15:42:51 2020 +0100 +++ b/rdf/PluginRDFDescription.cpp Mon Apr 20 18:45:47 2020 +0100 @@ -80,28 +80,10 @@ return m_pluginMaker; } -QString -PluginRDFDescription::getPluginInfoURL() const +Provider +PluginRDFDescription::getPluginProvider() const { - return m_pluginInfoURL; -} - -QString -PluginRDFDescription::getPluginDownloadURL() const -{ - return m_pluginDownloadURL; -} - -std::set -PluginRDFDescription::getPluginDownloadTypes() const -{ - return m_pluginDownloadTypes; -} - -std::map -PluginRDFDescription::getPluginFoundInPacks() const -{ - return m_pluginFoundInPacks; + return m_provider; } QStringList @@ -234,7 +216,7 @@ (Triple(plugin, index->expand("foaf:page"), Node())); if (n.type == Node::URI && n.value != "") { - m_pluginInfoURL = n.value; + m_provider.infoUrl = n.value; } // There may be more than one library node claiming this @@ -261,19 +243,19 @@ (Triple(libn, index->expand("foaf:page"), Node())); if (n.type == Node::URI && n.value != "") { - m_pluginInfoURL = n.value; + m_provider.infoUrl = n.value; } n = index->complete (Triple(libn, index->expand("doap:download-page"), Node())); if (n.type == Node::URI && n.value != "") { - m_pluginDownloadURL = n.value; + m_provider.downloadUrl = n.value; n = index->complete (Triple(libn, index->expand("vamp:has_source"), Node())); if (n.type == Node::Literal && n.value == "true") { - m_pluginDownloadTypes.insert(DownloadSourceCode); + m_provider.downloadTypes.insert(Provider::DownloadSourceCode); } Nodes binaries = index->match @@ -283,13 +265,13 @@ for (Node bin: binaries) { if (bin.type != Node::Literal) continue; if (bin.value == "linux32") { - m_pluginDownloadTypes.insert(DownloadLinux32); + m_provider.downloadTypes.insert(Provider::DownloadLinux32); } else if (bin.value == "linux64") { - m_pluginDownloadTypes.insert(DownloadLinux64); + m_provider.downloadTypes.insert(Provider::DownloadLinux64); } else if (bin.value == "win32") { - m_pluginDownloadTypes.insert(DownloadWindows); + m_provider.downloadTypes.insert(Provider::DownloadWindows); } else if (bin.value == "osx") { - m_pluginDownloadTypes.insert(DownloadMac); + m_provider.downloadTypes.insert(Provider::DownloadMac); } } } @@ -304,20 +286,21 @@ for (Node packn: packs) { if (packn.type != Node::URI) continue; - Pack pack; + QString packName; + QString packUrl; n = index->complete (Triple(packn, index->expand("dc:title"), Node())); if (n.type == Node::Literal) { - pack.name = n.value; + packName = n.value; } n = index->complete (Triple(packn, index->expand("foaf:page"), Node())); if (n.type == Node::URI) { - pack.downloadURL = n.value; + packUrl = n.value; } - if (pack.name != "" && pack.downloadURL != "") { - m_pluginFoundInPacks[packn.value] = pack; + if (packName != "" && packUrl != "") { + m_provider.foundInPacks[packName] = packUrl; } } } @@ -329,16 +312,16 @@ SVCERR << " * name: " << m_pluginName << endl; SVCERR << " * description: " << m_pluginDescription << endl; SVCERR << " * maker: " << m_pluginMaker << endl; - SVCERR << " * info url: <" << m_pluginInfoURL << ">" << endl; - SVCERR << " * download url: <" << m_pluginDownloadURL << ">" << endl; + SVCERR << " * info url: <" << m_provider.infoUrl << ">" << endl; + SVCERR << " * download url: <" << m_provider.downloadUrl << ">" << endl; SVCERR << " * download types:" << endl; - for (auto t: m_pluginDownloadTypes) { + for (auto t: m_provider.downloadTypes) { SVCERR << " * " << int(t) << endl; } SVCERR << " * packs:" << endl; - for (auto t: m_pluginFoundInPacks) { - SVCERR << " * " << t.first << " { name: " << t.second.name - << ", download url: " << t.second.downloadURL << " }" << endl; + for (auto t: m_provider.foundInPacks) { + SVCERR << " * " << t.first + << ", download url: <" << t.second << ">" << endl; } SVCERR << endl; #endif diff -r 5b1b03c1d8d4 -r 6f626cfdba51 rdf/PluginRDFDescription.h --- a/rdf/PluginRDFDescription.h Mon Apr 20 15:42:51 2020 +0100 +++ b/rdf/PluginRDFDescription.h Mon Apr 20 18:45:47 2020 +0100 @@ -23,6 +23,8 @@ #include "base/Debug.h" +#include "plugin/Provider.h" + class PluginRDFDescription { public: @@ -30,8 +32,7 @@ PluginRDFDescription(QString pluginId); ~PluginRDFDescription(); - enum OutputDisposition - { + enum OutputDisposition { OutputDispositionUnknown, OutputSparse, OutputDense, @@ -43,26 +44,7 @@ QString getPluginName() const; QString getPluginDescription() const; QString getPluginMaker() const; - QString getPluginInfoURL() const; - QString getPluginDownloadURL() const; - - enum DownloadType - { - DownloadSourceCode, - DownloadWindows, - DownloadMac, - DownloadLinux32, - DownloadLinux64, - DownloadOther - }; - std::set getPluginDownloadTypes() const; - - struct Pack - { - QString name; - QString downloadURL; - }; - std::map getPluginFoundInPacks() const; // uri -> pack + Provider getPluginProvider() const; QStringList getOutputIds() const; QString getOutputName(QString outputId) const; @@ -83,10 +65,7 @@ QString m_pluginName; QString m_pluginDescription; QString m_pluginMaker; - QString m_pluginInfoURL; - QString m_pluginDownloadURL; - std::set m_pluginDownloadTypes; - std::map m_pluginFoundInPacks; + Provider m_provider; OutputStringMap m_outputNames; OutputDispositionMap m_outputDispositions; OutputStringMap m_outputEventTypeURIMap; diff -r 5b1b03c1d8d4 -r 6f626cfdba51 transform/TransformDescription.h --- a/transform/TransformDescription.h Mon Apr 20 15:42:51 2020 +0100 +++ b/transform/TransformDescription.h Mon Apr 20 18:45:47 2020 +0100 @@ -18,6 +18,8 @@ #include "Transform.h" +#include "plugin/Provider.h" + #include #include @@ -74,7 +76,7 @@ QString description; // sentence describing transform QString longDescription; // description "using" plugin name "by" maker QString maker; - QString infoUrl; + Provider provider; QString units; bool configurable; diff -r 5b1b03c1d8d4 -r 6f626cfdba51 transform/TransformFactory.cpp --- a/transform/TransformFactory.cpp Mon Apr 20 15:42:51 2020 +0100 +++ b/transform/TransformFactory.cpp Mon Apr 20 18:45:47 2020 +0100 @@ -664,7 +664,7 @@ QString description = desc.getPluginDescription(); QString maker = desc.getPluginMaker(); - QString infoUrl = desc.getPluginInfoURL(); + Provider provider = desc.getPluginProvider(); QStringList oids = desc.getOutputIds(); @@ -675,11 +675,11 @@ if (m_transforms.find(tid) != m_transforms.end()) { #ifdef DEBUG_TRANSFORM_FACTORY SVCERR << "TransformFactory::populateUninstalledTransforms: " - << tid << " is installed; adding info url if appropriate, skipping rest" << endl; + << tid << " is installed; adding provider if present, skipping rest" << endl; #endif - if (infoUrl != "") { - if (m_transforms[tid].infoUrl == "") { - m_transforms[tid].infoUrl = infoUrl; + if (provider != Provider()) { + if (m_transforms[tid].provider == Provider()) { + m_transforms[tid].provider = provider; } } continue; @@ -728,7 +728,7 @@ td.description = description; td.longDescription = longDescription; td.maker = maker; - td.infoUrl = infoUrl; + td.provider = provider; td.units = ""; td.configurable = false; @@ -856,12 +856,12 @@ } else return ""; } -QString -TransformFactory::getTransformInfoUrl(TransformId identifier) +Provider +TransformFactory::getTransformProvider(TransformId identifier) { if (m_transforms.find(identifier) != m_transforms.end()) { - return m_transforms[identifier].infoUrl; - } else return ""; + return m_transforms[identifier].provider; + } else return {}; } Vamp::Plugin::InputDomain diff -r 5b1b03c1d8d4 -r 6f626cfdba51 transform/TransformFactory.h --- a/transform/TransformFactory.h Mon Apr 20 15:42:51 2020 +0100 +++ b/transform/TransformFactory.h Mon Apr 20 18:45:47 2020 +0100 @@ -105,7 +105,7 @@ QString getTransformUnits(TransformId identifier); - QString getTransformInfoUrl(TransformId identifier); + Provider getTransformProvider(TransformId identifier); Vamp::Plugin::InputDomain getTransformInputDomain(TransformId identifier);