Subversion Repositories HomeAutomation

Rev

Rev 1326 | 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
 
1323 runge 13
Variable::Variable(xml::Node xmlNode)
1309 runge 14
{
1323 runge 15
    this->myName = xmlNode["name"];
16
    this->myRequired = convert::string2bool(xmlNode["required"]);
17
    this->myUnit = xmlNode["unit"];
1309 runge 18
 
1323 runge 19
    this->myDatatype = Datatype::create(xmlNode["datatype"]);
1309 runge 20
}
21
 
22
Variable::Variable()
23
{
1328 runge 24
    LOG.setName("Variable");
1309 runge 25
}
26
 
27
Variable::~Variable()
28
{
29
}
30
 
1322 runge 31
string Variable::getName()
1310 runge 32
{
1322 runge 33
    return this->myName;
1310 runge 34
}
35
 
1322 runge 36
Datatype::pointer Variable::getDatatype()
1310 runge 37
{
1322 runge 38
    return this->myDatatype;
1310 runge 39
}
40
 
1322 runge 41
string Variable::getUnit()
42
{
43
    return this->myUnit;
44
}
45
 
46
bool Variable::isRequired()
47
{
48
    return this->myRequired;
49
}
50
 
1309 runge 51
void Variable::readBits(BitBuffer & buffer)
52
{
1322 runge 53
    this->myDatatype->readBits(buffer);
1309 runge 54
}
55
 
1322 runge 56
void Variable::writeBits(BitBuffer & buffer)
57
{
58
    this->myDatatype->writeBits(buffer);
1309 runge 59
}
1322 runge 60
 
1326 runge 61
string Variable::toString()
62
{
63
    string buffer = this->myName + "=" + this->myDatatype->toString();
64
 
65
    if (this->myUnit != "")
66
    {
67
        buffer += " " + this->myUnit;
68
    }
69
 
70
    return buffer;
1309 runge 71
}
1326 runge 72
 
1322 runge 73
}
1326 runge 74
}