17 #ifndef mitkStringLookupTablePropertySerializer_h_included
18 #define mitkStringLookupTablePropertySerializer_h_included
26 class StringLookupTablePropertySerializer :
public BasePropertySerializer
29 mitkClassMacro(StringLookupTablePropertySerializer, BasePropertySerializer);
30 itkFactorylessNewMacro(Self) itkCloneMacro(Self)
32 virtual TiXmlElement *Serialize()
override
34 const StringLookupTableProperty *prop =
dynamic_cast<const StringLookupTableProperty *
>(m_Property.GetPointer());
37 StringLookupTable lut = prop->GetValue();
42 auto element =
new TiXmlElement(
"StringLookupTable");
43 for (
auto it = map.begin(); it != map.end(); ++it)
45 auto tableEntry =
new TiXmlElement(
"LUTValue");
46 tableEntry->SetAttribute(
"id", it->first);
47 tableEntry->SetAttribute(
"value", it->second);
48 element->LinkEndChild(tableEntry);
58 StringLookupTable lut;
59 for (TiXmlElement *child = element->FirstChildElement(
"LUTValue"); child !=
nullptr;
60 child = child->NextSiblingElement(
"LUTValue"))
63 if (child->QueryIntAttribute(
"id", &temp) == TIXML_WRONG_TYPE)
67 if (child->Attribute(
"value") ==
nullptr)
70 lut.SetTableValue(
id, val);
76 StringLookupTablePropertySerializer() {}
77 virtual ~StringLookupTablePropertySerializer() {}
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)