1 #include "FloatValue.h"
14 FloatValue::FloatValue(Databoard::Type::DataType* dataBoard) : Value(dataBoard)
18 FloatValue::~FloatValue()
22 void FloatValue::setValue(float value)
24 Databoard::Type::FloatType* floatType = dynamic_cast<Databoard::Type::FloatType*>(dataBoard);
32 float FloatValue::getValue()
37 std::string FloatValue::writeOut(int /*indent*/)
41 std::stringstream oss;
47 //if(unit.size() != 0)
49 // s += "(Unit=\"" + unit + "\")";
55 bool FloatValue::equals(const Value* other)
57 FloatValue* o = (FloatValue*)other;
59 return (this->value < o->value);
63 std::string FloatValue::isValid()
67 return "There is no datatype.";
70 Databoard::Type::FloatType* floatType = (Databoard::Type::FloatType*)dataBoard;
72 if(floatType->getRange() == NULL)
77 double minValue = floatType->minValue();
78 double maxValue = floatType->maxValue();
80 if(floatType->getRange()->getLower()->getInclusive() == true)
84 return std::string("FloatValue: ") + STR_ERROR_VALUE_SMALL;
87 else //if(integerType->getRange()->getLower()->getInclusive() == false)
89 if(value < minValue || (abs(value-minValue) < FLT_EPSILON))
91 return std::string("FloatValue: ") + STR_ERROR_VALUE_SMALL;
95 if(floatType->getRange()->getUpper()->getInclusive() == true)
99 return std::string("FloatValue: ") + STR_ERROR_VALUE_LARGE;
102 else //if(integerType->getRange()->getUpper()->getInclusive() == false)
104 if(value > maxValue || (abs(value-minValue) > FLT_EPSILON))
106 return std::string("FloatValue: ") + STR_ERROR_VALUE_LARGE;