annotate base/HelperExecPath.h @ 1782:2a810ed46977

Lib dir name is usually the same as the binary name, not the formal application name
author Chris Cannam
date Tue, 17 Sep 2019 09:28:27 +0100
parents 75aefcc9f07d
children
rev   line source
Chris@1243 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@1243 2
Chris@1243 3 /*
Chris@1243 4 Sonic Visualiser
Chris@1243 5 An audio file viewer and annotation editor.
Chris@1243 6 Centre for Digital Music, Queen Mary, University of London.
Chris@1243 7 This file copyright 2006-2016 Chris Cannam and QMUL.
Chris@1243 8
Chris@1243 9 This program is free software; you can redistribute it and/or
Chris@1243 10 modify it under the terms of the GNU General Public License as
Chris@1243 11 published by the Free Software Foundation; either version 2 of the
Chris@1243 12 License, or (at your option) any later version. See the file
Chris@1243 13 COPYING included with this distribution for more information.
Chris@1243 14 */
Chris@1243 15
Chris@1243 16 #ifndef SV_HELPER_EXEC_PATH_H
Chris@1243 17 #define SV_HELPER_EXEC_PATH_H
Chris@1243 18
Chris@1243 19 #include <QStringList>
Chris@1243 20
Chris@1243 21 /**
Chris@1243 22 * Class to find helper executables that have been installed alongside
Chris@1243 23 * the application. There may be more than one executable available
Chris@1243 24 * with a given base name, because it's possible to have more than one
Chris@1243 25 * implementation of a given service. For example, a plugin helper or
Chris@1243 26 * scanner may exist in both 32-bit and 64-bit variants.
Chris@1243 27 *
Chris@1243 28 * This class encodes both the expected locations of helper
Chris@1243 29 * executables, and the expected priority between different
Chris@1243 30 * implementations (e.g. preferring the architecture that matches that
Chris@1243 31 * of the host).
Chris@1243 32 */
Chris@1243 33 class HelperExecPath
Chris@1243 34 {
Chris@1243 35 public:
Chris@1246 36 enum SearchType {
Chris@1246 37 NativeArchitectureOnly,
Chris@1246 38 AllInstalled
Chris@1246 39 };
Chris@1246 40
Chris@1246 41 HelperExecPath(SearchType type) : m_type(type) { }
Chris@1246 42
Chris@1243 43 /**
Chris@1243 44 * Find a helper executable with the given base name in the bundle
Chris@1243 45 * directory or installation location, if one exists, and return
Chris@1243 46 * its full path. Equivalent to calling getHelperExecutables() and
Chris@1243 47 * taking the first result from the returned list (or "" if empty).
Chris@1243 48 */
Chris@1246 49 QString getHelperExecutable(QString basename);
Chris@1246 50
Chris@1246 51 struct HelperExec {
Chris@1246 52 QString executable;
Chris@1246 53 QString tag;
Chris@1246 54 };
Chris@1243 55
Chris@1243 56 /**
Chris@1243 57 * Find all helper executables with the given base name in the
Chris@1243 58 * bundle directory or installation location, and return their
Chris@1246 59 * full paths in order of priority. The "tag" string contains an
Chris@1246 60 * identifier for the location or architecture of the helper, for
Chris@1246 61 * example "32", "64", "js" etc. An empty tag signifies a default
Chris@1246 62 * helper that matches the application's architecture.
Chris@1243 63 */
Chris@1246 64 QList<HelperExec> getHelperExecutables(QString basename);
Chris@1243 65
Chris@1243 66 /**
Chris@1243 67 * Return the list of directories searched for helper
Chris@1243 68 * executables.
Chris@1243 69 */
Chris@1246 70 QStringList getHelperDirPaths();
Chris@1243 71
Chris@1243 72 /**
Chris@1243 73 * Return the list of executable paths examined in the search for
Chris@1243 74 * the helper executable with the given basename.
Chris@1243 75 */
Chris@1246 76 QStringList getHelperCandidatePaths(QString basename);
Chris@1243 77
Chris@1243 78 private:
Chris@1246 79 SearchType m_type;
Chris@1246 80 QList<HelperExec> search(QString, QStringList &);
Chris@1246 81 QStringList getTags();
Chris@1243 82 };
Chris@1243 83
Chris@1243 84 #endif