annotate plugin/Provider.h @ 1845:6f626cfdba51

Pull out Provider struct
author Chris Cannam
date Mon, 20 Apr 2020 18:45:47 +0100
parents
children 37ffea1e50ec
rev   line source
Chris@1845 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@1845 2
Chris@1845 3 /*
Chris@1845 4 Sonic Visualiser
Chris@1845 5 An audio file viewer and annotation editor.
Chris@1845 6 Centre for Digital Music, Queen Mary, University of London.
Chris@1845 7
Chris@1845 8 This program is free software; you can redistribute it and/or
Chris@1845 9 modify it under the terms of the GNU General Public License as
Chris@1845 10 published by the Free Software Foundation; either version 2 of the
Chris@1845 11 License, or (at your option) any later version. See the file
Chris@1845 12 COPYING included with this distribution for more information.
Chris@1845 13 */
Chris@1845 14
Chris@1845 15 #ifndef SV_PROVIDER_H
Chris@1845 16 #define SV_PROVIDER_H
Chris@1845 17
Chris@1845 18 #include <QString>
Chris@1845 19
Chris@1845 20 #include <set>
Chris@1845 21
Chris@1845 22 struct Provider
Chris@1845 23 {
Chris@1845 24 QString infoUrl;
Chris@1845 25 QString downloadUrl;
Chris@1845 26
Chris@1845 27 enum DownloadType {
Chris@1845 28 DownloadSourceCode,
Chris@1845 29 DownloadWindows,
Chris@1845 30 DownloadMac,
Chris@1845 31 DownloadLinux32,
Chris@1845 32 DownloadLinux64,
Chris@1845 33 DownloadOther
Chris@1845 34 };
Chris@1845 35 std::set<DownloadType> downloadTypes;
Chris@1845 36
Chris@1845 37 std::map<QString, QString> foundInPacks; // pack name -> pack url
Chris@1845 38
Chris@1845 39 bool hasSourceDownload() const {
Chris@1845 40 return downloadTypes.find(DownloadSourceCode) != downloadTypes.end();
Chris@1845 41 }
Chris@1845 42
Chris@1845 43 bool hasDownloadForThisPlatform() const {
Chris@1845 44 #ifdef Q_OS_WIN32
Chris@1845 45 return downloadTypes.find(DownloadWindows) != downloadTypes.end();
Chris@1845 46 #endif
Chris@1845 47 #ifdef Q_OS_MAC
Chris@1845 48 return downloadTypes.find(DownloadMac) != downloadTypes.end();
Chris@1845 49 #endif
Chris@1845 50 #ifdef Q_OS_LINUX
Chris@1845 51 if (sizeof(void *) == 8) {
Chris@1845 52 return downloadTypes.find(DownloadLinux64) != downloadTypes.end();
Chris@1845 53 } else {
Chris@1845 54 return downloadTypes.find(DownloadLinux32) != downloadTypes.end();
Chris@1845 55 }
Chris@1845 56 #endif
Chris@1845 57 return false;
Chris@1845 58 }
Chris@1845 59
Chris@1845 60 bool operator==(const Provider &other) {
Chris@1845 61 return
Chris@1845 62 other.infoUrl == infoUrl &&
Chris@1845 63 other.downloadUrl == downloadUrl &&
Chris@1845 64 other.downloadTypes == downloadTypes &&
Chris@1845 65 other.foundInPacks == foundInPacks;
Chris@1845 66 }
Chris@1845 67 bool operator!=(const Provider &other) {
Chris@1845 68 return !operator==(other);
Chris@1845 69 }
Chris@1845 70 };
Chris@1845 71
Chris@1845 72 #endif