annotate plugin/PluginPathSetter.h @ 1472:5d7057af0c68 plugin-path-config

Add class to get/set/remember the plugin path for each plugin type
author Chris Cannam
date Fri, 25 May 2018 16:04:42 +0100
parents
children f52bf66b9096
rev   line source
Chris@1472 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@1472 2
Chris@1472 3 /*
Chris@1472 4 Sonic Visualiser
Chris@1472 5 An audio file viewer and annotation editor.
Chris@1472 6 Centre for Digital Music, Queen Mary, University of London.
Chris@1472 7
Chris@1472 8 This program is free software; you can redistribute it and/or
Chris@1472 9 modify it under the terms of the GNU General Public License as
Chris@1472 10 published by the Free Software Foundation; either version 2 of the
Chris@1472 11 License, or (at your option) any later version. See the file
Chris@1472 12 COPYING included with this distribution for more information.
Chris@1472 13 */
Chris@1472 14
Chris@1472 15 #ifndef SV_PLUGIN_PATH_SETTER_H
Chris@1472 16 #define SV_PLUGIN_PATH_SETTER_H
Chris@1472 17
Chris@1472 18 #include <QString>
Chris@1472 19 #include <QStringList>
Chris@1472 20 #include <QMutex>
Chris@1472 21
Chris@1472 22 #include <map>
Chris@1472 23
Chris@1472 24 class PluginPathSetter
Chris@1472 25 {
Chris@1472 26 public:
Chris@1472 27 /// Text used to identify a plugin type, e.g. "LADSPA", "Vamp"
Chris@1472 28 typedef QString PluginTypeLabel;
Chris@1472 29
Chris@1472 30 struct PathConfig {
Chris@1472 31 QStringList directories;
Chris@1472 32 QString envVariable; // e.g. "LADSPA_PATH" etc
Chris@1472 33 bool useEnvVariable; // true if env variable overrides directories list
Chris@1472 34 };
Chris@1472 35
Chris@1472 36 typedef std::map<PluginTypeLabel, PathConfig> Paths;
Chris@1472 37
Chris@1472 38 /// Return paths arising from environment variables only, without
Chris@1472 39 /// any user-defined preferences
Chris@1472 40 static Paths getDefaultPaths();
Chris@1472 41
Chris@1472 42 /// Return paths arising from user settings + environment
Chris@1472 43 /// variables as appropriate
Chris@1472 44 static Paths getPaths();
Chris@1472 45
Chris@1472 46 /// Save the given paths to the settings
Chris@1472 47 static void savePathSettings(Paths paths);
Chris@1472 48
Chris@1472 49 /// Update *_PATH environment variables from the settings, on
Chris@1472 50 /// application startup
Chris@1472 51 static void setEnvironmentVariables();
Chris@1472 52
Chris@1472 53 private:
Chris@1472 54 static Paths m_defaultPaths;
Chris@1472 55 static QMutex m_mutex;
Chris@1472 56 };
Chris@1472 57
Chris@1472 58 #endif