X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.databoard%2Fcpp%2FDataBoardTest%2FDataBoard%2FUnionValue.cpp;fp=bundles%2Forg.simantics.databoard%2Fcpp%2FDataBoardTest%2FDataBoard%2FUnionValue.cpp;h=09848933ac5abbd8cf80299efb24185463fcc9ae;hb=0ae2b770234dfc3cbb18bd38f324125cf0faca07;hp=67568e79fe017735ff1ffdcc32513534dca49938;hpb=24e2b34260f219f0d1644ca7a138894980e25b14;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.databoard/cpp/DataBoardTest/DataBoard/UnionValue.cpp b/bundles/org.simantics.databoard/cpp/DataBoardTest/DataBoard/UnionValue.cpp index 67568e79f..09848933a 100644 --- a/bundles/org.simantics.databoard/cpp/DataBoardTest/DataBoard/UnionValue.cpp +++ b/bundles/org.simantics.databoard/cpp/DataBoardTest/DataBoard/UnionValue.cpp @@ -1,96 +1,96 @@ -#include "UnionValue.h" - -#include "UnionType.h" -#include "Component.h" -#include "Constants.h" - -namespace Databoard { - namespace Value { - UnionValue::UnionValue(Databoard::Type::DataType* dataBoard) : Value(dataBoard) - { - tag = -1; - value = NULL; - } - - UnionValue::~UnionValue() - { - if(value != NULL) - { - delete value; - value = NULL; - } - } - - int UnionValue::getTag() - { - return tag; - } - - Value* UnionValue::getValue() - { - return value; - } - - void UnionValue::setValue(int tag, Value* value) - { - this->tag = tag; - this->value = value; - } - - std::string UnionValue::writeOut(int /*indent*/) - { - std::string s; - - Databoard::Type::UnionType* unionType = (Databoard::Type::UnionType*)dataBoard; - - Databoard::Type::Component* component = unionType->getComponent(tag); - - if(component != NULL) - { - s += component->getName(); - s += " "; - } - - if(value != NULL) - { - s += value->writeOut(); - } - - //s += value; - - //if(unit.size() != 0) - //{ - // s += "(Unit=\"" + unit + "\")"; - //} - - return s; - } - - bool UnionValue::equals(const Value* other) - { - UnionValue* o = (UnionValue*)other; - - if(tag != o->tag) - { - return (tag < o->tag); - } - - return (value->equals(o->value)); - } - - std::string UnionValue::isValid() - { - if(dataBoard == NULL) - { - return "LongValue: There is no datatype."; - } - - if(value == NULL) - { - return STR_ERROR; - } - - return value->isValid(); - } - } -} +#include "UnionValue.h" + +#include "UnionType.h" +#include "Component.h" +#include "Constants.h" + +namespace Databoard { + namespace Value { + UnionValue::UnionValue(Databoard::Type::DataType* dataBoard) : Value(dataBoard) + { + tag = -1; + value = NULL; + } + + UnionValue::~UnionValue() + { + if(value != NULL) + { + delete value; + value = NULL; + } + } + + int UnionValue::getTag() + { + return tag; + } + + Value* UnionValue::getValue() + { + return value; + } + + void UnionValue::setValue(int tag, Value* value) + { + this->tag = tag; + this->value = value; + } + + std::string UnionValue::writeOut(int /*indent*/) + { + std::string s; + + Databoard::Type::UnionType* unionType = (Databoard::Type::UnionType*)dataBoard; + + Databoard::Type::Component* component = unionType->getComponent(tag); + + if(component != NULL) + { + s += component->getName(); + s += " "; + } + + if(value != NULL) + { + s += value->writeOut(); + } + + //s += value; + + //if(unit.size() != 0) + //{ + // s += "(Unit=\"" + unit + "\")"; + //} + + return s; + } + + bool UnionValue::equals(const Value* other) + { + UnionValue* o = (UnionValue*)other; + + if(tag != o->tag) + { + return (tag < o->tag); + } + + return (value->equals(o->value)); + } + + std::string UnionValue::isValid() + { + if(dataBoard == NULL) + { + return "LongValue: There is no datatype."; + } + + if(value == NULL) + { + return STR_ERROR; + } + + return value->isValid(); + } + } +}