Mercurial > hg > svcore
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/plugin/PluginPathSetter.h Fri May 25 16:04:42 2018 +0100 @@ -0,0 +1,58 @@ +/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ + +/* + Sonic Visualiser + An audio file viewer and annotation editor. + Centre for Digital Music, Queen Mary, University of London. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. See the file + COPYING included with this distribution for more information. +*/ + +#ifndef SV_PLUGIN_PATH_SETTER_H +#define SV_PLUGIN_PATH_SETTER_H + +#include <QString> +#include <QStringList> +#include <QMutex> + +#include <map> + +class PluginPathSetter +{ +public: + /// Text used to identify a plugin type, e.g. "LADSPA", "Vamp" + typedef QString PluginTypeLabel; + + struct PathConfig { + QStringList directories; + QString envVariable; // e.g. "LADSPA_PATH" etc + bool useEnvVariable; // true if env variable overrides directories list + }; + + typedef std::map<PluginTypeLabel, PathConfig> Paths; + + /// Return paths arising from environment variables only, without + /// any user-defined preferences + static Paths getDefaultPaths(); + + /// Return paths arising from user settings + environment + /// variables as appropriate + static Paths getPaths(); + + /// Save the given paths to the settings + static void savePathSettings(Paths paths); + + /// Update *_PATH environment variables from the settings, on + /// application startup + static void setEnvironmentVariables(); + +private: + static Paths m_defaultPaths; + static QMutex m_mutex; +}; + +#endif