-#include "FloatValue.h"\r
-\r
-#include "FloatType.h"\r
-#include "Constants.h"\r
-#include "Range.h"\r
-#include "Limit.h"\r
-\r
-#include <sstream>\r
-#include <cfloat>\r
-#include <valarray>\r
-\r
-namespace Databoard {\r
- namespace Value {\r
- FloatValue::FloatValue(Databoard::Type::DataType* dataBoard) : Value(dataBoard)\r
- {\r
- }\r
-\r
- FloatValue::~FloatValue()\r
- {\r
- }\r
-\r
- void FloatValue::setValue(float value)\r
- {\r
- Databoard::Type::FloatType* floatType = dynamic_cast<Databoard::Type::FloatType*>(dataBoard);\r
-\r
- if(floatType != NULL)\r
- {\r
- this->value = value;\r
- }\r
- }\r
-\r
- float FloatValue::getValue()\r
- {\r
- return value;\r
- }\r
-\r
- std::string FloatValue::writeOut(int /*indent*/)\r
- {\r
- std::string s;\r
-\r
- std::stringstream oss;\r
-\r
- oss << value;\r
-\r
- oss >> s;\r
-\r
- //if(unit.size() != 0)\r
- //{\r
- // s += "(Unit=\"" + unit + "\")";\r
- //}\r
-\r
- return s;\r
- }\r
-\r
- bool FloatValue::equals(const Value* other)\r
- {\r
- FloatValue* o = (FloatValue*)other;\r
-\r
- return (this->value < o->value);\r
-\r
- }\r
-\r
- std::string FloatValue::isValid()\r
- {\r
- if(dataBoard == NULL)\r
- {\r
- return "There is no datatype.";\r
- }\r
-\r
- Databoard::Type::FloatType* floatType = (Databoard::Type::FloatType*)dataBoard;\r
-\r
- if(floatType->getRange() == NULL)\r
- {\r
- return STR_EMPTY;\r
- }\r
-\r
- double minValue = floatType->minValue();\r
- double maxValue = floatType->maxValue();\r
-\r
- if(floatType->getRange()->getLower()->getInclusive() == true)\r
- {\r
- if(value < minValue)\r
- {\r
- return std::string("FloatValue: ") + STR_ERROR_VALUE_SMALL;\r
- }\r
- }\r
- else //if(integerType->getRange()->getLower()->getInclusive() == false)\r
- {\r
- if(value < minValue || (abs(value-minValue) < FLT_EPSILON))\r
- {\r
- return std::string("FloatValue: ") + STR_ERROR_VALUE_SMALL;\r
- }\r
- }\r
-\r
- if(floatType->getRange()->getUpper()->getInclusive() == true)\r
- {\r
- if(value > maxValue)\r
- {\r
- return std::string("FloatValue: ") + STR_ERROR_VALUE_LARGE;\r
- }\r
- }\r
- else //if(integerType->getRange()->getUpper()->getInclusive() == false)\r
- {\r
- if(value > maxValue || (abs(value-minValue) > FLT_EPSILON))\r
- {\r
- return std::string("FloatValue: ") + STR_ERROR_VALUE_LARGE;\r
- }\r
- }\r
-\r
- return STR_EMPTY;\r
- }\r
- }\r
-}\r
+#include "FloatValue.h"
+
+#include "FloatType.h"
+#include "Constants.h"
+#include "Range.h"
+#include "Limit.h"
+
+#include <sstream>
+#include <cfloat>
+#include <valarray>
+
+namespace Databoard {
+ namespace Value {
+ FloatValue::FloatValue(Databoard::Type::DataType* dataBoard) : Value(dataBoard)
+ {
+ }
+
+ FloatValue::~FloatValue()
+ {
+ }
+
+ void FloatValue::setValue(float value)
+ {
+ Databoard::Type::FloatType* floatType = dynamic_cast<Databoard::Type::FloatType*>(dataBoard);
+
+ if(floatType != NULL)
+ {
+ this->value = value;
+ }
+ }
+
+ float FloatValue::getValue()
+ {
+ return value;
+ }
+
+ std::string FloatValue::writeOut(int /*indent*/)
+ {
+ std::string s;
+
+ std::stringstream oss;
+
+ oss << value;
+
+ oss >> s;
+
+ //if(unit.size() != 0)
+ //{
+ // s += "(Unit=\"" + unit + "\")";
+ //}
+
+ return s;
+ }
+
+ bool FloatValue::equals(const Value* other)
+ {
+ FloatValue* o = (FloatValue*)other;
+
+ return (this->value < o->value);
+
+ }
+
+ std::string FloatValue::isValid()
+ {
+ if(dataBoard == NULL)
+ {
+ return "There is no datatype.";
+ }
+
+ Databoard::Type::FloatType* floatType = (Databoard::Type::FloatType*)dataBoard;
+
+ if(floatType->getRange() == NULL)
+ {
+ return STR_EMPTY;
+ }
+
+ double minValue = floatType->minValue();
+ double maxValue = floatType->maxValue();
+
+ if(floatType->getRange()->getLower()->getInclusive() == true)
+ {
+ if(value < minValue)
+ {
+ return std::string("FloatValue: ") + STR_ERROR_VALUE_SMALL;
+ }
+ }
+ else //if(integerType->getRange()->getLower()->getInclusive() == false)
+ {
+ if(value < minValue || (abs(value-minValue) < FLT_EPSILON))
+ {
+ return std::string("FloatValue: ") + STR_ERROR_VALUE_SMALL;
+ }
+ }
+
+ if(floatType->getRange()->getUpper()->getInclusive() == true)
+ {
+ if(value > maxValue)
+ {
+ return std::string("FloatValue: ") + STR_ERROR_VALUE_LARGE;
+ }
+ }
+ else //if(integerType->getRange()->getUpper()->getInclusive() == false)
+ {
+ if(value > maxValue || (abs(value-minValue) > FLT_EPSILON))
+ {
+ return std::string("FloatValue: ") + STR_ERROR_VALUE_LARGE;
+ }
+ }
+
+ return STR_EMPTY;
+ }
+ }
+}