00001 /*========================================================================= 00002 00003 Program: Medical Imaging & Interaction Toolkit 00004 Language: C++ 00005 Date: $Date$ 00006 Version: $Revision$ 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 00019 #include "mitkStringProperty.h" 00020 00021 const char* mitk::StringProperty::PATH = "path"; 00022 mitk::StringProperty::StringProperty( const char* string ) 00023 : m_Value() 00024 { 00025 if ( string ) 00026 m_Value = string; 00027 } 00028 00029 mitk::StringProperty::StringProperty( const std::string& s ) 00030 : m_Value( s ) 00031 { 00032 00033 } 00034 00035 bool mitk::StringProperty::operator==(const BaseProperty& property ) const 00036 { 00037 const Self *other = dynamic_cast<const Self*>(&property); 00038 00039 if(other==NULL) return false; 00040 00041 return other->m_Value==m_Value; 00042 } 00043 00044 std::string mitk::StringProperty::GetValueAsString() const 00045 { 00046 return m_Value; 00047 } 00048 00049 bool mitk::StringProperty::Assignable(const BaseProperty& other) const 00050 { 00051 try 00052 { 00053 dynamic_cast<const Self&>(other); // dear compiler, please don't optimize this away! 00054 return true; 00055 } 00056 catch (std::bad_cast) 00057 { 00058 } 00059 return false; 00060 } 00061 00062 mitk::BaseProperty& mitk::StringProperty::operator=(const BaseProperty& other) 00063 { 00064 try 00065 { 00066 const Self& otherProp( dynamic_cast<const Self&>(other) ); 00067 00068 if (this->m_Value != otherProp.m_Value) 00069 { 00070 this->m_Value = otherProp.m_Value; 00071 this->Modified(); 00072 } 00073 } 00074 catch (std::bad_cast) 00075 { 00076 // nothing to do then 00077 } 00078 00079 return *this; 00080 } 00081 00082