go home Home | Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages
elxConfiguration.h
Go to the documentation of this file.
1 /*======================================================================
2 
3 This file is part of the elastix software.
4 
5 Copyright (c) University Medical Center Utrecht. All rights reserved.
6 See src/CopyrightElastix.txt or http://elastix.isi.uu.nl/legal.php for
7 details.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without even
10 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11 PURPOSE. See the above copyright notices for more information.
12 
13 ======================================================================*/
14 
15 #ifndef __elxConfiguration_H__
16 #define __elxConfiguration_H__
17 
18 #include "itkObject.h"
19 #include "elxBaseComponent.h"
20 
21 #include "itkParameterFileParser.h"
23 #include <map>
24 #include "xoutmain.h"
25 
26 namespace elastix
27 {
28 
47 class Configuration : public itk::Object, public BaseComponent
48 {
49 public:
50 
53  typedef itk::Object Superclass1;
55  typedef itk::SmartPointer< Self > Pointer;
56  typedef itk::SmartPointer< const Self > ConstPointer;
57 
59  itkNewMacro( Self );
60 
62  itkTypeMacro( Configuration, itk::Object );
63 
65  typedef std::map< std::string, std::string > CommandLineArgumentMapType;
66  typedef CommandLineArgumentMapType::value_type CommandLineEntryType;
67 
73 
75  const std::string GetCommandLineArgument( const std::string & key ) const;
76 
77  void SetCommandLineArgument( const std::string & key, const std::string & value );
78 
80  itkGetStringMacro( ParameterFileName );
81  itkSetStringMacro( ParameterFileName );
82 
90  virtual int Initialize( const CommandLineArgumentMapType & _arg );
91 
92  virtual int Initialize( const CommandLineArgumentMapType & _arg,
94 
96  virtual bool IsInitialized( void ) const; //to elxconfigurationbase
97 
101  itkSetMacro( ElastixLevel, unsigned int );
102  itkGetConstMacro( ElastixLevel, unsigned int );
103 
105  itkSetMacro( TotalNumberOfElastixLevels, unsigned int );
106  itkGetConstMacro( TotalNumberOfElastixLevels, unsigned int );
107 
108  /***/
109  virtual bool GetPrintErrorMessages( void )
110  {
111  return this->m_ParameterMapInterface->GetPrintErrorMessages();
112  }
113 
114 
123  virtual int BeforeAll( void );
124 
128  virtual int BeforeAllTransformix( void );
129 
134  const std::string & parameterName ) const
135  {
136  return this->m_ParameterMapInterface->CountNumberOfParameterEntries(
137  parameterName );
138  }
139 
140 
142  template< class T >
143  bool ReadParameter( T & parameterValue, const std::string & parameterName,
144  const unsigned int entry_nr, const bool printThisErrorMessage )
145  {
146  std::string errorMessage = "";
147  bool found = this->m_ParameterMapInterface->ReadParameter(
148  parameterValue, parameterName, entry_nr,
149  printThisErrorMessage, errorMessage );
150  if( errorMessage != "" )
151  {
152  xl::xout[ "error" ] << errorMessage;
153  }
154 
155  return found;
156  }
157 
158 
160  template< class T >
161  bool ReadParameter( T & parameterValue, const std::string & parameterName,
162  const unsigned int entry_nr )
163  {
164  std::string errorMessage = "";
165  bool found = this->m_ParameterMapInterface->ReadParameter(
166  parameterValue, parameterName, entry_nr, errorMessage );
167  if( errorMessage != "" )
168  {
169  xl::xout[ "error" ] << errorMessage;
170  }
171 
172  return found;
173  }
174 
175 
177  template< class T >
178  bool ReadParameter( T & parameterValue, const std::string & parameterName,
179  const std::string & prefix,
180  const unsigned int entry_nr, const int default_entry_nr,
181  const bool printThisErrorMessage ) const
182  {
183  std::string errorMessage = "";
184  bool found = this->m_ParameterMapInterface->ReadParameter(
185  parameterValue, parameterName, prefix, entry_nr, default_entry_nr,
186  printThisErrorMessage, errorMessage );
187  if( errorMessage != "" )
188  {
189  xl::xout[ "error" ] << errorMessage;
190  }
191 
192  return found;
193  }
194 
195 
197  template< class T >
198  bool ReadParameter( T & parameterValue, const std::string & parameterName,
199  const std::string & prefix,
200  const unsigned int entry_nr, const int default_entry_nr ) const
201  {
202  std::string errorMessage = "";
203  bool found = this->m_ParameterMapInterface->ReadParameter(
204  parameterValue, parameterName, prefix, entry_nr, default_entry_nr,
205  errorMessage );
206  if( errorMessage != "" )
207  {
208  xl::xout[ "error" ] << errorMessage;
209  }
210 
211  return found;
212  }
213 
214 
216  template< class T >
217  bool ReadParameter( std::vector< T > & parameterValues,
218  const std::string & parameterName,
219  const unsigned int entry_nr_start,
220  const unsigned int entry_nr_end,
221  const bool printThisErrorMessage ) const
222  {
223  std::string errorMessage = "";
224  bool found = this->m_ParameterMapInterface->ReadParameter(
225  parameterValues, parameterName, entry_nr_start, entry_nr_end,
226  printThisErrorMessage, errorMessage );
227  if( errorMessage != "" )
228  {
229  xl::xout[ "error" ] << errorMessage;
230  }
231 
232  return found;
233  }
234 
235 
236 protected:
237 
238  Configuration();
239  virtual ~Configuration() {}
240 
245  virtual void PrintParameterFile( void ) const;
246 
247 private:
248 
249  Configuration( const Self & ); // purposely not implemented
250  void operator=( const Self & ); // purposely not implemented
251 
253  std::string m_ParameterFileName;
256 
258  unsigned int m_ElastixLevel;
260 
261 };
262 
263 } // end namespace elastix
264 
265 #endif // end #ifndef __elxConfiguration_H__
std::map< std::string, ParameterValuesType > ParameterMapType
bool ReadParameter(T &parameterValue, const std::string &parameterName, const std::string &prefix, const unsigned int entry_nr, const int default_entry_nr, const bool printThisErrorMessage) const
bool ReadParameter(T &parameterValue, const std::string &parameterName, const unsigned int entry_nr)
bool ReadParameter(T &parameterValue, const std::string &parameterName, const unsigned int entry_nr, const bool printThisErrorMessage)
virtual bool GetPrintErrorMessages(void)
std::vcl_size_t CountNumberOfParameterEntries(const std::string &parameterName) const
bool ReadParameter(std::vector< T > &parameterValues, const std::string &parameterName, const unsigned int entry_nr_start, const unsigned int entry_nr_end, const bool printThisErrorMessage) const
virtual int BeforeAllTransformix(void)
unsigned int m_TotalNumberOfElastixLevels
itk::SmartPointer< const Self > ConstPointer
The BaseComponent class is a class that all elastix components should inherit from.
#define xout
Definition: xoutmain.h:26
virtual bool IsInitialized(void) const
Implements functionality to get parameters from a parameter map.
bool ReadParameter(T &parameterValue, const std::string &parameterName, const std::string &prefix, const unsigned int entry_nr, const int default_entry_nr) const
ParameterMapInterfacePointer m_ParameterMapInterface
Implements functionality to read a parameter file.
itk::ParameterMapInterface ParameterMapInterfaceType
CommandLineArgumentMapType::value_type CommandLineEntryType
void operator=(const Self &)
itk::ParameterFileParser ParameterFileParserType
ParameterFileParserPointer m_ParameterFileParser
itk::SmartPointer< Self > Pointer
virtual int Initialize(const CommandLineArgumentMapType &_arg)
CommandLineArgumentMapType m_CommandLineArgumentMap
A class that deals with user given parameters and command line arguments.
const std::string GetCommandLineArgument(const std::string &key) const
SmartPointer< Self > Pointer
virtual int BeforeAll(void)
virtual void PrintParameterFile(void) const
void SetCommandLineArgument(const std::string &key, const std::string &value)
ParameterFileParserType::Pointer ParameterFileParserPointer
ParameterMapInterfaceType::Pointer ParameterMapInterfacePointer
std::map< std::string, std::string > CommandLineArgumentMapType


Generated on 11-03-2014 for elastix by doxygen 1.8.6 elastix logo