Subversion Repositories HomeAutomation

Rev

Rev 1309 | Rev 1311 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed

Rev 1309 Rev 1310
Line 8... Line 8...
8
#include "Variable.h"
8
#include "Variable.h"
9
 
9
 
10
namespace atom {
10
namespace atom {
11
namespace message {
11
namespace message {
12
 
12
 
13
Variable::Variable(string datatype, bool required, string unit)
13
Variable::Variable(string name, string datatype, bool required, string unit)
14
{
14
{
-
 
15
    this->myName = name;
15
    this->myRequired = required;
16
    this->myRequired = required;
16
    this->myUnit = unit;
17
    this->myUnit = unit;
17
 
18
 
18
    // TODO convert datatype-string into datatype and length
19
    xml::Node datatypeNode = db::Database::getInstance()->getRootNode().selectFirst("datatypes").selectFirst("datatype", xml::Node::attributePair("name", datatype));
-
 
20
 
19
    // this->myLength;
21
    this->myLength = stoi(datatypeNode["length"]);
20
    // this->myDatatype = Datatype_create(type);
22
    this->myDatatype = boost::make_shared<Datatype>(Datatype::getTypeFromString(datatypeNode["type"]));
21
}
23
}
22
 
24
 
23
Variable::Variable()
25
Variable::Variable()
24
{
26
{
25
}
27
}
26
 
28
 
27
Variable::~Variable()
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)
28
{
39
{
29
    // TODO Auto-generated destructor stub
40
    this->myDatatype->setValue(value);
30
}
41
}
31
 
42
 
32
void Variable::readBits(BitBuffer & buffer)
43
void Variable::readBits(BitBuffer & buffer)
33
{
44
{
34
    (*this->myDatatype).readBits(buffer, this->myLength);
45
    this->myDatatype->readBits(buffer, this->myLength);
35
}
46
}
36
 
47
 
37
}
48
}
38
}
49
}