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