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