Subversion Repositories HomeAutomation

Rev

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

  1. /*
  2.  * Header.cpp
  3.  *
  4.  *  Created on: Jul 23, 2009
  5.  *      Author: Mattias Runge
  6.  */
  7.  
  8. #include "Header.h"
  9.  
  10. namespace atom {
  11. namespace message {
  12.  
  13. Header::Header()
  14. {
  15.     xml::Node::nodeList nodes = Protocol::getInstance()->getRootNode().selectFirst("header").select("variable");
  16.  
  17.     for (unsigned int n = 0; n < nodes.size(); n++)
  18.     {
  19.         Variable variable(nodes[n]["name"], nodes[n]["datatype"], stob(nodes[n]["required"]), nodes[n]["unit"]);
  20.         this->myVariables[nodes[n]["name"]] = variable;
  21.     }
  22. }
  23.  
  24. Header::~Header()
  25. {
  26. }
  27.  
  28. Variable & Header::getVariable(string name)
  29. {
  30.     return this->myVariables[name];
  31.  
  32.     // TODO Check if it does not exist, throw exception?
  33. }
  34.  
  35. void Header::readBits(BitBuffer & buffer)
  36. {
  37.     for (variableMap::iterator iter = this->myVariables.begin(); iter != this->myVariables.end(); iter++)
  38.     {
  39.         iter->second.readBits(buffer);
  40.     }
  41. }
  42.  
  43. }
  44. }
  45.