Merge branch 'master' into cairocanvas
[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
45         ~PluginManager ();
46
47         ARDOUR::PluginInfoList &windows_vst_plugin_info ();
48         ARDOUR::PluginInfoList &lxvst_plugin_info ();
49         ARDOUR::PluginInfoList &ladspa_plugin_info ();
50         ARDOUR::PluginInfoList &lv2_plugin_info ();
51         ARDOUR::PluginInfoList &au_plugin_info ();
52
53         void refresh ();
54
55         int add_windows_vst_directory (std::string dirpath);
56         int add_lxvst_directory (std::string dirpath);
57
58         enum PluginStatusType {
59                 Normal = 0,
60                 Favorite,
61                 Hidden
62         };
63
64         void load_statuses ();
65         void save_statuses ();
66         void set_status (ARDOUR::PluginType type, std::string unique_id, PluginStatusType status);
67         PluginStatusType get_status (const PluginInfoPtr&);
68
69         /** plugins were added to or removed from one of the PluginInfoLists */
70         PBD::Signal0<void> PluginListChanged;
71
72   private:
73         struct PluginStatus {
74             ARDOUR::PluginType type;
75             std::string unique_id;
76             PluginStatusType status;
77
78             PluginStatus (ARDOUR::PluginType t, std::string id, PluginStatusType s = Normal)
79             : type (t), unique_id (id), status (s) {}
80
81             bool operator==(const PluginStatus& other) const {
82                     return other.type == type && other.unique_id == unique_id;
83             }
84
85             bool operator<(const PluginStatus& other) const {
86                     if (other.type < type) {
87                             return true;
88                     } else if (other.type == type && other.unique_id < unique_id) {
89                             return true;
90                     }
91                     return false;
92             }
93         };
94         typedef std::set<PluginStatus> PluginStatusList;
95         PluginStatusList statuses;
96
97         ARDOUR::PluginInfoList  _empty_plugin_info;
98         ARDOUR::PluginInfoList* _windows_vst_plugin_info;
99         ARDOUR::PluginInfoList* _lxvst_plugin_info;
100         ARDOUR::PluginInfoList* _ladspa_plugin_info;
101         ARDOUR::PluginInfoList* _lv2_plugin_info;
102         ARDOUR::PluginInfoList* _au_plugin_info;
103
104         std::map<uint32_t, std::string> rdf_type;
105
106         std::string windows_vst_path;
107         std::string lxvst_path;
108
109         void ladspa_refresh ();
110         void windows_vst_refresh ();
111         void lxvst_refresh ();
112
113         void add_lrdf_data (const std::string &path);
114         void add_ladspa_presets ();
115         void add_windows_vst_presets ();
116         void add_lxvst_presets ();
117         void add_presets (std::string domain);
118
119         void au_refresh ();
120
121         void lv2_refresh ();
122
123         int windows_vst_discover_from_path (std::string path);
124         int windows_vst_discover (std::string path);
125         
126         int lxvst_discover_from_path (std::string path);
127         int lxvst_discover (std::string path);
128
129         int ladspa_discover (std::string path);
130
131         std::string get_ladspa_category (uint32_t id);
132         std::vector<uint32_t> ladspa_plugin_whitelist;
133
134         static PluginManager* _instance; // singleton
135         PluginManager ();
136 };
137
138 } /* namespace ARDOUR */
139
140 #endif /* __ardour_plugin_manager_h__ */
141