19 const ScalarListLookupTableProperty* prop =
20 dynamic_cast<const ScalarListLookupTableProperty*
>(
m_Property.GetPointer());
24 MITK_ERROR <<
"Serialization: Property is NULL";
31 TiXmlElement* mapElement =
new TiXmlElement(
"ScalarListLookupTable");
33 for (ScalarListLookupTable::LookupTableType::const_iterator mapIter = map.begin();
34 mapIter != map.end(); ++mapIter)
37 TiXmlElement* listElement =
new TiXmlElement(
"List");
38 listElement->SetAttribute(
"name", mapIter->first);
40 for (ScalarListLookupTable::ValueType::const_iterator listIter = list.begin();
41 listIter != list.end(); ++listIter)
43 TiXmlElement* valueElement =
new TiXmlElement(
"Element");
44 valueElement->SetDoubleAttribute(
"value", *listIter);
45 listElement->LinkEndChild(valueElement);
48 mapElement->LinkEndChild(listElement);
59 MITK_ERROR <<
"Deserialization: Element is NULL";
65 for (TiXmlElement* listElement = element->FirstChildElement(
"List");
66 listElement !=
nullptr; listElement = listElement->NextSiblingElement(
"List"))
70 if (listElement->Attribute(
"name") !=
nullptr)
72 name = listElement->Attribute(
"name");
76 MITK_ERROR <<
"Deserialization: No element with attribute 'name' found";
82 for (TiXmlElement* valueElement = listElement->FirstChildElement(
"Element");
83 valueElement !=
nullptr;
84 valueElement = valueElement->NextSiblingElement(
"Element"))
88 if (valueElement->QueryDoubleAttribute(
"value", &value) == TIXML_WRONG_TYPE)
90 MITK_ERROR <<
"Deserialization: No element with attribute 'value' found";
94 list.push_back(value);
100 return ScalarListLookupTableProperty::New(lut).GetPointer();
110 lutSerializer->SetProperty(prop);
111 auto xmlLut = lutSerializer->Serialize();
113 TiXmlPrinter printer;
114 xmlLut->Accept(&printer);
115 printer.SetStreamPrinting();
116 return printer.Str();
120 const std::string &value)
125 doc.Parse(value.c_str());
126 return lutSerializer->Deserialize(doc.RootElement());
MITKMODELFIT_EXPORT mitk::BaseProperty::Pointer deserializeXMLToScalarListLookupTableProperty(const std::string &value)
void SetTableValue(const KeyType &key, const ValueType &value)
Sets the list at the given map key to the given value.
TiXmlElement * Serialize() override
Serializes given BaseProperty object.
BaseProperty::Pointer Deserialize(TiXmlElement *element) override
Deserializes given TiXmlElement.
Serializer for the ScalarListLookupTableProperty so it can be written and read from file...
Data class for modelfit properties that store a map of lists (e.g. static parameters).
Abstract base class for properties.
std::vector< double > ValueType
const LookupTableType & GetLookupTable() const
Returns the map of lists.
MITK_REGISTER_SERIALIZER(ScalarListLookupTablePropertySerializer)
BaseProperty::ConstPointer m_Property
std::map< KeyType, ValueType > LookupTableType
MITKMODELFIT_EXPORT ::std::string serializeScalarListLookupTablePropertyToXML(const mitk::BaseProperty *prop)