]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.databoard/cpp/DataBoardTest/DataBoard/FloatType.cpp
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.databoard / cpp / DataBoardTest / DataBoard / FloatType.cpp
diff --git a/bundles/org.simantics.databoard/cpp/DataBoardTest/DataBoard/FloatType.cpp b/bundles/org.simantics.databoard/cpp/DataBoardTest/DataBoard/FloatType.cpp
new file mode 100644 (file)
index 0000000..88f8d4d
--- /dev/null
@@ -0,0 +1,65 @@
+#include "FloatType.h"\r
+\r
+#include "Range.h"\r
+#include "Limit.h"\r
+\r
+#include <cfloat>\r
+\r
+namespace Databoard {\r
+       namespace Type {\r
+\r
+               FloatType::FloatType() : NumberType()\r
+               {\r
+                       this->range = NULL;\r
+               }\r
+\r
+               FloatType::FloatType(std::string unit) : NumberType(unit)\r
+               {\r
+                       this->unit = unit;\r
+                       this->range = NULL;\r
+               }\r
+\r
+               FloatType::FloatType(std::string unit, Range* range) : NumberType(unit, range)\r
+               {\r
+                       this->unit = unit;\r
+                       this->range = range;\r
+               }\r
+\r
+               FloatType::~FloatType()\r
+               {\r
+               }\r
+\r
+               float FloatType::minValue()\r
+               {\r
+                       if(range == NULL) return FLT_MIN;\r
+\r
+                       Limit* l = range->getLower();\r
+\r
+                       float value = l->getFloat(FLT_MIN);\r
+\r
+                       return value;\r
+               }\r
+\r
+               float FloatType::maxValue()\r
+               {\r
+                       if(range == NULL) return FLT_MAX;\r
+\r
+                       Limit* l = range->getUpper();\r
+\r
+                       float value = l->getFloat(FLT_MAX);\r
+\r
+                       return value;\r
+               }\r
+\r
+               std::string FloatType::writeOut(int indent)\r
+               {\r
+                       std::string s;\r
+\r
+                       s.append("Float");\r
+\r
+                       s += NumberType::writeOut(indent + 1);\r
+\r
+                       return s;\r
+               }\r
+       }\r
+}\r