go home Home | Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages
itkParameterFileParser.h
Go to the documentation of this file.
00001 /*======================================================================
00002 
00003 This file is part of the elastix software.
00004 
00005 Copyright (c) University Medical Center Utrecht. All rights reserved.
00006 See src/CopyrightElastix.txt or http://elastix.isi.uu.nl/legal.php for
00007 details.
00008 
00009 This software is distributed WITHOUT ANY WARRANTY; without even
00010 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00011 PURPOSE. See the above copyright notices for more information.
00012 
00013 ======================================================================*/
00014 
00015 #ifndef __itkParameterFileParser_h
00016 #define __itkParameterFileParser_h
00017 
00018 #include "itkObject.h"
00019 #include "itkObjectFactory.h"
00020 #include "itkMacro.h"
00021 
00022 #include <map>
00023 #include <string>
00024 #include <vector>
00025 #include <fstream>
00026 
00027 
00028 namespace itk
00029 {
00030 
00077 class ParameterFileParser : public Object
00078 {
00079 public:
00080 
00082   typedef ParameterFileParser         Self;
00083   typedef Object                      Superclass;
00084   typedef SmartPointer< Self >        Pointer;
00085   typedef SmartPointer< const Self >  ConstPointer;
00086 
00088   itkNewMacro( Self );
00089 
00091   itkTypeMacro( ParameterFileParser, Object );
00092 
00094   typedef std::vector< std::string >      ParameterValuesType;
00095   typedef std::map<
00096     std::string,
00097     ParameterValuesType >                 ParameterMapType;
00098 
00100   itkSetStringMacro( ParameterFileName );
00101   itkGetStringMacro( ParameterFileName );
00102 
00104   virtual const ParameterMapType & GetParameterMap( void ) const;
00105 
00107   void ReadParameterFile( void );
00108 
00112   std::string ReturnParameterFileAsString( void );
00113 
00114 protected:
00115   ParameterFileParser();
00116   virtual ~ParameterFileParser();
00117 
00118 private:
00119   ParameterFileParser(const Self&); //purposely not implemented
00120   void operator=(const Self&); //purposely not implemented
00121 
00128   void BasicFileChecking( void ) const;
00129 
00135   bool CheckLine( const std::string & line, std::string & lineOut ) const;
00136 
00138   void GetParameterFromLine( const std::string & fullLine,
00139     const std::string & line );
00140 
00142   void SplitLine( const std::string & fullLine, const std::string & line,
00143     std::vector<std::string> & splittedLine ) const;
00144 
00148   void ThrowException( const std::string & line, const std::string & hint ) const;
00149 
00151   std::string       m_ParameterFileName;
00152   std::ifstream     m_ParameterFile;
00153   ParameterMapType  m_ParameterMap;
00154 
00155 }; // end class ParameterFileParser
00156 
00157 } // end of namespace itk
00158 
00159 #endif // end __itkParameterFileParser_h


Generated on 11-05-2012 for elastix by doxygen 1.7.6.1 elastix logo