merge pre- and post-fader processor boxes; start removing Placement (not finished...
[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 #ifdef HAVE_SLV2
37 #include "ardour/lv2_plugin.h"
38 #endif
39
40 namespace ARDOUR {
41
42 class Plugin;
43
44 class PluginManager : public boost::noncopyable {
45   public:
46         PluginManager ();
47         ~PluginManager ();
48
49         /* realtime plugin APIs */
50
51         ARDOUR::PluginInfoList &vst_plugin_info ()    { return _vst_plugin_info; }
52         ARDOUR::PluginInfoList &ladspa_plugin_info () { return _ladspa_plugin_info; }
53         ARDOUR::PluginInfoList &lv2_plugin_info ()    { return _lv2_plugin_info; }
54         ARDOUR::PluginInfoList &au_plugin_info ()     { return _au_plugin_info; }
55
56         void refresh ();
57
58         int add_ladspa_directory (std::string dirpath);
59         int add_vst_directory (std::string dirpath);
60
61         static PluginManager* the_manager() { return _manager; }
62
63         void load_favorites ();
64         void save_favorites ();
65         void add_favorite (ARDOUR::PluginType type, std::string unique_id);
66         void remove_favorite (ARDOUR::PluginType type, std::string unique_id);
67         bool is_a_favorite_plugin (const PluginInfoPtr&);
68         
69   private:
70         struct FavoritePlugin {
71             ARDOUR::PluginType type;
72             std::string unique_id;
73
74             FavoritePlugin (ARDOUR::PluginType t, std::string id) 
75             : type (t), unique_id (id) {}
76             
77             bool operator==(const FavoritePlugin& other) const {
78                     return other.type == type && other.unique_id == unique_id;
79             }
80
81             bool operator<(const FavoritePlugin& other) const {
82                     return other.type < type || other.unique_id < unique_id;
83             }
84         };
85         typedef std::set<FavoritePlugin> FavoritePluginList;
86         FavoritePluginList favorites;
87
88         ARDOUR::PluginInfoList _vst_plugin_info;
89         ARDOUR::PluginInfoList _ladspa_plugin_info;
90         ARDOUR::PluginInfoList _lv2_plugin_info;
91         ARDOUR::PluginInfoList _au_plugin_info;
92
93 #ifdef HAVE_SLV2
94         LV2World* _lv2_world;
95 #endif
96         
97         std::map<uint32_t, std::string> rdf_type;
98
99         std::string ladspa_path;
100         std::string vst_path;
101
102         void ladspa_refresh ();
103         void vst_refresh ();
104
105         void add_lrdf_data (const std::string &path);
106         void add_ladspa_presets ();
107         void add_vst_presets ();
108         void add_presets (std::string domain);
109
110         int au_discover ();
111         void au_refresh ();
112         
113         int lv2_discover ();
114         void lv2_refresh ();
115
116         int vst_discover_from_path (std::string path);
117         int vst_discover (std::string path);
118
119         int ladspa_discover_from_path (std::string path);
120         int ladspa_discover (std::string path);
121
122         std::string get_ladspa_category (uint32_t id);
123         std::vector<uint32_t> ladspa_plugin_whitelist;
124
125         static PluginManager* _manager; // singleton
126 };
127
128 } /* namespace ARDOUR */
129
130 #endif /* __ardour_plugin_manager_h__ */
131