X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=bundles%2Forg.simantics.databoard%2Fcpp%2FDataBoardTest%2FDataBoard%2FDoubleValue.cpp;h=23a027ec305c439dd733becd4d6c6feedc835069;hb=refs%2Fchanges%2F38%2F238%2F2;hp=258cc4b7a2fc52a91816ee1c0e25e40c4aed7fbf;hpb=24e2b34260f219f0d1644ca7a138894980e25b14;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.databoard/cpp/DataBoardTest/DataBoard/DoubleValue.cpp b/bundles/org.simantics.databoard/cpp/DataBoardTest/DataBoard/DoubleValue.cpp index 258cc4b7a..23a027ec3 100644 --- a/bundles/org.simantics.databoard/cpp/DataBoardTest/DataBoard/DoubleValue.cpp +++ b/bundles/org.simantics.databoard/cpp/DataBoardTest/DataBoard/DoubleValue.cpp @@ -1,115 +1,115 @@ -#include "DoubleValue.h" - -#include "DoubleType.h" -#include "Constants.h" - -#include "Range.h" -#include "Limit.h" - -#include -#include -#include -#include -#include - -namespace Databoard { - namespace Value { - DoubleValue::DoubleValue(Databoard::Type::DataType* dataBoard) : Value(dataBoard) - { - } - - DoubleValue::~DoubleValue() - { - } - - void DoubleValue::setValue(double value) - { - Databoard::Type::DoubleType* doubleType = dynamic_cast(dataBoard); - - if(doubleType != NULL) - { - this->value = value; - } - } - - double DoubleValue::getValue() - { - return value; - } - - std::string DoubleValue::writeOut(int /*indent*/) - { - std::string s; - - std::stringstream oss; - - //oss.setf(std::ios::fixed); - - oss << value; - - oss >> s; - - return s; - } - - bool DoubleValue::equals(const Value* other) - { - DoubleValue* o = (DoubleValue*)other; - - return (this->value < o->value); - } - - std::string DoubleValue::isValid() - { - if(dataBoard == NULL) - { - return "There is no datatype."; - } - - Databoard::Type::DoubleType* doubleType = (Databoard::Type::DoubleType*)dataBoard; - - if(doubleType->getRange() == NULL) - { - return STR_EMPTY; - } - - double minValue = doubleType->minValue(); - double maxValue = doubleType->maxValue(); - - if(doubleType->getRange()->getLower()->getInclusive() == true) - { - if(value < minValue) - { - return std::string("DoubleValue: ") + STR_ERROR_VALUE_SMALL; - } - } - else //if(integerType->getRange()->getLower()->getInclusive() == false) - { - if(value < minValue || (abs(value-minValue) < DBL_EPSILON)) - { - return std::string("DoubleValue: ") + STR_ERROR_VALUE_SMALL; - } - } - - if(doubleType->getRange()->getUpper()->getInclusive() == true) - { - if(value > maxValue) - { - return std::string("DoubleValue: ") + STR_ERROR_VALUE_LARGE; - } - } - else //if(integerType->getRange()->getUpper()->getInclusive() == false) - { - double d1 = abs(value-maxValue); - double d2 = DBL_EPSILON; - - if(value > maxValue || (abs(value-maxValue) < DBL_EPSILON)) - { - return std::string("DoubleValue: ") + STR_ERROR_VALUE_LARGE; - } - } - - return STR_EMPTY; - } - } -} +#include "DoubleValue.h" + +#include "DoubleType.h" +#include "Constants.h" + +#include "Range.h" +#include "Limit.h" + +#include +#include +#include +#include +#include + +namespace Databoard { + namespace Value { + DoubleValue::DoubleValue(Databoard::Type::DataType* dataBoard) : Value(dataBoard) + { + } + + DoubleValue::~DoubleValue() + { + } + + void DoubleValue::setValue(double value) + { + Databoard::Type::DoubleType* doubleType = dynamic_cast(dataBoard); + + if(doubleType != NULL) + { + this->value = value; + } + } + + double DoubleValue::getValue() + { + return value; + } + + std::string DoubleValue::writeOut(int /*indent*/) + { + std::string s; + + std::stringstream oss; + + //oss.setf(std::ios::fixed); + + oss << value; + + oss >> s; + + return s; + } + + bool DoubleValue::equals(const Value* other) + { + DoubleValue* o = (DoubleValue*)other; + + return (this->value < o->value); + } + + std::string DoubleValue::isValid() + { + if(dataBoard == NULL) + { + return "There is no datatype."; + } + + Databoard::Type::DoubleType* doubleType = (Databoard::Type::DoubleType*)dataBoard; + + if(doubleType->getRange() == NULL) + { + return STR_EMPTY; + } + + double minValue = doubleType->minValue(); + double maxValue = doubleType->maxValue(); + + if(doubleType->getRange()->getLower()->getInclusive() == true) + { + if(value < minValue) + { + return std::string("DoubleValue: ") + STR_ERROR_VALUE_SMALL; + } + } + else //if(integerType->getRange()->getLower()->getInclusive() == false) + { + if(value < minValue || (abs(value-minValue) < DBL_EPSILON)) + { + return std::string("DoubleValue: ") + STR_ERROR_VALUE_SMALL; + } + } + + if(doubleType->getRange()->getUpper()->getInclusive() == true) + { + if(value > maxValue) + { + return std::string("DoubleValue: ") + STR_ERROR_VALUE_LARGE; + } + } + else //if(integerType->getRange()->getUpper()->getInclusive() == false) + { + double d1 = abs(value-maxValue); + double d2 = DBL_EPSILON; + + if(value > maxValue || (abs(value-maxValue) < DBL_EPSILON)) + { + return std::string("DoubleValue: ") + STR_ERROR_VALUE_LARGE; + } + } + + return STR_EMPTY; + } + } +}