Chris@4
|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
|
Chris@5
|
2 /*
|
Chris@5
|
3 Copyright (c) 2016 Queen Mary, University of London
|
Chris@5
|
4
|
Chris@5
|
5 Permission is hereby granted, free of charge, to any person
|
Chris@5
|
6 obtaining a copy of this software and associated documentation
|
Chris@5
|
7 files (the "Software"), to deal in the Software without
|
Chris@5
|
8 restriction, including without limitation the rights to use, copy,
|
Chris@5
|
9 modify, merge, publish, distribute, sublicense, and/or sell copies
|
Chris@5
|
10 of the Software, and to permit persons to whom the Software is
|
Chris@5
|
11 furnished to do so, subject to the following conditions:
|
Chris@5
|
12
|
Chris@5
|
13 The above copyright notice and this permission notice shall be
|
Chris@5
|
14 included in all copies or substantial portions of the Software.
|
Chris@5
|
15
|
Chris@5
|
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
Chris@5
|
17 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
Chris@5
|
18 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
Chris@5
|
19 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
Chris@5
|
20 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
Chris@5
|
21 CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
Chris@5
|
22 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
Chris@5
|
23
|
Chris@5
|
24 Except as contained in this notice, the names of the Centre for
|
Chris@5
|
25 Digital Music and Queen Mary, University of London shall not be
|
Chris@5
|
26 used in advertising or otherwise to promote the sale, use or other
|
Chris@5
|
27 dealings in this Software without prior written authorization.
|
Chris@5
|
28 */
|
Chris@4
|
29
|
Chris@4
|
30 #ifndef KNOWN_PLUGINS_H
|
Chris@4
|
31 #define KNOWN_PLUGINS_H
|
Chris@4
|
32
|
Chris@4
|
33 #include "plugincandidates.h"
|
Chris@4
|
34
|
Chris@4
|
35 #include <string>
|
Chris@4
|
36 #include <map>
|
Chris@4
|
37 #include <vector>
|
Chris@4
|
38
|
Chris@28
|
39 /**
|
Chris@28
|
40 * Class to identify and list candidate shared-library files possibly
|
Chris@28
|
41 * containing plugins in a hardcoded set of known formats. Uses a
|
Chris@28
|
42 * separate process (the "helper", whose executable name must be
|
Chris@28
|
43 * provided at construction) to test-load each library in order to
|
Chris@28
|
44 * winnow out any that fail to load or crash on load.
|
Chris@28
|
45 *
|
Chris@28
|
46 * Requires C++11 and the Qt5 QtCore library.
|
Chris@28
|
47 */
|
Chris@4
|
48 class KnownPlugins
|
Chris@4
|
49 {
|
Chris@4
|
50 typedef std::vector<std::string> stringlist;
|
Chris@4
|
51
|
Chris@4
|
52 public:
|
Chris@4
|
53 enum PluginType {
|
Chris@19
|
54 VampPlugin,
|
Chris@19
|
55 LADSPAPlugin,
|
Chris@19
|
56 DSSIPlugin
|
Chris@4
|
57 };
|
Chris@4
|
58
|
Chris@6
|
59 KnownPlugins(std::string helperExecutableName,
|
Chris@6
|
60 PluginCandidates::LogCallback *cb = 0);
|
Chris@4
|
61
|
Chris@4
|
62 std::vector<PluginType> getKnownPluginTypes() const {
|
Chris@19
|
63 return { VampPlugin, LADSPAPlugin, DSSIPlugin };
|
Chris@4
|
64 };
|
Chris@4
|
65
|
Chris@4
|
66 std::string getTagFor(PluginType type) const {
|
Chris@19
|
67 return m_known.at(type).tag;
|
Chris@4
|
68 }
|
Chris@4
|
69
|
Chris@4
|
70 stringlist getCandidateLibrariesFor(PluginType type) const {
|
Chris@19
|
71 return m_candidates.getCandidateLibrariesFor(getTagFor(type));
|
Chris@4
|
72 }
|
Chris@4
|
73
|
Chris@21
|
74 std::string getHelperExecutableName() const {
|
Chris@21
|
75 return m_helperExecutableName;
|
Chris@21
|
76 }
|
Chris@21
|
77
|
Chris@4
|
78 std::string getFailureReport() const;
|
Chris@4
|
79
|
Chris@4
|
80 private:
|
Chris@4
|
81 struct TypeRec {
|
Chris@19
|
82 std::string tag;
|
Chris@19
|
83 stringlist path;
|
Chris@19
|
84 std::string descriptor;
|
Chris@4
|
85 };
|
Chris@4
|
86 std::map<PluginType, TypeRec> m_known;
|
Chris@4
|
87
|
Chris@4
|
88 stringlist expandConventionalPath(PluginType type, std::string var);
|
Chris@4
|
89 std::string getDefaultPath(PluginType type);
|
Chris@4
|
90
|
Chris@4
|
91 PluginCandidates m_candidates;
|
Chris@20
|
92 std::string m_helperExecutableName;
|
Chris@20
|
93
|
Chris@20
|
94 bool is32bit() const; // true if helper looks to be 32-bit on 64-bit system
|
Chris@4
|
95 };
|
Chris@4
|
96
|
Chris@4
|
97 #endif
|