Open Lighting Architecture  0.9.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PluginManager.h
1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 2 of the License, or
5  * (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU Library General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software
14  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
15  *
16  * PluginManager.h
17  * Interface to the PluginManager class
18  * Copyright (C) 2005-2009 Simon Newton
19  */
20 
21 #ifndef OLAD_PLUGINMANAGER_H_
22 #define OLAD_PLUGINMANAGER_H_
23 
24 #include <map>
25 #include <vector>
26 
27 #include "ola/base/Macro.h"
28 
29 namespace ola {
30 
31 class PluginLoader;
32 class PluginAdaptor;
33 class AbstractPlugin;
34 
36  public:
37  PluginManager(const std::vector<PluginLoader*> &plugin_loaders,
38  PluginAdaptor *plugin_adaptor);
39  ~PluginManager();
40 
41  void LoadAll();
42  void UnloadAll();
43 
44  // Return a list of all loaded plugins, this includes active and inactive
45  // plugins.
46  void Plugins(std::vector<AbstractPlugin*> *plugins) const;
47 
48  // Return a list of all plugins that are active. Note that even though a
49  // plugin may be enabled, it may not be active due to conflicts with
50  // other plugins.
51  void ActivePlugins(std::vector<AbstractPlugin*> *plugins) const;
52 
53  // Lookup a plugin by ID
54  AbstractPlugin* GetPlugin(ola_plugin_id plugin_id) const;
55 
56  // Returns if a plugin is active.
57  bool IsActive(ola_plugin_id plugin_id) const;
58 
59  // Return a list of plugins that conflict with this plugin
60  void GetConflictList(ola_plugin_id plugin_id,
61  std::vector<AbstractPlugin*> *plugins);
62 
63  private:
64  typedef std::map<ola_plugin_id, AbstractPlugin*> PluginMap;
65 
66  std::vector<PluginLoader*> m_plugin_loaders;
67  PluginMap m_loaded_plugins; // plugins that are loaded
68  PluginMap m_active_plugins; // active plugins
69  PluginAdaptor *m_plugin_adaptor;
70 
71  DISALLOW_COPY_AND_ASSIGN(PluginManager);
72 };
73 } // namespace ola
74 #endif // OLAD_PLUGINMANAGER_H_