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

Diff of /smsdaemon/PluginManager.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 28 by torben, Mon Jun 9 20:56:03 2008 UTC revision 35 by torben, Tue Jun 10 14:38:59 2008 UTC
# Line 5  Line 5 
5    
6  #include "EchoPlugin.h"  #include "EchoPlugin.h"
7  #include "SpamPlugin.h"  #include "SpamPlugin.h"
8    #include "ShellExecPlugin.h"
9    
10    
11  typedef std::map<std::string, Plugin*>::iterator MapIterator;  typedef std::map<std::string, Plugin*>::iterator MapIterator;
12    
# Line 19  PluginManager::~PluginManager() Line 21  PluginManager::~PluginManager()
21    
22  void PluginManager::AddPlugin(Plugin* plugin)  void PluginManager::AddPlugin(Plugin* plugin)
23  {  {
24          _plugins[ plugin->GetCommand() ] = plugin;          Common* cmn = Common::instance();
25    
26            if (plugin != 0)
27            {
28                    std::string command = plugin->GetCommand();
29    
30                    if ( _plugins[ command ] == 0)
31                            _plugins[ command ] = plugin;
32                    else
33                            cmn->logMessage( std::string("AddPlugin() -- already have a plugin called ") + command);
34            }
35            else
36            {
37                    cmn->logMessage("AddPlugin() -- cannot register a null pointer");
38            }
39  }  }
40    
41  void PluginManager::LoadPlugins()  void PluginManager::LoadPlugins()
42  {  {
43          Common* cmn = Common::instance();          Common* cmn = Common::instance();
44    
   
45          static EchoPlugin echo;          static EchoPlugin echo;
         _plugins[ echo.GetCommand() ] = &echo;  
46    
47          static SpamPlugin spam;          static SpamPlugin spam;
48          _plugins[ spam.GetCommand() ] = &spam;  
49                    static ShellExecPlugin wake("wake", "/home/torben/bin/wake");
50                    
51    
52          for(MapIterator it = _plugins.begin(); it != _plugins.end(); ++it)          for(MapIterator it = _plugins.begin(); it != _plugins.end(); ++it)
53          {          {
54                  Plugin* pl = (*it).second;                  Plugin* pl = (*it).second;
55                  cmn->logMessage( std::string("Loaded plugin \"") + pl->GetCommand() + "\" - " + pl->GetDescription() );                  if (pl != 0)
56                            cmn->logMessage( std::string("Loaded plugin \"") + pl->GetCommand() + "\" - " + pl->GetDescription() );
57          }          }
58  }  }
59    

Legend:
Removed from v.28  
changed lines
  Added in v.35

  ViewVC Help
Powered by ViewVC 1.1.20