Deserializes a mitk::PropertyList. More...
#include <mitkPropertyListDeserializerV1.h>


Public Types | |
| typedef PropertyListDeserializerV1 | Self |
| typedef PropertyListDeserializer | Superclass |
| typedef itk::SmartPointer< Self > | Pointer |
| typedef itk::SmartPointer < const Self > | ConstPointer |
Public Member Functions | |
| virtual const char * | GetClassName () const |
| virtual bool | Deserialize () |
| Reads a propertylist from file. Get result via GetOutput() | |
Static Public Member Functions | |
| static Pointer | New () |
Protected Member Functions | |
| PropertyListDeserializerV1 () | |
| virtual | ~PropertyListDeserializerV1 () |
Deserializes a mitk::PropertyList.
Definition at line 29 of file mitkPropertyListDeserializerV1.h.
| typedef itk::SmartPointer<const Self> mitk::PropertyListDeserializerV1::ConstPointer |
Reimplemented from mitk::PropertyListDeserializer.
Definition at line 33 of file mitkPropertyListDeserializerV1.h.
| typedef itk::SmartPointer<Self> mitk::PropertyListDeserializerV1::Pointer |
Reimplemented from mitk::PropertyListDeserializer.
Definition at line 33 of file mitkPropertyListDeserializerV1.h.
Reimplemented from mitk::PropertyListDeserializer.
Definition at line 33 of file mitkPropertyListDeserializerV1.h.
Reimplemented from mitk::PropertyListDeserializer.
Definition at line 33 of file mitkPropertyListDeserializerV1.h.
| mitk::PropertyListDeserializerV1::PropertyListDeserializerV1 | ( | ) | [protected] |
Definition at line 26 of file mitkPropertyListDeserializerV1.cpp.
{
}
| mitk::PropertyListDeserializerV1::~PropertyListDeserializerV1 | ( | ) | [protected, virtual] |
Definition at line 30 of file mitkPropertyListDeserializerV1.cpp.
{
}
| bool mitk::PropertyListDeserializerV1::Deserialize | ( | ) | [virtual] |
Reads a propertylist from file. Get result via GetOutput()
Reimplemented from mitk::PropertyListDeserializer.
Definition at line 34 of file mitkPropertyListDeserializerV1.cpp.
References TiXmlDocument::ErrorDesc(), TiXmlNode::FirstChildElement(), TiXmlDocument::LoadFile(), MITK_ERROR, MITK_WARN, mitk::PropertyList::New(), and TiXmlNode::NextSiblingElement().
{
bool error(false);
m_PropertyList = PropertyList::New();
TiXmlDocument document( m_Filename );
if (!document.LoadFile())
{
MITK_ERROR << "Could not open/read/parse " << m_Filename << "\nTinyXML reports: " << document.ErrorDesc() << std::endl;
return false;
}
for( TiXmlElement* propertyElement = document.FirstChildElement("property"); propertyElement != NULL; propertyElement = propertyElement->NextSiblingElement("property") )
{
const char* keya = propertyElement->Attribute("key");
std::string key( keya ? keya : "");
const char* typea = propertyElement->Attribute("type");
std::string type( typea ? typea : "");
// hand propertyElement to specific reader
std::stringstream propertyDeserializerClassName;
propertyDeserializerClassName << type << "Deserializer";
std::list<itk::LightObject::Pointer> readers = itk::ObjectFactoryBase::CreateAllInstance(propertyDeserializerClassName.str().c_str());
if (readers.size() < 1)
{
MITK_ERROR << "No property reader found for " << type;
error = true;
}
if (readers.size() > 1)
{
MITK_WARN << "Multiple property readers found for " << type << ". Using arbitrary first one.";
}
for ( std::list<itk::LightObject::Pointer>::iterator iter = readers.begin();
iter != readers.end();
++iter )
{
if (BasePropertyDeserializer* reader = dynamic_cast<BasePropertyDeserializer*>( iter->GetPointer() ) )
{
BaseProperty::Pointer property = reader->Deserialize( propertyElement->FirstChildElement() );
if (property.IsNotNull())
{
m_PropertyList->ReplaceProperty(key, property);
}
else
{
MITK_ERROR << "There were errors while loding property '" << key << "' of type " << type << ". Your data may be corrupted";
error = true;
}
break;
}
}
}
return !error;
}
| virtual const char* mitk::PropertyListDeserializerV1::GetClassName | ( | ) | const [virtual] |
Reimplemented from mitk::PropertyListDeserializer.
| static Pointer mitk::PropertyListDeserializerV1::New | ( | ) | [static] |
Reimplemented from mitk::PropertyListDeserializer.
1.7.2