Open Lighting Architecture  0.9.6
 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
15  *
16  * PluginManager.h
17  * Interface to the PluginManager class
18  * Copyright (C) 2005 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 #include "ola/plugin_id.h"
29 
30 namespace ola {
31 
32 class PluginLoader;
33 class PluginAdaptor;
34 class AbstractPlugin;
35 
53  public:
59  PluginManager(const std::vector<PluginLoader*> &plugin_loaders,
60  PluginAdaptor *plugin_adaptor);
61 
66 
72  void LoadAll();
73 
77  void UnloadAll();
78 
85  void Plugins(std::vector<AbstractPlugin*> *plugins) const;
86 
91  void ActivePlugins(std::vector<AbstractPlugin*> *plugins) const;
92 
97  void EnabledPlugins(std::vector<AbstractPlugin*> *plugins) const;
98 
104  AbstractPlugin* GetPlugin(ola_plugin_id plugin_id) const;
105 
111  bool IsActive(ola_plugin_id plugin_id) const;
112 
118  bool IsEnabled(ola_plugin_id plugin_id) const;
119 
129  bool EnableAndStartPlugin(ola_plugin_id plugin_id);
130 
135  void DisableAndStopPlugin(ola_plugin_id plugin_id);
136 
142  void GetConflictList(ola_plugin_id plugin_id,
143  std::vector<AbstractPlugin*> *plugins);
144 
145  private:
146  typedef std::map<ola_plugin_id, AbstractPlugin*> PluginMap;
147 
148  std::vector<PluginLoader*> m_plugin_loaders;
149  PluginMap m_loaded_plugins; // plugins that are loaded
150  PluginMap m_active_plugins; // active plugins
151  PluginMap m_enabled_plugins; // enabled plugins
152  PluginAdaptor *m_plugin_adaptor;
153 
154  bool StartIfSafe(AbstractPlugin *plugin);
155  AbstractPlugin* CheckForRunningConflicts(const AbstractPlugin *plugin) const;
156 
157  DISALLOW_COPY_AND_ASSIGN(PluginManager);
158 };
159 } // namespace ola
160 #endif // OLAD_PLUGINMANAGER_H_