Subversion Repositories HomeAutomation

Rev

Rev 977 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | SVN | RSS feed

  1.  
  2. function ServiceManager() {}
  3.  
  4. ServiceManager.Services = new Array();
  5.  
  6. ServiceManager.getService = function(type, name, id)
  7. {
  8.     var fullId = name + id;
  9.  
  10.     if (!ServiceManager.Services[fullId])
  11.     {
  12.         if (eval("typeof " + name + " != 'function'"))///FIXME: eval = evil!
  13.         {
  14.             if (!loadScript(type + "/" + name + ".js"))
  15.             {
  16.                 //log("Could not load " + name + ".js\n");
  17.                 return null;
  18.             }
  19.         }
  20.        
  21.         ServiceManager.Services[fullId] = eval("(new " + name + "('" + type + "', '" + name + "', " + id + "))");///FIXME: Can we do this without eval??
  22.     }
  23.    
  24.     return ServiceManager.Services[fullId];
  25. }
  26.  
  27. ServiceManager.startService = function(type, name, id, args)
  28. {
  29.     var service = ServiceManager.getService(type, name, id);
  30.     if (service != null)
  31.     {
  32.         service.initialize(args);
  33.     }
  34. }
  35.