1 #include "DoubleValue.h"
3 #include "DoubleType.h"
17 DoubleValue::DoubleValue(Databoard::Type::DataType* dataBoard) : Value(dataBoard)
21 DoubleValue::~DoubleValue()
25 void DoubleValue::setValue(double value)
27 Databoard::Type::DoubleType* doubleType = dynamic_cast<Databoard::Type::DoubleType*>(dataBoard);
29 if(doubleType != NULL)
35 double DoubleValue::getValue()
40 std::string DoubleValue::writeOut(int /*indent*/)
44 std::stringstream oss;
46 //oss.setf(std::ios::fixed);
55 bool DoubleValue::equals(const Value* other)
57 DoubleValue* o = (DoubleValue*)other;
59 return (this->value < o->value);
62 std::string DoubleValue::isValid()
66 return "There is no datatype.";
69 Databoard::Type::DoubleType* doubleType = (Databoard::Type::DoubleType*)dataBoard;
71 if(doubleType->getRange() == NULL)
76 double minValue = doubleType->minValue();
77 double maxValue = doubleType->maxValue();
79 if(doubleType->getRange()->getLower()->getInclusive() == true)
83 return std::string("DoubleValue: ") + STR_ERROR_VALUE_SMALL;
86 else //if(integerType->getRange()->getLower()->getInclusive() == false)
88 if(value < minValue || (abs(value-minValue) < DBL_EPSILON))
90 return std::string("DoubleValue: ") + STR_ERROR_VALUE_SMALL;
94 if(doubleType->getRange()->getUpper()->getInclusive() == true)
98 return std::string("DoubleValue: ") + STR_ERROR_VALUE_LARGE;
101 else //if(integerType->getRange()->getUpper()->getInclusive() == false)
103 double d1 = abs(value-maxValue);
104 double d2 = DBL_EPSILON;
106 if(value > maxValue || (abs(value-maxValue) < DBL_EPSILON))
108 return std::string("DoubleValue: ") + STR_ERROR_VALUE_LARGE;