13 #ifndef mitkVectorPropertySerializer_h 14 #define mitkVectorPropertySerializer_h 43 template <
typename DATATYPE>
56 std::vector<std::string>
GetClassHierarchy()
const override {
return mitk::GetClassHierarchy<Self>(); }
63 static std::string nameOfClass =
65 return nameOfClass.c_str();
68 const char *
GetNameOfClass()
const override {
return this->GetStaticNameOfClass(); }
69 itkFactorylessNewMacro(Self);
75 auto listElement =
new TiXmlElement(
"Values");
77 if (
const PropertyType *prop = dynamic_cast<const PropertyType *>(m_Property.GetPointer()))
80 unsigned int index(0);
81 for (
auto listEntry : elements)
83 std::stringstream indexS;
86 auto entryElement =
new TiXmlElement(
"Value");
87 entryElement->SetAttribute(
"idx", indexS.str());
88 entryElement->SetAttribute(
"value", boost::lexical_cast<std::string>(listEntry));
89 listElement->LinkEndChild(entryElement);
107 MITK_DEBUG <<
"Deserializing " << *listElement;
109 unsigned int index(0);
110 std::string valueString;
112 for (TiXmlElement *valueElement = listElement->FirstChildElement(
"Value"); valueElement;
113 valueElement = valueElement->NextSiblingElement(
"Value"))
115 if (valueElement->QueryValueAttribute(
"value", &valueString) != TIXML_SUCCESS)
117 MITK_ERROR <<
"Missing value attribute in <Values> list";
125 catch (boost::bad_lexical_cast &e)
127 MITK_ERROR <<
"Could not parse '" << valueString <<
"' as number: " << e.what();
131 datalist.push_back(value);
136 property->SetValue(datalist);
137 return property.GetPointer();
static const char * GetStaticNameOfClass()
BasePropertySerializer SuperClass
Helper for VectorProperty to determine a good ITK ClassName.
itk::SmartPointer< const Self > ConstPointer
itk::SmartPointer< Self > Pointer
DataCollection - Class to facilitate loading/accessing structured data.
VectorPropertySerializer< DATATYPE > Self
TiXmlElement * Serialize() override
Build an XML version of this property.
std::vector< std::string > GetClassHierarchy() const override
const char * GetNameOfClass() const override
Target lexical_cast(const std::string &arg)
BaseProperty::Pointer Deserialize(TiXmlElement *listElement) override
Construct a property from an XML serialization.
Serializes a VectorProperty.
VectorPropertySerializer< double > DoubleVectorPropertySerializer
Base class for objects that serialize BaseProperty types.
std::vector< DATATYPE > VectorType
Providing a std::vector as property.
#define MITKSCENESERIALIZATIONBASE_EXPORT
VectorPropertySerializer< int > IntVectorPropertySerializer
VectorProperty< DATATYPE > PropertyType