annotate plugin/PluginScan.h @ 1838:403e961ec6ab

Merge
author Chris Cannam
date Thu, 09 Apr 2020 11:23:17 +0100
parents 0ee87bc10cdc
children
rev   line source
Chris@1178 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@1178 2
Chris@1178 3 /*
Chris@1178 4 Sonic Visualiser
Chris@1178 5 An audio file viewer and annotation editor.
Chris@1178 6 Centre for Digital Music, Queen Mary, University of London.
Chris@1178 7
Chris@1178 8 This program is free software; you can redistribute it and/or
Chris@1178 9 modify it under the terms of the GNU General Public License as
Chris@1178 10 published by the Free Software Foundation; either version 2 of the
Chris@1178 11 License, or (at your option) any later version. See the file
Chris@1178 12 COPYING included with this distribution for more information.
Chris@1178 13 */
Chris@1178 14
Chris@1178 15 #ifndef PLUGIN_SCAN_H
Chris@1178 16 #define PLUGIN_SCAN_H
Chris@1178 17
Chris@1178 18 #include <QStringList>
Chris@1246 19 #include <QMutex>
Chris@1241 20 #include <vector>
Chris@1246 21 #include <map>
Chris@1178 22
Chris@1501 23 #ifdef HAVE_PLUGIN_CHECKER_HELPER
Chris@1501 24 #include "checker/knownplugincandidates.h"
Chris@1501 25 #else
Chris@1501 26 class KnownPluginCandidates {};
Chris@1501 27 #endif
Chris@1178 28
Chris@1180 29 class PluginScan
Chris@1178 30 {
Chris@1178 31 public:
Chris@1178 32 static PluginScan *getInstance();
Chris@1178 33
Chris@1249 34 /**
Chris@1249 35 * Carry out startup scan of available plugins. Do not call
Chris@1249 36 * getCandidateLibrariesFor() unless this has been called and
Chris@1249 37 * scanSucceeded() is returning true.
Chris@1249 38 */
Chris@1241 39 void scan();
Chris@1179 40
Chris@1249 41 /**
Chris@1249 42 * Return true if scan() completed successfully. If the scan
Chris@1249 43 * failed, consider using the normal plugin path to load any
Chris@1249 44 * available plugins (as if they had all been found to be
Chris@1249 45 * loadable) rather than rejecting all of them -- i.e. consider
Chris@1249 46 * falling back on the behaviour of code from before the scan
Chris@1249 47 * logic was added.
Chris@1249 48 */
Chris@1179 49 bool scanSucceeded() const;
Chris@1178 50
Chris@1180 51 enum PluginType {
Chris@1429 52 VampPlugin,
Chris@1429 53 LADSPAPlugin,
Chris@1429 54 DSSIPlugin
Chris@1180 55 };
Chris@1246 56 struct Candidate {
Chris@1249 57 QString libraryPath; // full path, not just soname
Chris@1249 58 QString helperTag; // identifies the helper that found it
Chris@1249 59 // (see HelperExecPath)
Chris@1246 60 };
Chris@1249 61
Chris@1249 62 /**
Chris@1249 63 * Return the candidate plugin libraries of the given type that
Chris@1249 64 * were found by helpers during the startup scan.
Chris@1249 65 *
Chris@1249 66 * This could return an empty list for two reasons: the scan
Chris@1249 67 * succeeded but no libraries were found; or the scan failed. Call
Chris@1249 68 * scanSucceeded() to distinguish between them.
Chris@1249 69 */
Chris@1246 70 QList<Candidate> getCandidateLibrariesFor(PluginType) const;
Chris@1178 71
Chris@1178 72 QString getStartupFailureReport() const;
Chris@1178 73
Chris@1178 74 private:
Chris@1178 75 PluginScan();
Chris@1178 76 ~PluginScan();
Chris@1241 77
Chris@1241 78 void clear();
Chris@1246 79
Chris@1501 80 #ifdef HAVE_PLUGIN_CHECKER_HELPER
Chris@1501 81 QString formatFailureReport(QString helperTag,
Chris@1501 82 std::vector<PluginCandidates::FailureRec>)
Chris@1501 83 const;
Chris@1501 84 #endif
Chris@1501 85
Chris@1246 86 mutable QMutex m_mutex; // while scanning; definitely can't multi-thread this
Chris@1241 87
Chris@1474 88 std::map<QString, KnownPluginCandidates *> m_kp; // tag -> KnownPlugins client
Chris@1179 89 bool m_succeeded;
Chris@1180 90
Chris@1180 91 class Logger;
Chris@1180 92 Logger *m_logger;
Chris@1178 93 };
Chris@1178 94
Chris@1178 95 #endif