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