3 |
|
|
4 |
#include "common.h" |
#include "common.h" |
5 |
|
|
6 |
#include "plugins/EchoPlugin.h" |
#include "EchoPlugin.h" |
7 |
|
#include "SpamPlugin.h" |
8 |
|
|
9 |
typedef std::map<std::string, Plugin*>::iterator MapIterator; |
typedef std::map<std::string, Plugin*>::iterator MapIterator; |
10 |
|
|
17 |
} |
} |
18 |
|
|
19 |
|
|
20 |
|
void PluginManager::AddPlugin(Plugin* plugin) |
21 |
|
{ |
22 |
|
_plugins[ plugin->GetCommand() ] = plugin; |
23 |
|
} |
24 |
|
|
25 |
void PluginManager::LoadPlugins() |
void PluginManager::LoadPlugins() |
26 |
{ |
{ |
27 |
Common* cmn = Common::instance(); |
Common* cmn = Common::instance(); |
28 |
|
|
29 |
|
|
30 |
static EchoPlugin echo; |
static EchoPlugin echo; |
31 |
_plugins[ echo.GetCommand() ] = &echo; |
_plugins[ echo.GetCommand() ] = &echo; |
32 |
|
|
33 |
|
static SpamPlugin spam; |
34 |
|
_plugins[ spam.GetCommand() ] = &spam; |
35 |
|
|
36 |
|
|
37 |
for(MapIterator it = _plugins.begin(); it != _plugins.end(); ++it) |
for(MapIterator it = _plugins.begin(); it != _plugins.end(); ++it) |
39 |
Plugin* pl = (*it).second; |
Plugin* pl = (*it).second; |
40 |
cmn->logMessage( std::string("Loaded plugin \"") + pl->GetCommand() + "\" - " + pl->GetDescription() ); |
cmn->logMessage( std::string("Loaded plugin \"") + pl->GetCommand() + "\" - " + pl->GetDescription() ); |
41 |
} |
} |
|
|
|
|
|
|
42 |
} |
} |
43 |
|
|
44 |
Plugin* PluginManager::GetPlugin(const std::string& pluginname) |
Plugin* PluginManager::GetPlugin(const std::string& pluginname) |