1 |
|
2 |
#include "PluginManager.h" |
3 |
|
4 |
#include "common.h" |
5 |
|
6 |
#include "EchoPlugin.h" |
7 |
|
8 |
|
9 |
typedef std::map<std::string, Plugin*>::iterator MapIterator; |
10 |
|
11 |
PluginManager::PluginManager() |
12 |
{ |
13 |
} |
14 |
|
15 |
PluginManager::~PluginManager() |
16 |
{ |
17 |
} |
18 |
|
19 |
|
20 |
void PluginManager::LoadPlugins() |
21 |
{ |
22 |
Common* cmn = Common::instance(); |
23 |
|
24 |
static EchoPlugin echo; |
25 |
_plugins[ echo.GetCommand() ] = &echo; |
26 |
|
27 |
|
28 |
for(MapIterator it = _plugins.begin(); it != _plugins.end(); ++it) |
29 |
{ |
30 |
Plugin* pl = (*it).second; |
31 |
cmn->logMessage( std::string("Loaded plugin \"") + pl->GetCommand() + "\" - " + pl->GetDescription() ); |
32 |
} |
33 |
|
34 |
|
35 |
} |
36 |
|
37 |
Plugin* PluginManager::GetPlugin(const std::string& pluginname) |
38 |
{ |
39 |
return _plugins[ pluginname ]; |
40 |
} |
41 |
|
42 |
|
43 |
std::vector<Plugin*> PluginManager::GetPluginList() |
44 |
{ |
45 |
typedef std::map<std::string, Plugin*>::iterator MapIterator; |
46 |
std::vector<Plugin*> plugin_list; |
47 |
|
48 |
for (MapIterator it = _plugins.begin(); it != _plugins.end(); ++it) |
49 |
{ |
50 |
Plugin* pl = (*it).second; |
51 |
plugin_list.push_back(pl); |
52 |
} |
53 |
|
54 |
|
55 |
return plugin_list; |
56 |
} |