-#include "DoubleValue.h"\r
-\r
-#include "DoubleType.h"\r
-#include "Constants.h"\r
-\r
-#include "Range.h"\r
-#include "Limit.h"\r
-\r
-#include <sstream>\r
-#include <iomanip>\r
-#include <iostream>\r
-#include <valarray>\r
-#include <cfloat>\r
-\r
-namespace Databoard {\r
- namespace Value {\r
- DoubleValue::DoubleValue(Databoard::Type::DataType* dataBoard) : Value(dataBoard)\r
- {\r
- }\r
-\r
- DoubleValue::~DoubleValue()\r
- {\r
- }\r
-\r
- void DoubleValue::setValue(double value)\r
- {\r
- Databoard::Type::DoubleType* doubleType = dynamic_cast<Databoard::Type::DoubleType*>(dataBoard);\r
-\r
- if(doubleType != NULL)\r
- {\r
- this->value = value;\r
- }\r
- }\r
-\r
- double DoubleValue::getValue()\r
- {\r
- return value;\r
- }\r
-\r
- std::string DoubleValue::writeOut(int /*indent*/)\r
- {\r
- std::string s;\r
-\r
- std::stringstream oss;\r
-\r
- //oss.setf(std::ios::fixed);\r
-\r
- oss << value;\r
-\r
- oss >> s;\r
-\r
- return s;\r
- }\r
-\r
- bool DoubleValue::equals(const Value* other)\r
- {\r
- DoubleValue* o = (DoubleValue*)other;\r
-\r
- return (this->value < o->value);\r
- }\r
-\r
- std::string DoubleValue::isValid()\r
- {\r
- if(dataBoard == NULL)\r
- {\r
- return "There is no datatype.";\r
- }\r
-\r
- Databoard::Type::DoubleType* doubleType = (Databoard::Type::DoubleType*)dataBoard;\r
-\r
- if(doubleType->getRange() == NULL)\r
- {\r
- return STR_EMPTY;\r
- }\r
-\r
- double minValue = doubleType->minValue();\r
- double maxValue = doubleType->maxValue();\r
-\r
- if(doubleType->getRange()->getLower()->getInclusive() == true)\r
- {\r
- if(value < minValue)\r
- {\r
- return std::string("DoubleValue: ") + STR_ERROR_VALUE_SMALL;\r
- }\r
- }\r
- else //if(integerType->getRange()->getLower()->getInclusive() == false)\r
- {\r
- if(value < minValue || (abs(value-minValue) < DBL_EPSILON))\r
- {\r
- return std::string("DoubleValue: ") + STR_ERROR_VALUE_SMALL;\r
- }\r
- }\r
-\r
- if(doubleType->getRange()->getUpper()->getInclusive() == true)\r
- {\r
- if(value > maxValue)\r
- {\r
- return std::string("DoubleValue: ") + STR_ERROR_VALUE_LARGE;\r
- }\r
- }\r
- else //if(integerType->getRange()->getUpper()->getInclusive() == false)\r
- {\r
- double d1 = abs(value-maxValue);\r
- double d2 = DBL_EPSILON;\r
-\r
- if(value > maxValue || (abs(value-maxValue) < DBL_EPSILON))\r
- {\r
- return std::string("DoubleValue: ") + STR_ERROR_VALUE_LARGE;\r
- }\r
- }\r
-\r
- return STR_EMPTY;\r
- }\r
- }\r
-}\r
+#include "DoubleValue.h"
+
+#include "DoubleType.h"
+#include "Constants.h"
+
+#include "Range.h"
+#include "Limit.h"
+
+#include <sstream>
+#include <iomanip>
+#include <iostream>
+#include <valarray>
+#include <cfloat>
+
+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::Type::DoubleType*>(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;
+ }
+ }
+}