re-work VST paths configuration.
[ardour.git] / libs / ardour / ardour / plugin_manager.h
1 /*
2     Copyright (C) 2000-2007 Paul Davis
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 #ifndef __ardour_plugin_manager_h__
21 #define __ardour_plugin_manager_h__
22
23 #ifdef WAF_BUILD
24 #include "libardour-config.h"
25 #endif
26
27 #include <list>
28 #include <map>
29 #include <string>
30 #include <set>
31 #include <boost/utility.hpp>
32
33 #include "ardour/libardour_visibility.h"
34 #include "ardour/types.h"
35 #include "ardour/plugin.h"
36
37 namespace ARDOUR {
38
39 class Plugin;
40
41 class LIBARDOUR_API PluginManager : public boost::noncopyable {
42   public:
43         static PluginManager& instance();
44         static std::string scanner_bin_path;
45
46         ~PluginManager ();
47
48         ARDOUR::PluginInfoList &windows_vst_plugin_info ();
49         ARDOUR::PluginInfoList &lxvst_plugin_info ();
50         ARDOUR::PluginInfoList &ladspa_plugin_info ();
51         ARDOUR::PluginInfoList &lv2_plugin_info ();
52         ARDOUR::PluginInfoList &au_plugin_info ();
53
54         void refresh (bool cache_only = false);
55         void cancel_plugin_scan();
56         void clear_vst_cache ();
57         void clear_vst_blacklist ();
58
59         const std::string get_default_windows_vst_path() const { return windows_vst_path; }
60         const std::string get_default_lxvst_path() const { return lxvst_path; }
61
62         bool cancelled () { return cancel_scan; }
63
64         enum PluginStatusType {
65                 Normal = 0,
66                 Favorite,
67                 Hidden
68         };
69
70         void load_statuses ();
71         void save_statuses ();
72         void set_status (ARDOUR::PluginType type, std::string unique_id, PluginStatusType status);
73         PluginStatusType get_status (const PluginInfoPtr&);
74
75         /** plugins were added to or removed from one of the PluginInfoLists */
76         PBD::Signal0<void> PluginListChanged;
77
78   private:
79         struct PluginStatus {
80             ARDOUR::PluginType type;
81             std::string unique_id;
82             PluginStatusType status;
83
84             PluginStatus (ARDOUR::PluginType t, std::string id, PluginStatusType s = Normal)
85             : type (t), unique_id (id), status (s) {}
86
87             bool operator==(const PluginStatus& other) const {
88                     return other.type == type && other.unique_id == unique_id;
89             }
90
91             bool operator<(const PluginStatus& other) const {
92                     if (other.type < type) {
93                             return true;
94                     } else if (other.type == type && other.unique_id < unique_id) {
95                             return true;
96                     }
97                     return false;
98             }
99         };
100         typedef std::set<PluginStatus> PluginStatusList;
101         PluginStatusList statuses;
102
103         ARDOUR::PluginInfoList  _empty_plugin_info;
104         ARDOUR::PluginInfoList* _windows_vst_plugin_info;
105         ARDOUR::PluginInfoList* _lxvst_plugin_info;
106         ARDOUR::PluginInfoList* _ladspa_plugin_info;
107         ARDOUR::PluginInfoList* _lv2_plugin_info;
108         ARDOUR::PluginInfoList* _au_plugin_info;
109
110         std::map<uint32_t, std::string> rdf_type;
111
112         std::string windows_vst_path;
113         std::string lxvst_path;
114
115         bool cancel_scan;
116
117         void ladspa_refresh ();
118         void windows_vst_refresh (bool cache_only = false);
119         void lxvst_refresh (bool cache_only = false);
120
121         void add_lrdf_data (const std::string &path);
122         void add_ladspa_presets ();
123         void add_windows_vst_presets ();
124         void add_lxvst_presets ();
125         void add_presets (std::string domain);
126
127         void au_refresh ();
128
129         void lv2_refresh ();
130
131         int windows_vst_discover_from_path (std::string path, bool cache_only = false);
132         int windows_vst_discover (std::string path, bool cache_only = false);
133         
134         int lxvst_discover_from_path (std::string path, bool cache_only = false);
135         int lxvst_discover (std::string path, bool cache_only = false);
136
137         int ladspa_discover (std::string path);
138
139         std::string get_ladspa_category (uint32_t id);
140         std::vector<uint32_t> ladspa_plugin_whitelist;
141
142         static PluginManager* _instance; // singleton
143         PluginManager ();
144 };
145
146 } /* namespace ARDOUR */
147
148 #endif /* __ardour_plugin_manager_h__ */
149