13 #ifndef mitkStringLookupTablePropertySerializer_h_included 14 #define mitkStringLookupTablePropertySerializer_h_included 22 class StringLookupTablePropertySerializer :
public BasePropertySerializer
25 mitkClassMacro(StringLookupTablePropertySerializer, BasePropertySerializer);
26 itkFactorylessNewMacro(Self) itkCloneMacro(Self)
28 TiXmlElement *Serialize()
override 30 const StringLookupTableProperty *prop =
dynamic_cast<const StringLookupTableProperty *
>(m_Property.GetPointer());
33 StringLookupTable lut = prop->GetValue();
38 auto element =
new TiXmlElement(
"StringLookupTable");
39 for (
auto it = map.begin(); it != map.end(); ++it)
41 auto tableEntry =
new TiXmlElement(
"LUTValue");
42 tableEntry->SetAttribute(
"id", it->first);
43 tableEntry->SetAttribute(
"value", it->second);
44 element->LinkEndChild(tableEntry);
54 StringLookupTable lut;
55 for (TiXmlElement *child = element->FirstChildElement(
"LUTValue"); child !=
nullptr;
56 child = child->NextSiblingElement(
"LUTValue"))
59 if (child->QueryIntAttribute(
"id", &temp) == TIXML_WRONG_TYPE)
63 if (child->Attribute(
"value") ==
nullptr)
66 lut.SetTableValue(
id, val);
72 StringLookupTablePropertySerializer() {}
73 ~StringLookupTablePropertySerializer()
override {}
std::map< IdentifierType, ValueType > LookupTableType
DataCollection - Class to facilitate loading/accessing structured data.
itk::SmartPointer< Self > Pointer
MITK_REGISTER_SERIALIZER(StringLookupTablePropertySerializer)
unsigned int IdentifierType
#define mitkClassMacro(className, SuperClassName)