freSetupIOHelper.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: freSetupIOHelper.cxx,v $
00007   Language:  C++
00008 
00009 
00010 
00011 
00012   Copyright (c) 2007 Ralf o Floca (Department of Medical Informatics,
00013   Institute for Medical Biometry and Informatics, University of Heidelberg,
00014   Germany). All rights reserved.
00015   See FREECopyright.txt or http://www.mi.med.uni-hd.de/free/copyright.htm
00016   for details.
00017 
00018      This software is distributed WITHOUT ANY WARRANTY; without even 
00019      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00020      PURPOSE.  See the above copyright notices for more information.
00021 
00022 =========================================================================*/
00023 //This is to avoid the warnings produced by itk/stl and ease the search for errors
00024 //in the creation report
00025 #pragma warning( disable : 4786)
00026 
00027 #include "freSetupIOHelper.h"
00028 
00029 #include "freConvert.h"
00030 #include "frePointerSentry.h"
00031 #include "freComponentSetupCollection.h"
00032 
00033 
00034 namespace FREE
00035 {
00036 
00040 
00041 
00042 SetupLoadingHelper::
00043 SetupLoadingHelper(ComponentSetup* pRoot) : XMLStreamObject(cXML_SetupSections), m_pRoot(pRoot)
00044 {
00045 };
00046 
00047 void
00048 SetupLoadingHelper::
00049 SubElementLoadProcessing(const std::string& rsXMLSubTag, const std::string& rsXMLSubElement, const std::string& rsXMLSubData)
00050 {
00051   if (rsXMLSubTag==cXML_Component)
00052   { 
00053     ComponentSetup::Pointer smpNewComponent = ComponentSetup::New(m_pRoot);
00054 
00055     try
00056     {
00057       smpNewComponent->LoadFromString(rsXMLSubElement);
00058     }
00059     catchAllNPassMacro("Error while loading setup component.");
00060  
00061     m_pRoot->Components().AddElement(smpNewComponent);
00062   }
00063         else XMLStreamObject::SubElementLoadProcessing(rsXMLSubTag, rsXMLSubElement, rsXMLSubData);
00064 };
00065 
00069 
00070 
00071 SetupSavingHelper::
00072 SetupSavingHelper(const ComponentSetup* pRoot) : XMLStreamObject(cXML_SetupSections), m_pRoot(pRoot)
00073 {
00074 };
00075 
00076 std::string
00077 SetupSavingHelper::
00078 SaveData(const unsigned int& iDepth, bool& bHasSubElements) const
00079 {
00080                 std::string result;
00081                 for (unsigned int i = 0; i<m_pRoot->Components().Size(); i++)
00082                 {
00083       ComponentSetup* pComp = m_pRoot->Components().GetElement(i);
00084       AddSubElement(result,pComp,iDepth);
00085                 };
00086 
00087                 bHasSubElements = !(result.empty());
00088 
00089                 return result;
00090 };
00091 
00092 }//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