Chris@4: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ Chris@5: /* Chris@5: Copyright (c) 2016 Queen Mary, University of London Chris@5: Chris@5: Permission is hereby granted, free of charge, to any person Chris@5: obtaining a copy of this software and associated documentation Chris@5: files (the "Software"), to deal in the Software without Chris@5: restriction, including without limitation the rights to use, copy, Chris@5: modify, merge, publish, distribute, sublicense, and/or sell copies Chris@5: of the Software, and to permit persons to whom the Software is Chris@5: furnished to do so, subject to the following conditions: Chris@5: Chris@5: The above copyright notice and this permission notice shall be Chris@5: included in all copies or substantial portions of the Software. Chris@5: Chris@5: THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, Chris@5: EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF Chris@5: MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND Chris@5: NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY Chris@5: CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF Chris@5: CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION Chris@5: WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Chris@5: Chris@5: Except as contained in this notice, the names of the Centre for Chris@5: Digital Music and Queen Mary, University of London shall not be Chris@5: used in advertising or otherwise to promote the sale, use or other Chris@5: dealings in this Software without prior written authorization. Chris@5: */ Chris@4: Chris@4: #ifndef KNOWN_PLUGINS_H Chris@4: #define KNOWN_PLUGINS_H Chris@4: Chris@4: #include "plugincandidates.h" Chris@4: Chris@4: #include Chris@4: #include Chris@4: #include Chris@4: Chris@28: /** Chris@28: * Class to identify and list candidate shared-library files possibly Chris@28: * containing plugins in a hardcoded set of known formats. Uses a Chris@28: * separate process (the "helper", whose executable name must be Chris@28: * provided at construction) to test-load each library in order to Chris@28: * winnow out any that fail to load or crash on load. Chris@28: * Chris@28: * Requires C++11 and the Qt5 QtCore library. Chris@28: */ Chris@4: class KnownPlugins Chris@4: { Chris@4: typedef std::vector stringlist; Chris@4: Chris@4: public: Chris@4: enum PluginType { Chris@19: VampPlugin, Chris@19: LADSPAPlugin, Chris@19: DSSIPlugin Chris@4: }; Chris@4: Chris@6: KnownPlugins(std::string helperExecutableName, Chris@6: PluginCandidates::LogCallback *cb = 0); Chris@4: Chris@34: std::vector getKnownPluginTypes() const; Chris@4: Chris@4: std::string getTagFor(PluginType type) const { Chris@19: return m_known.at(type).tag; Chris@4: } Chris@4: Chris@4: stringlist getCandidateLibrariesFor(PluginType type) const { Chris@19: return m_candidates.getCandidateLibrariesFor(getTagFor(type)); Chris@4: } Chris@4: Chris@34: std::string getPathEnvironmentVariableFor(PluginType type) const { Chris@34: return m_known.at(type).variable; Chris@34: } Chris@34: Chris@34: stringlist getPathFor(PluginType type) const { Chris@34: return m_known.at(type).path; Chris@34: } Chris@34: Chris@21: std::string getHelperExecutableName() const { Chris@21: return m_helperExecutableName; Chris@21: } Chris@21: Chris@4: std::string getFailureReport() const; Chris@4: Chris@4: private: Chris@4: struct TypeRec { Chris@19: std::string tag; Chris@34: std::string variable; Chris@19: stringlist path; Chris@19: std::string descriptor; Chris@4: }; Chris@34: typedef std::map Known; Chris@34: Known m_known; Chris@4: Chris@4: stringlist expandConventionalPath(PluginType type, std::string var); Chris@4: std::string getDefaultPath(PluginType type); Chris@4: Chris@4: PluginCandidates m_candidates; Chris@20: std::string m_helperExecutableName; Chris@20: Chris@34: /** This returns true if the helper has a name ending in "-32". By Chris@34: * our convention, this means that it is a 32-bit helper found on Chris@34: * a 64-bit system, so (depending on the OS) we may need to look Chris@34: * in 32-bit-specific paths. Note that is32bit() is *not* usually Chris@34: * true on 32-bit systems; it's used specifically to indicate a Chris@34: * "non-native" 32-bit helper. Chris@34: */ Chris@34: bool is32bit() const; Chris@4: }; Chris@4: Chris@4: #endif