Mercurial > hg > svcore
comparison plugin/PluginScan.cpp @ 1180:98664afd518b pluginscan
Update for adjusted checker layout, and tidy
author | Chris Cannam |
---|---|
date | Thu, 14 Apr 2016 16:52:55 +0100 |
parents | 6b1af0f05f06 |
children | 2f628dc9a0b0 |
comparison
equal
deleted
inserted
replaced
1179:6b1af0f05f06 | 1180:98664afd518b |
---|---|
14 | 14 |
15 #include "PluginScan.h" | 15 #include "PluginScan.h" |
16 | 16 |
17 #include "base/Debug.h" | 17 #include "base/Debug.h" |
18 | 18 |
19 #include "checker/knownplugins.h" | |
20 | |
19 #include <QMutex> | 21 #include <QMutex> |
20 | 22 |
21 using std::string; | 23 using std::string; |
22 | 24 |
23 PluginScan *PluginScan::getInstance() { | 25 class PluginScan::Logger : public PluginCandidates::LogCallback |
26 { | |
27 protected: | |
28 void log(std::string message) { | |
29 SVDEBUG << "PluginScan: " << message; | |
30 } | |
31 }; | |
32 | |
33 PluginScan *PluginScan::getInstance() | |
34 { | |
24 static QMutex mutex; | 35 static QMutex mutex; |
25 static PluginScan *m_instance = 0; | 36 static PluginScan *m_instance = 0; |
26 mutex.lock(); | 37 mutex.lock(); |
27 if (!m_instance) m_instance = new PluginScan(); | 38 if (!m_instance) m_instance = new PluginScan(); |
28 mutex.unlock(); | 39 mutex.unlock(); |
29 return m_instance; | 40 return m_instance; |
30 } | 41 } |
31 | 42 |
32 PluginScan::PluginScan() : m_kp(0), m_succeeded(false) { | 43 PluginScan::PluginScan() : m_kp(0), m_succeeded(false), m_logger(new Logger) { |
33 } | 44 } |
34 | 45 |
35 PluginScan::~PluginScan() { | 46 PluginScan::~PluginScan() { |
36 delete m_kp; | 47 delete m_kp; |
37 } | 48 delete m_logger; |
38 | |
39 void | |
40 PluginScan::log(string message) | |
41 { | |
42 SVDEBUG << "PluginScan: " << message; | |
43 } | 49 } |
44 | 50 |
45 void | 51 void |
46 PluginScan::scan() | 52 PluginScan::scan() |
47 { | 53 { |
48 delete m_kp; | 54 delete m_kp; |
49 m_succeeded = false; | 55 m_succeeded = false; |
50 try { | 56 try { |
51 m_kp = new KnownPlugins("./helper", this); //!!! | 57 m_kp = new KnownPlugins("./helper", m_logger); //!!! |
52 m_succeeded = true; | 58 m_succeeded = true; |
53 } catch (const std::exception &e) { | 59 } catch (const std::exception &e) { |
54 cerr << "ERROR: PluginScan::scan: " << e.what() << endl; | 60 cerr << "ERROR: PluginScan::scan: " << e.what() << endl; |
55 m_kp = 0; | 61 m_kp = 0; |
56 } | 62 } |
57 } | 63 } |
58 | 64 |
59 QStringList | 65 QStringList |
60 PluginScan::getCandidateLibrariesFor(KnownPlugins::PluginType type) const | 66 PluginScan::getCandidateLibrariesFor(PluginType type) const |
61 { | 67 { |
68 KnownPlugins::PluginType kpt; | |
69 switch (type) { | |
70 case VampPlugin: kpt = KnownPlugins::VampPlugin; break; | |
71 case LADSPAPlugin: kpt = KnownPlugins::LADSPAPlugin; break; | |
72 case DSSIPlugin: kpt = KnownPlugins::DSSIPlugin; break; | |
73 default: throw std::logic_error("Inconsistency in plugin type enums"); | |
74 } | |
75 | |
62 QStringList candidates; | 76 QStringList candidates; |
63 if (!m_kp) return candidates; | 77 if (!m_kp) return candidates; |
64 auto c = m_kp->getCandidateLibrariesFor(type); | 78 auto c = m_kp->getCandidateLibrariesFor(kpt); |
65 for (auto s: c) candidates.push_back(s.c_str()); | 79 for (auto s: c) candidates.push_back(s.c_str()); |
66 return candidates; | 80 return candidates; |
67 } | |
68 | |
69 QStringList | |
70 PluginScan::getCandidateVampLibraries() const | |
71 { | |
72 return getCandidateLibrariesFor(KnownPlugins::VampPlugin); | |
73 } | |
74 | |
75 QStringList | |
76 PluginScan::getCandidateLADSPALibraries() const | |
77 { | |
78 return getCandidateLibrariesFor(KnownPlugins::LADSPAPlugin); | |
79 } | |
80 | |
81 QStringList | |
82 PluginScan::getCandidateDSSILibraries() const | |
83 { | |
84 return getCandidateLibrariesFor(KnownPlugins::DSSIPlugin); | |
85 } | 81 } |
86 | 82 |
87 QString | 83 QString |
88 PluginScan::getStartupFailureReport() const | 84 PluginScan::getStartupFailureReport() const |
89 { | 85 { |