Subversion Repositories HomeAutomation

Rev

Rev 1323 | 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
 
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
{
24
}
25
 
26
Variable::~Variable()
27
{
28
}
29
 
1322 runge 30
string Variable::getName()
1310 runge 31
{
1322 runge 32
    return this->myName;
1310 runge 33
}
34
 
1322 runge 35
Datatype::pointer Variable::getDatatype()
1310 runge 36
{
1322 runge 37
    return this->myDatatype;
1310 runge 38
}
39
 
1322 runge 40
string Variable::getUnit()
41
{
42
    return this->myUnit;
43
}
44
 
45
bool Variable::isRequired()
46
{
47
    return this->myRequired;
48
}
49
 
1309 runge 50
void Variable::readBits(BitBuffer & buffer)
51
{
1322 runge 52
    this->myDatatype->readBits(buffer);
1309 runge 53
}
54
 
1322 runge 55
void Variable::writeBits(BitBuffer & buffer)
56
{
57
    this->myDatatype->writeBits(buffer);
1309 runge 58
}
1322 runge 59
 
1326 runge 60
string Variable::toString()
61
{
62
    string buffer = this->myName + "=" + this->myDatatype->toString();
63
 
64
    if (this->myUnit != "")
65
    {
66
        buffer += " " + this->myUnit;
67
    }
68
 
69
    return buffer;
1309 runge 70
}
1326 runge 71
 
1322 runge 72
}
1326 runge 73
}