annotate checker/knownplugins.h @ 34:6905d8b146f6 plugin-path-config

Toward supporting separate environment variables for 32-bit plugins on a 64-bit system (otherwise we try to load both from the same helpers)
author Chris Cannam
date Wed, 06 Jun 2018 13:49:23 +0100
parents 7a20698b4c29
children 4154894d638c
rev   line source
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@34 62 std::vector<PluginType> getKnownPluginTypes() const;
Chris@4 63
Chris@4 64 std::string getTagFor(PluginType type) const {
Chris@19 65 return m_known.at(type).tag;
Chris@4 66 }
Chris@4 67
Chris@4 68 stringlist getCandidateLibrariesFor(PluginType type) const {
Chris@19 69 return m_candidates.getCandidateLibrariesFor(getTagFor(type));
Chris@4 70 }
Chris@4 71
Chris@34 72 std::string getPathEnvironmentVariableFor(PluginType type) const {
Chris@34 73 return m_known.at(type).variable;
Chris@34 74 }
Chris@34 75
Chris@34 76 stringlist getPathFor(PluginType type) const {
Chris@34 77 return m_known.at(type).path;
Chris@34 78 }
Chris@34 79
Chris@21 80 std::string getHelperExecutableName() const {
Chris@21 81 return m_helperExecutableName;
Chris@21 82 }
Chris@21 83
Chris@4 84 std::string getFailureReport() const;
Chris@4 85
Chris@4 86 private:
Chris@4 87 struct TypeRec {
Chris@19 88 std::string tag;
Chris@34 89 std::string variable;
Chris@19 90 stringlist path;
Chris@19 91 std::string descriptor;
Chris@4 92 };
Chris@34 93 typedef std::map<PluginType, TypeRec> Known;
Chris@34 94 Known m_known;
Chris@4 95
Chris@4 96 stringlist expandConventionalPath(PluginType type, std::string var);
Chris@4 97 std::string getDefaultPath(PluginType type);
Chris@4 98
Chris@4 99 PluginCandidates m_candidates;
Chris@20 100 std::string m_helperExecutableName;
Chris@20 101
Chris@34 102 /** This returns true if the helper has a name ending in "-32". By
Chris@34 103 * our convention, this means that it is a 32-bit helper found on
Chris@34 104 * a 64-bit system, so (depending on the OS) we may need to look
Chris@34 105 * in 32-bit-specific paths. Note that is32bit() is *not* usually
Chris@34 106 * true on 32-bit systems; it's used specifically to indicate a
Chris@34 107 * "non-native" 32-bit helper.
Chris@34 108 */
Chris@34 109 bool is32bit() const;
Chris@4 110 };
Chris@4 111
Chris@4 112 #endif