Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes

mitk::PropertyListDeserializer Class Reference

Deserializes a mitk::PropertyList. More...

#include <mitkPropertyListDeserializer.h>

Inheritance diagram for mitk::PropertyListDeserializer:
Inheritance graph
[legend]

List of all members.

Public Types

typedef PropertyListDeserializer Self
typedef itk::Object Superclass
typedef itk::SmartPointer< SelfPointer
typedef itk::SmartPointer
< const Self
ConstPointer

Public Member Functions

virtual const char * GetClassName () const
virtual void SetFilename (const char *_arg)
virtual const char * GetFilename () const
virtual bool Deserialize ()
 Reads a propertylist from file.
virtual PropertyList::Pointer GetOutput ()

Static Public Member Functions

static Pointer New ()

Protected Member Functions

 PropertyListDeserializer ()
virtual ~PropertyListDeserializer ()

Protected Attributes

std::string m_Filename
PropertyList::Pointer m_PropertyList

Detailed Description

Deserializes a mitk::PropertyList.

Definition at line 31 of file mitkPropertyListDeserializer.h.


Member Typedef Documentation

typedef itk::SmartPointer<const Self> mitk::PropertyListDeserializer::ConstPointer

Reimplemented in mitk::PropertyListDeserializerV1.

Definition at line 35 of file mitkPropertyListDeserializer.h.

typedef itk::SmartPointer<Self> mitk::PropertyListDeserializer::Pointer

Reimplemented in mitk::PropertyListDeserializerV1.

Definition at line 35 of file mitkPropertyListDeserializer.h.

Reimplemented in mitk::PropertyListDeserializerV1.

Definition at line 35 of file mitkPropertyListDeserializer.h.

Reimplemented in mitk::PropertyListDeserializerV1.

Definition at line 35 of file mitkPropertyListDeserializer.h.


Constructor & Destructor Documentation

mitk::PropertyListDeserializer::PropertyListDeserializer (  ) [protected]

Definition at line 22 of file mitkPropertyListDeserializer.cpp.

{
}
mitk::PropertyListDeserializer::~PropertyListDeserializer (  ) [protected, virtual]

Definition at line 26 of file mitkPropertyListDeserializer.cpp.

{
}

Member Function Documentation

bool mitk::PropertyListDeserializer::Deserialize (  ) [virtual]

Reads a propertylist from file.

Returns:
success of deserialization

Reimplemented in mitk::PropertyListDeserializerV1.

Definition at line 31 of file mitkPropertyListDeserializer.cpp.

References TiXmlDocument::ErrorDesc(), TiXmlNode::FirstChildElement(), TiXmlDocument::LoadFile(), MITK_ERROR, MITK_WARN, TiXmlElement::QueryIntAttribute(), and TIXML_SUCCESS.

{
  bool error(false);

  TiXmlDocument document( m_Filename );
  if (!document.LoadFile())
  {
    MITK_ERROR << "Could not open/read/parse " << m_Filename << "\nTinyXML reports: " << document.ErrorDesc() << std::endl;
    return false;
  }

  // find version node --> note version in some variable
  int fileVersion = 1;
  TiXmlElement* versionObject = document.FirstChildElement("Version");
  if (versionObject)
  {
    if ( versionObject->QueryIntAttribute( "FileVersion", &fileVersion ) != TIXML_SUCCESS )
    {
      MITK_ERROR << "Property file " << m_Filename << " does not contain version information! Trying version 1 format." << std::endl;
    }
  }
  
  std::stringstream propertyListDeserializerClassName;
  propertyListDeserializerClassName << "PropertyListDeserializerV" << fileVersion;

  std::list<itk::LightObject::Pointer> readers = itk::ObjectFactoryBase::CreateAllInstance(propertyListDeserializerClassName.str().c_str());
  if (readers.size() < 1)
  {
    MITK_ERROR << "No property list reader found for file version " << fileVersion;
  }
  if (readers.size() > 1)
  {
    MITK_WARN << "Multiple property list readers found for file version " << fileVersion << ". Using arbitrary first one.";
  }

  for ( std::list<itk::LightObject::Pointer>::iterator iter = readers.begin();
        iter != readers.end();
        ++iter )
  {
    if (PropertyListDeserializer* reader = dynamic_cast<PropertyListDeserializer*>( iter->GetPointer() ) )
    {
      reader->SetFilename( m_Filename );
      bool success = reader->Deserialize();
      error |= !success;
      m_PropertyList = reader->GetOutput();
      
      if ( error )
      {
        MITK_ERROR << "There were errors while loding property list file " << m_Filename << ". Your data may be corrupted";
      }
      break;
    }
  }
   
  return !error;
}
virtual const char* mitk::PropertyListDeserializer::GetClassName (  ) const [virtual]
virtual const char* mitk::PropertyListDeserializer::GetFilename (  ) const [virtual]
mitk::PropertyList::Pointer mitk::PropertyListDeserializer::GetOutput ( void   ) [virtual]

Definition at line 89 of file mitkPropertyListDeserializer.cpp.

{
  return m_PropertyList;
}
static Pointer mitk::PropertyListDeserializer::New (  ) [static]
virtual void mitk::PropertyListDeserializer::SetFilename ( const char *  _arg ) [virtual]

Member Data Documentation

Definition at line 54 of file mitkPropertyListDeserializer.h.

Definition at line 55 of file mitkPropertyListDeserializer.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines