/[projects]/smsdaemon/PluginManager.cpp
ViewVC logotype

Contents of /smsdaemon/PluginManager.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 28 - (show annotations) (download)
Mon Jun 9 20:56:03 2008 UTC (15 years, 11 months ago) by torben
File size: 1170 byte(s)
Restructured the plugins a little and implemented a spam plugin.


1
2 #include "PluginManager.h"
3
4 #include "common.h"
5
6 #include "EchoPlugin.h"
7 #include "SpamPlugin.h"
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::AddPlugin(Plugin* plugin)
21 {
22 _plugins[ plugin->GetCommand() ] = plugin;
23 }
24
25 void PluginManager::LoadPlugins()
26 {
27 Common* cmn = Common::instance();
28
29
30 static EchoPlugin echo;
31 _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)
38 {
39 Plugin* pl = (*it).second;
40 cmn->logMessage( std::string("Loaded plugin \"") + pl->GetCommand() + "\" - " + pl->GetDescription() );
41 }
42 }
43
44 Plugin* PluginManager::GetPlugin(const std::string& pluginname)
45 {
46 return _plugins[ pluginname ];
47 }
48
49
50 std::vector<Plugin*> PluginManager::GetPluginList()
51 {
52 typedef std::map<std::string, Plugin*>::iterator MapIterator;
53 std::vector<Plugin*> plugin_list;
54
55 for (MapIterator it = _plugins.begin(); it != _plugins.end(); ++it)
56 {
57 Plugin* pl = (*it).second;
58 plugin_list.push_back(pl);
59 }
60
61
62 return plugin_list;
63 }

  ViewVC Help
Powered by ViewVC 1.1.20