Mania++
 All Classes Functions Variables Pages
PluginHandler.h
1 #ifndef PLUGINHANDLER_H_
2 #define PLUGINHANDLER_H_
3 
4 #include <string>
5 #include <map>
6 #include <functional>
7 #include <boost/any.hpp>
8 
9 #include "../Utils/VersionCompare.h"
10 
11 //* PluginInfo
15 struct PluginInfo
16 {
17  std::string Version;
18  std::string Author;
19  std::string Description;
21  void* Instance;
22  void* Handle;
24  std::map<std::string, std::function<boost::any(boost::any)>> Methods;
25 };
26 
28 {
29 public:
35  PluginHandler(std::map<std::string, PluginInfo>* pluginList);
36 
43  bool IsLoaded(std::string pluginName, std::string minVersion = "");
44 
52  boost::any CallMethod(std::string pluginName, std::string methodName, boost::any params);
53 
54 private:
55  std::map<std::string, PluginInfo>* plugins;
56 };
57 
58 #endif // PLUGINHANDLER_H_
boost::any CallMethod(std::string pluginName, std::string methodName, boost::any params)
Calls method on a different plugin.
Definition: PluginHandler.cpp:31
std::string Author
Plugin author (from instance).
Definition: PluginHandler.h:18
std::string Description
Plugin description (from instance).
Definition: PluginHandler.h:19
std::map< std::string, PluginInfo > * plugins
Pointer to the plugin list.
Definition: PluginHandler.h:55
PluginHandler(std::map< std::string, PluginInfo > *pluginList)
Handler constructor.
Definition: PluginHandler.cpp:3
void * Handle
Handle (from dlopen) of the plugin.
Definition: PluginHandler.h:22
Definition: PluginHandler.h:27
Struct with information about a plugin.
Definition: PluginHandler.h:15
void * Instance
Instance of the plugin.
Definition: PluginHandler.h:21
std::map< std::string, std::function< boost::any(boost::any)> > Methods
Callable methods of the plugin.
Definition: PluginHandler.h:24
std::string Version
Plugin version (from instance).
Definition: PluginHandler.h:17
bool IsLoaded(std::string pluginName, std::string minVersion="")
Checks if plugin is loaded (and is proper version).
Definition: PluginHandler.cpp:8