Mercurial > hg > vamp-plugin-load-checker
comparison checker/knownplugins.h @ 35:4154894d638c plugin-path-config
Trim KnownPlugins class down to static info and environment variable lookup; introduce KnownPluginCandidates to provide its former API
author | Chris Cannam |
---|---|
date | Wed, 06 Jun 2018 15:54:26 +0100 |
parents | 6905d8b146f6 |
children |
comparison
equal
deleted
inserted
replaced
34:6905d8b146f6 | 35:4154894d638c |
---|---|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ | 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ |
2 /* | 2 /* |
3 Copyright (c) 2016 Queen Mary, University of London | 3 Copyright (c) 2016-2018 Queen Mary, University of London |
4 | 4 |
5 Permission is hereby granted, free of charge, to any person | 5 Permission is hereby granted, free of charge, to any person |
6 obtaining a copy of this software and associated documentation | 6 obtaining a copy of this software and associated documentation |
7 files (the "Software"), to deal in the Software without | 7 files (the "Software"), to deal in the Software without |
8 restriction, including without limitation the rights to use, copy, | 8 restriction, including without limitation the rights to use, copy, |
28 */ | 28 */ |
29 | 29 |
30 #ifndef KNOWN_PLUGINS_H | 30 #ifndef KNOWN_PLUGINS_H |
31 #define KNOWN_PLUGINS_H | 31 #define KNOWN_PLUGINS_H |
32 | 32 |
33 #include "plugincandidates.h" | |
34 | |
35 #include <string> | 33 #include <string> |
36 #include <map> | 34 #include <map> |
37 #include <vector> | 35 #include <vector> |
38 | 36 |
39 /** | 37 /** |
40 * Class to identify and list candidate shared-library files possibly | 38 * Class to provide information about a hardcoded set of known plugin |
41 * containing plugins in a hardcoded set of known formats. Uses a | 39 * formats. |
42 * separate process (the "helper", whose executable name must be | |
43 * provided at construction) to test-load each library in order to | |
44 * winnow out any that fail to load or crash on load. | |
45 * | 40 * |
46 * Requires C++11 and the Qt5 QtCore library. | 41 * Requires C++11 and the Qt5 QtCore library. |
47 */ | 42 */ |
48 class KnownPlugins | 43 class KnownPlugins |
49 { | 44 { |
54 VampPlugin, | 49 VampPlugin, |
55 LADSPAPlugin, | 50 LADSPAPlugin, |
56 DSSIPlugin | 51 DSSIPlugin |
57 }; | 52 }; |
58 | 53 |
59 KnownPlugins(std::string helperExecutableName, | 54 enum BinaryFormat { |
60 PluginCandidates::LogCallback *cb = 0); | 55 FormatNative, |
56 FormatNonNative32Bit // i.e. a 32-bit plugin but on a 64-bit host | |
57 }; | |
58 | |
59 KnownPlugins(BinaryFormat format); | |
61 | 60 |
62 std::vector<PluginType> getKnownPluginTypes() const; | 61 std::vector<PluginType> getKnownPluginTypes() const; |
63 | 62 |
64 std::string getTagFor(PluginType type) const { | 63 std::string getTagFor(PluginType type) const { |
65 return m_known.at(type).tag; | 64 return m_known.at(type).tag; |
66 } | 65 } |
67 | 66 |
68 stringlist getCandidateLibrariesFor(PluginType type) const { | |
69 return m_candidates.getCandidateLibrariesFor(getTagFor(type)); | |
70 } | |
71 | |
72 std::string getPathEnvironmentVariableFor(PluginType type) const { | 67 std::string getPathEnvironmentVariableFor(PluginType type) const { |
73 return m_known.at(type).variable; | 68 return m_known.at(type).variable; |
74 } | 69 } |
75 | 70 |
71 stringlist getDefaultPathFor(PluginType type) const { | |
72 return m_known.at(type).defaultPath; | |
73 } | |
74 | |
76 stringlist getPathFor(PluginType type) const { | 75 stringlist getPathFor(PluginType type) const { |
77 return m_known.at(type).path; | 76 return m_known.at(type).path; |
78 } | 77 } |
79 | 78 |
80 std::string getHelperExecutableName() const { | 79 std::string getDescriptorFor(PluginType type) const { |
81 return m_helperExecutableName; | 80 return m_known.at(type).descriptor; |
82 } | 81 } |
83 | |
84 std::string getFailureReport() const; | |
85 | 82 |
86 private: | 83 private: |
87 struct TypeRec { | 84 struct TypeRec { |
88 std::string tag; | 85 std::string tag; |
89 std::string variable; | 86 std::string variable; |
87 stringlist defaultPath; | |
90 stringlist path; | 88 stringlist path; |
91 std::string descriptor; | 89 std::string descriptor; |
92 }; | 90 }; |
93 typedef std::map<PluginType, TypeRec> Known; | 91 typedef std::map<PluginType, TypeRec> Known; |
94 Known m_known; | 92 Known m_known; |
95 | 93 |
96 stringlist expandConventionalPath(PluginType type, std::string var); | 94 std::string getUnexpandedDefaultPathString(PluginType type); |
97 std::string getDefaultPath(PluginType type); | 95 std::string getDefaultPathString(PluginType type); |
96 | |
97 stringlist expandPathString(std::string pathString); | |
98 stringlist expandConventionalPath(PluginType type, std::string variable); | |
98 | 99 |
99 PluginCandidates m_candidates; | 100 BinaryFormat m_format; |
100 std::string m_helperExecutableName; | |
101 | |
102 /** This returns true if the helper has a name ending in "-32". By | |
103 * our convention, this means that it is a 32-bit helper found on | |
104 * a 64-bit system, so (depending on the OS) we may need to look | |
105 * in 32-bit-specific paths. Note that is32bit() is *not* usually | |
106 * true on 32-bit systems; it's used specifically to indicate a | |
107 * "non-native" 32-bit helper. | |
108 */ | |
109 bool is32bit() const; | |
110 }; | 101 }; |
111 | 102 |
112 #endif | 103 #endif |