freSetup.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: freSetup.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 //This is to avoid the warnings produced by itk/stl and ease the search for errors
00023 //in the creation report
00024 #pragma warning( disable : 4786)
00025 
00026 #include "freSetup.h"
00027 
00028 #include "freConvert.h"
00029 #include "freComponentSetupCollection.h"
00030 #include "freSetupIOHelper.h"
00031 
00032 namespace FREE
00033 {
00034 
00038 
00039 
00040 std::string
00041 Setup::
00042 GetName() const
00043 {
00044   return m_sName;
00045 };
00046 
00047 void
00048 Setup::
00049 SetName(const std::string& sName)
00050 {
00051   m_sName = sName;
00052 };
00053 
00054 std::string
00055 Setup::
00056 GetDescription() const
00057 {
00058   return m_sDescription;
00059 };
00060 
00061 void
00062 Setup::
00063 SetDescription(const std::string& sDescription)
00064 {
00065   m_sDescription = sDescription;
00066 };
00067 
00068 Setup::
00069 Setup() : XMLStreamObject(cXML_Setup)
00070 {
00071   m_Root = ComponentSetup::New(0,"");
00072   Reset();
00073 };
00074 
00075 Setup::
00076 Setup( const Setup& setup ) : XMLStreamObject(cXML_Setup)
00077 {
00078 };
00079 
00080 Setup::
00081 ~Setup()
00082 {
00083   Reset();
00084 };
00085 
00086 Setup&
00087 Setup::
00088 operator = (const Setup& rSetup)
00089 {
00090   if (this == &rSetup) return *this;
00091 
00092   Reset();
00093   m_sName = rSetup.GetName();
00094   m_sDescription = rSetup.GetDescription();
00095   m_Root->Components().LoadFromString(rSetup.Components().SaveToString());
00096   
00097   return *this;
00098 };
00099 
00100 void
00101 Setup::
00102 Reset()
00103 {
00104   XMLStreamObject::Reset();
00105 
00106   m_sName = "";
00107   m_sDescription = "";
00108   m_Root->Reset();
00109 };
00110 
00111 void
00112 Setup::
00113 SaveAttributes(AttributesSaveListType& rAttributes) const
00114 {
00115         rAttributes.push_back(AttributesType::value_type(cXML_SetupVersion,"1.2"));
00116 };
00117 
00118 void
00119 Setup::
00120 SubElementLoadProcessing(const std::string& rsXMLSubTag, const std::string& rsXMLSubElement, const std::string& rsXMLSubData)
00121 {
00122   try
00123   {
00124     if (rsXMLSubTag == cXML_SetupName)
00125     {
00126       m_sName = rsXMLSubData; return;
00127     };
00128     
00129     if (rsXMLSubTag == cXML_SetupDescription)
00130     {
00131       m_sDescription = rsXMLSubData; return;
00132     };
00133     
00134     if (rsXMLSubTag == cXML_SetupSections)
00135     {
00136       SetupLoadingHelper sectionLoader(m_Root);
00137       sectionLoader.LoadFromString(rsXMLSubElement); return;
00138     };
00139   }
00140   catchAllNPassMacro("Unknown error occured while loading setup. Please check error log for further information.");
00141 }
00142 
00143 std::string
00144 Setup::
00145 SaveData(const unsigned int& iDepth, bool& bHasSubElements) const
00146 {
00147   std::string sResult;
00148 
00149   AddSubElement(sResult,cXML_SetupName,m_sName,iDepth);
00150 
00151   if (m_sDescription.size()!=0) AddSubElement(sResult,cXML_SetupDescription,m_sDescription,iDepth);
00152 
00153   SetupSavingHelper sectionSaver(m_Root);
00154   AddSubElement(sResult,&sectionSaver,iDepth);
00155 
00156   return sResult;
00157 };
00158 
00159 void
00160 Setup::
00161 SetNeededSubElements()
00162 {
00163   AddNeededSubElement(cXML_SetupName);
00164 };
00165 
00166 ComponentSetup*
00167 Setup::
00168 GetComponentByIDPath(const IDPath& idPath)
00169 {
00170   return m_Root->GetComponentByIDPath(idPath);
00171 };
00172 
00173 Setup::SectionVector
00174 Setup::
00175 GetSections() const
00176 {
00177   SectionVector sections;
00178 
00179   for (unsigned int i = 0; i < m_Root->Components().Size(); i++)
00180   {
00181     ComponentSetup* pComp = m_Root->Components().GetElement(i);
00182     sections.push_back(pComp);
00183   }
00184 
00185   return sections;
00186 };
00187 
00188 Setup::SectionSetup*
00189 Setup::
00190 GetSection(const unsigned int& iIndex) const
00191 {
00192   SectionVector sections = GetSections();
00193 
00194   if ((iIndex<0) || (iIndex>=sections.size())) return NULL;
00195 
00196   return sections[iIndex];
00197 };
00198 
00199 unsigned int
00200 Setup::
00201 GetSectionCount() const
00202 {
00203   return GetSections().size();
00204 };
00205 
00206 }//end of namespace FREE

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