00001 /*========================================================================= 00002 00003 Program: Medical Imaging & Interaction Toolkit 00004 Language: C++ 00005 Date: $Date: 2009-10-08 17:07:40 +0200 (Do, 08. Okt 2009) $ 00006 Version: $Revision: 1.12 $ 00007 00008 Copyright (c) German Cancer Research Center, Division of Medical and 00009 Biological Informatics. All rights reserved. 00010 See MITKCopyright.txt or https://www.mitk.org/copyright.html for details. 00011 00012 This software is distributed WITHOUT ANY WARRANTY; without even 00013 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00014 PURPOSE. See the above copyright notices for more information. 00015 00016 =========================================================================*/ 00017 00018 #ifndef mitkStringLookupTablePropertyDeserializer_h_included 00019 #define mitkStringLookupTablePropertyDeserializer_h_included 00020 00021 #include "mitkBasePropertyDeserializer.h" 00022 00023 #include "mitkProperties.h" 00024 00025 #include "SceneSerializationBaseExports.h" 00026 00027 namespace mitk 00028 { 00029 00030 class SceneSerializationBase_EXPORT StringLookupTablePropertyDeserializer : public BasePropertyDeserializer 00031 { 00032 public: 00033 00034 mitkClassMacro( StringLookupTablePropertyDeserializer, BasePropertyDeserializer ); 00035 itkNewMacro(Self); 00036 00037 virtual BaseProperty::Pointer Deserialize(TiXmlElement* element) 00038 { 00039 if (!element) 00040 return NULL; 00041 00042 StringLookupTable lut; 00043 for( TiXmlElement* child = element->FirstChildElement("LUTValue"); child != NULL; child = child->NextSiblingElement("LUTValue")) 00044 { 00045 00046 int temp; 00047 if (child->QueryIntAttribute("id", &temp) == TIXML_WRONG_TYPE) 00048 return NULL; // TODO: can we do a better error handling? 00049 StringLookupTable::IdentifierType id = static_cast<StringLookupTable::IdentifierType>(temp); 00050 00051 if (child->Attribute("value") == NULL) 00052 return NULL; // TODO: can we do a better error handling? 00053 StringLookupTable::ValueType val = child->Attribute("value"); 00054 lut.SetTableValue(id, val); 00055 } 00056 return StringLookupTableProperty::New(lut).GetPointer(); 00057 } 00058 protected: 00059 StringLookupTablePropertyDeserializer() {} 00060 virtual ~StringLookupTablePropertyDeserializer() {} 00061 }; 00062 } // namespace 00063 // important to put this into the GLOBAL namespace (because it starts with 'namespace mitk') 00064 MITK_REGISTER_SERIALIZER(StringLookupTablePropertyDeserializer); 00065 #endif