PluginPathSetter.h
Go to the documentation of this file.
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2 
3 /*
4  Sonic Visualiser
5  An audio file viewer and annotation editor.
6  Centre for Digital Music, Queen Mary, University of London.
7 
8  This program is free software; you can redistribute it and/or
9  modify it under the terms of the GNU General Public License as
10  published by the Free Software Foundation; either version 2 of the
11  License, or (at your option) any later version. See the file
12  COPYING included with this distribution for more information.
13 */
14 
15 #ifndef SV_PLUGIN_PATH_SETTER_H
16 #define SV_PLUGIN_PATH_SETTER_H
17 
18 #include <QString>
19 #include <QStringList>
20 #include <QMutex>
21 
22 #include <map>
23 
24 #include "checker/knownplugins.h"
25 
27 {
28 public:
29  typedef std::pair<KnownPlugins::PluginType,
30  KnownPlugins::BinaryFormat> TypeKey;
31 
32  typedef std::vector<TypeKey> TypeKeys;
33 
34  struct PathConfig {
35  QStringList directories; // Actual list of directories arising
36  // from user settings, environment
37  // variables, and defaults as
38  // appropriate
39 
40  QString envVariable; // Name of env var, e.g. LADSPA_PATH
41 
42  bool useEnvVariable; // True if env variable should override
43  // any user settings for this
44  };
45 
46  typedef std::map<TypeKey, PathConfig> Paths;
47 
51  static void initialiseEnvironmentVariables();
52 
55  static Paths getDefaultPaths();
56 
59  static Paths getEnvironmentPaths();
60 
63  static Paths getPaths();
64 
66  static void savePathSettings(Paths paths);
67 
71  static QString getOriginalEnvironmentValue(QString envVariable);
72 
73 private:
74  static Paths m_defaultPaths;
75  static Paths m_environmentPaths;
76  static std::map<QString, QString> m_originalEnvValues;
77  static TypeKeys m_supportedKeys;
78  static QMutex m_mutex;
79 
80  static std::vector<TypeKey> getSupportedKeys();
81  static Paths getEnvironmentPathsUncached(const TypeKeys &keys);
82  static QString getSettingTagFor(TypeKey);
83 };
84 
85 #endif
static std::vector< TypeKey > getSupportedKeys()
static QString getSettingTagFor(TypeKey)
static void initialiseEnvironmentVariables()
Update *_PATH environment variables from the settings, on application startup.
std::vector< TypeKey > TypeKeys
static QMutex m_mutex
static QString getOriginalEnvironmentValue(QString envVariable)
Return the original value observed on startup for the given environment variable, if it is one of the...
static std::map< QString, QString > m_originalEnvValues
static Paths getDefaultPaths()
Return default values of paths only, without any environment variables or user-defined preferences...
static Paths getPaths()
Return paths arising from user settings + environment variables + defaults as appropriate.
static Paths m_environmentPaths
std::pair< KnownPlugins::PluginType, KnownPlugins::BinaryFormat > TypeKey
static TypeKeys m_supportedKeys
static void savePathSettings(Paths paths)
Save the given paths to the settings.
static Paths getEnvironmentPathsUncached(const TypeKeys &keys)
static Paths getEnvironmentPaths()
Return paths arising from environment variables only, falling back to the defaults, without any user-defined preferences.
static Paths m_defaultPaths
std::map< TypeKey, PathConfig > Paths