Open Lighting Architecture  Latest Git
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules 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_
void Plugins(std::vector< AbstractPlugin * > *plugins) const
Return the list of loaded plugins.
Definition: PluginManager.cpp:103
bool EnableAndStartPlugin(ola_plugin_id plugin_id)
Enable & start a plugin.
Definition: PluginManager.cpp:145
The manager of plugins.
Definition: PluginManager.h:52
void GetConflictList(ola_plugin_id plugin_id, std::vector< AbstractPlugin * > *plugins)
Return a list of plugins that conflict with this particular plugin.
Definition: PluginManager.cpp:163
void LoadAll()
Attempt to load all the plugins and start them.
Definition: PluginManager.cpp:46
void UnloadAll()
Definition: PluginManager.cpp:87
Definition: PluginAdaptor.h:41
void DisableAndStopPlugin(ola_plugin_id plugin_id)
Disable & stop a plugin.
Definition: PluginManager.cpp:130
void ActivePlugins(std::vector< AbstractPlugin * > *plugins) const
Return a list of active plugins.
Definition: PluginManager.cpp:108
PluginManager(const std::vector< PluginLoader * > &plugin_loaders, PluginAdaptor *plugin_adaptor)
Create a new PluginManager.
Definition: PluginManager.cpp:36
AbstractPlugin * GetPlugin(ola_plugin_id plugin_id) const
Lookup a plugin by ID.
Definition: PluginManager.cpp:118
Helper macros.
bool IsActive(ola_plugin_id plugin_id) const
Check if a plugin is active.
Definition: PluginManager.cpp:122
The namespace containing all OLA symbols.
Definition: Credentials.cpp:44
bool IsEnabled(ola_plugin_id plugin_id) const
Check if a plugin is enabled.
Definition: PluginManager.cpp:126
void EnabledPlugins(std::vector< AbstractPlugin * > *plugins) const
Return a list of enabled plugins.
Definition: PluginManager.cpp:113
~PluginManager()
Destructor.
Definition: PluginManager.cpp:42
Definition: Plugin.h:38