freAdaptationComponent.cxx

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   F.R.E.E. - flexible registration evaluation engine
00004   Version:   v.1.0.0
00005   Date:      $Date: 2006/09/01 12:00:00 $
00006   Module:    $RCSfile: freAdaptationComponent.cxx,v $
00007   Language:  C++
00008 
00009 
00010 
00011   Copyright (c) 2007 Ralf o Floca (Department of Medical Informatics,
00012   Institute for Medical Biometry and Informatics, University of Heidelberg,
00013   Germany). All rights reserved.
00014   See FREECopyright.txt or http://www.mi.med.uni-hd.de/free/copyright.htm
00015   for details.
00016 
00017      This software is distributed WITHOUT ANY WARRANTY; without even 
00018      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00019      PURPOSE.  See the above copyright notices for more information.
00020 
00021 =========================================================================*/
00022 #include "freAdaptationComponent.h"
00023 
00024 #include "freConvert.h"
00025 #include "freComponentSetupCollection.h"
00026 
00027 namespace FREE
00028 {
00029 namespace Adaptation
00030 {
00034 
00035 void
00036 AdaptationComponent::
00037 SetComponentPath( const IDPath& idPath )
00038 {
00039   m_ComponentPath = idPath;
00040 };
00041 
00042 AdaptationComponent&
00043 AdaptationComponent::
00044 operator = (const AdaptationComponent& rAdaptationComponent)
00045 {
00046   if (this == &rAdaptationComponent) return *this;
00047 
00048   Reset();
00049 
00050   ComponentSetup::operator = (rAdaptationComponent);
00051   m_ComponentPath = rAdaptationComponent.GetComponentPath();
00052   m_ComponentID = m_ComponentPath.GetComponentID();
00053 
00054   return *this;
00055 };
00056 
00057 AdaptationComponent::
00058 AdaptationComponent()
00059 {
00060   m_ComponentPath = cIDPSelf;
00061 };
00062 
00063 AdaptationComponent::
00064 ~AdaptationComponent()
00065 {
00066   Reset();
00067 };
00068 
00069 void AdaptationComponent::Reset()
00070 {
00071   ComponentSetup::Reset();
00072   m_ComponentPath = cIDPSelf;
00073   m_AdaptationMode = AdaptationComponent::AMOverwrite;
00074 };
00075 
00076 void
00077 AdaptationComponent::
00078 AttributesLoadProcessing(const AttributesType& rAttributes)
00079 {
00080   for (AttributesType::const_iterator pos = rAttributes.begin(); pos!= rAttributes.end(); pos++)
00081   {
00082     if (pos->first==cXML_ComponentControllerID) m_sControllerID = pos->second;
00083     else if (pos->first==cXML_ComponentID) m_ComponentPath = pos->second;
00084     else if (pos->first==cXML_Adaptation_Mode) m_AdaptationMode = Convert::ToAdaptationMode(pos->second);
00085   };
00086   m_ComponentID = m_ComponentPath.GetComponentID();
00087 };
00088 
00089 void
00090 AdaptationComponent::
00091 SaveAttributes(AttributesSaveListType& rAttributes) const
00092 {
00093   rAttributes.push_back(AttributesType::value_type(cXML_ComponentID,m_ComponentPath.ToStr()));
00094         if (m_sControllerID!=csUndefinedController) rAttributes.push_back(AttributesType::value_type(cXML_ComponentControllerID,m_sControllerID));
00095   if (m_AdaptationMode!=AdaptationComponent::AMOverwrite) rAttributes.push_back(AttributesType::value_type(cXML_Adaptation_Mode,Convert::ToStr(m_AdaptationMode)));
00096 }; 
00097 
00098 }//end of namespace Adaptation
00099 
00100 namespace Convert
00101 {
00102   std::string ToStr(const Adaptation::AdaptationComponent::AdaptationMode& am);
00103   Adaptation::AdaptationComponent::AdaptationMode ToAdaptationMode(const std::string& sValue);
00104 
00105 Adaptation::AdaptationComponent::AdaptationMode ToAdaptationMode(const std::string& sValue)
00106 {
00107         if (sValue==ToStr(Adaptation::AdaptationComponent::AMOverwrite)) return Adaptation::AdaptationComponent::AMOverwrite;
00108         if (sValue==ToStr(Adaptation::AdaptationComponent::AMReplace)) return Adaptation::AdaptationComponent::AMReplace;
00109         if (sValue==ToStr(Adaptation::AdaptationComponent::AMExtend)) return Adaptation::AdaptationComponent::AMExtend;
00110         if (sValue==ToStr(Adaptation::AdaptationComponent::AMAdapt)) return Adaptation::AdaptationComponent::AMAdapt;
00111         
00112   return Adaptation::AdaptationComponent::AMUnknown;
00113 };
00114 
00115 std::string ToStr(const Adaptation::AdaptationComponent::AdaptationMode& am)
00116 {
00117   switch (am)
00118   {
00119   case Adaptation::AdaptationComponent::AMOverwrite: return "overwrite";
00120   case Adaptation::AdaptationComponent::AMReplace: return "replace";
00121   case Adaptation::AdaptationComponent::AMExtend: return "extend";
00122   case Adaptation::AdaptationComponent::AMAdapt: return "adapt";
00123         default: return "unkown";
00124   };
00125 };
00126 }
00127 
00128 }//end of namespace FREE

Generated at Sat Oct 13 15:18:08 2007 for f.r.e.e. - Flexible Registration and Evaluation Engine by doxygen 1.5.3 written by Dimitri van Heesch, © 1997-2000