Subversion Repositories HomeAutomation

Rev

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

  1. /*
  2.  * Variable.cpp
  3.  *
  4.  *  Created on: Jul 21, 2009
  5.  *      Author: Mattias Runge
  6.  */
  7.  
  8. #include "Variable.h"
  9.  
  10. namespace atom {
  11. namespace message {
  12.  
  13. Variable::Variable(string name, string datatype, bool required, string unit)
  14. {
  15.     this->myName = name;
  16.     this->myRequired = required;
  17.     this->myUnit = unit;
  18.  
  19.     xml::Node datatypeNode = Protocol::getInstance()->getRootNode().selectFirst("datatypes").selectFirst("datatype", xml::Node::attributePair("name", datatype));
  20.  
  21.     this->myLength = stoi(datatypeNode["length"]);
  22.     this->myDatatype = boost::make_shared<Datatype>(Datatype::getTypeFromString(datatypeNode["type"]));
  23. }
  24.  
  25. Variable::Variable()
  26. {
  27. }
  28.  
  29. Variable::~Variable()
  30. {
  31. }
  32.  
  33. boost::any Variable::getValue()
  34. {
  35.     return this->myDatatype->getValue();
  36. }
  37.  
  38. void Variable::setValue(boost::any value)
  39. {
  40.     this->myDatatype->setValue(value);
  41. }
  42.  
  43. void Variable::readBits(BitBuffer & buffer)
  44. {
  45.     this->myDatatype->readBits(buffer, this->myLength);
  46. }
  47.  
  48. }
  49. }
  50.