Rev 1309 | Rev 1311 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | SVN | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 1309 | runge | 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 | |||
| 1310 | runge | 13 | Variable::Variable(string name, string datatype, bool required, string unit) |
| 1309 | runge | 14 | { |
| 1310 | runge | 15 | this->myName = name; |
| 1309 | runge | 16 | this->myRequired = required; |
| 17 | this->myUnit = unit; |
||
| 18 | |||
| 1310 | runge | 19 | xml::Node datatypeNode = db::Database::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"])); |
||
| 1309 | runge | 23 | } |
| 24 | |||
| 25 | Variable::Variable() |
||
| 26 | { |
||
| 27 | } |
||
| 28 | |||
| 29 | Variable::~Variable() |
||
| 30 | { |
||
| 31 | } |
||
| 32 | |||
| 1310 | runge | 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 | |||
| 1309 | runge | 43 | void Variable::readBits(BitBuffer & buffer) |
| 44 | { |
||
| 1310 | runge | 45 | this->myDatatype->readBits(buffer, this->myLength); |
| 1309 | runge | 46 | } |
| 47 | |||
| 48 | } |
||
| 49 | } |