Subversion Repositories HomeAutomation

Rev

Rev 1326 | Blame | Compare with Previous | Last modification | View Log | SVN | RSS feed

  1. /*
  2.  * Protocol.cpp
  3.  *
  4.  *  Created on: Jul 23, 2009
  5.  *      Author: Mattias Runge
  6.  */
  7.  
  8. #include "Protocol.h"
  9.  
  10. namespace atom {
  11.  
  12. Protocol::pointer Protocol::Instance(new Protocol());
  13.  
  14. Protocol::Protocol()
  15. {
  16.     this->myIsLoaded = false;
  17.     LOG.setName("Protocol");
  18. }
  19.  
  20. Protocol::~Protocol()
  21. {
  22. }
  23.  
  24. Protocol::pointer Protocol::getInstance()
  25. {
  26.     return Protocol::Instance;
  27. }
  28.  
  29. void Protocol::load(string filename, string cachefilename)
  30. {
  31.     this->myXmlNode.load(filename);
  32.  
  33.     LOG.info("Loaded protocol from \"" + filename + "\".");
  34.  
  35.     // TODO Catch exceptions thrown by load
  36.  
  37.     // TODO Do validation of XML-data, check if needed sections are defined
  38.  
  39.  
  40.     this->myXmlCacheNode.load(cachefilename);
  41.  
  42.     LOG.info("Loaded protocol cache from \"" + cachefilename + "\".");
  43.  
  44.     // TODO If not found generate one
  45.  
  46.     // TODO Check if versions match, if not update cache
  47.  
  48.     this->myIsLoaded = true;
  49. }
  50.  
  51. xml::Node & Protocol::getRootNode()
  52. {
  53.     return this->myXmlNode;
  54. }
  55.  
  56. xml::Node & Protocol::getRootCacheNode()
  57. {
  58.     return this->myXmlCacheNode;
  59. }
  60.  
  61. bool Protocol::isLoaded()
  62. {
  63.     return this->myIsLoaded;
  64. }
  65.  
  66. }
  67.  
  68.