Mania++
 All Classes Functions Variables Pages
PluginManager.h
1 #ifndef PLUGINMANAGER_H_
2 #define PLUGINMANAGER_H_
3 
4 #include <string>
5 #include <vector>
6 #include <iostream>
7 #include <dirent.h>
8 #include <stdio.h>
9 #include <dlfcn.h>
10 
11 #include "../Config/Config.h"
12 #include "../Events/EventManager.h"
13 #include "../Commands/CommandManager.h"
14 #include "../Methods/Methods.h"
15 
16 #include "Plugin.h"
17 
18 //* PluginInfo
22 struct PluginInfo
23 {
24  std::string Version;
25  std::string Author;
28  void* Handle;
29 };
30 
31 //* PluginManager
36 {
37 public:
49  PluginManager(Config* configPtr, Methods* methodsPtr, CommandManager* commandsPtr, std::map<std::string, Player>* playersPtr, MapList* mapsPtr, sql::Connection* databasePtr, UIManager* uiPtr);
50 
55 
61  void SetEventManager(EventManager* eventManagerPtr);
62 
68  void LoadPlugins(std::string pluginsFolder = "./plugins");
69 
73  void InitializePlugins();
74 
75 private:
79  std::map<std::string, std::string> discoverPlugins(std::string pluginsFolder);
80 
81  std::map<std::string, PluginInfo> plugins;
86 };
87 
88 #endif // PLUGINMANAGER_H_
void InitializePlugins()
Calls all Init() functions in the plugins (called after loading all plugins).
Definition: PluginManager.cpp:144
PluginManager(Config *configPtr, Methods *methodsPtr, CommandManager *commandsPtr, std::map< std::string, Player > *playersPtr, MapList *mapsPtr, sql::Connection *databasePtr, UIManager *uiPtr)
Initializes the pointers the plugins need.
Definition: PluginManager.cpp:3
Manages the plugins.
Definition: PluginManager.h:35
std::string Author
Plugin author (from instance).
Definition: PluginManager.h:25
std::map< std::string, PluginInfo > plugins
Vector of loaded plugins.
Definition: PluginManager.h:81
Manages the user interface on the server (ManiaLinks).
Definition: UIManager.h:17
std::map< std::string, std::string > discoverPlugins(std::string pluginsFolder)
Disovers plugin (.so) files in the specified folder.
Definition: PluginManager.cpp:156
Reads and stores configuration information.
Definition: Config.h:65
void SetEventManager(EventManager *eventManagerPtr)
Sets the event manager to be used for callbacks.
Definition: PluginManager.cpp:37
Plugin interface, inherited by all plugins.
Definition: Plugin.h:44
Contains the maplist and a pointer to the current map.
Definition: MapList.h:10
void * Handle
Handle (from dlopen) of the plugin.
Definition: PluginManager.h:28
Plugin * Instance
Instance of the plugin.
Definition: PluginManager.h:27
Contains all server methods and returns usable data types.
Definition: Methods.h:14
Controller * controller
Current instance of the controller.
Definition: PluginManager.h:85
EventManager * events
Current instance of the EventManager.
Definition: PluginManager.h:84
~PluginManager()
Destructor closes all open plugins.
Definition: PluginManager.cpp:24
Struct with all instances needed for plugins.
Definition: Plugin.h:31
CommandManager * commands
Current instance of the CommandManager.
Definition: PluginManager.h:83
Struct with information about a plugin.
Definition: PluginManager.h:22
void LoadPlugins(std::string pluginsFolder="./plugins")
Loads the plugins in the specified folder.
Definition: PluginManager.cpp:44
std::string Version
Plugin version (from instance).
Definition: PluginManager.h:24
Config * config
Current instance of the Config.
Definition: PluginManager.h:82
Handles events (callbacks) from server to plugins.
Definition: EventManager.h:15
Manages the chat commands.
Definition: CommandManager.h:14