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 
27 namespace elastix
28 {
29 
48 class Configuration : public itk::Object, public BaseComponent
49 {
50 public:
51 
54  typedef itk::Object Superclass1;
56  typedef itk::SmartPointer<Self> Pointer;
57  typedef itk::SmartPointer<const Self> ConstPointer;
58 
60  itkNewMacro( Self );
61 
63  itkTypeMacro( Configuration, itk::Object );
64 
66  typedef std::map<std::string, std::string> CommandLineArgumentMapType;
67  typedef CommandLineArgumentMapType::value_type CommandLineEntryType;
68 
74 
76  const std::string GetCommandLineArgument( const std::string & key ) const;
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 
93  virtual bool IsInitialized( void ) const; //to elxconfigurationbase
94 
98  itkSetMacro( ElastixLevel, unsigned int );
99  itkGetConstMacro( ElastixLevel, unsigned int );
100 
102  itkSetMacro( TotalNumberOfElastixLevels, unsigned int );
103  itkGetConstMacro( TotalNumberOfElastixLevels, unsigned int );
104 
105  /***/
106  virtual bool GetPrintErrorMessages( void )
107  {
108  return this->m_ParameterMapInterface->GetPrintErrorMessages();
109  }
110 
119  virtual int BeforeAll( void );
120 
124  virtual int BeforeAllTransformix( void );
125 
126 
131  const std::string & parameterName ) const
132  {
133  return this->m_ParameterMapInterface->CountNumberOfParameterEntries(
134  parameterName );
135  }
136 
138  template <class T>
139  bool ReadParameter( T & parameterValue, const std::string & parameterName,
140  const unsigned int entry_nr, const bool printThisErrorMessage )
141  {
142  std::string errorMessage = "";
143  bool found = this->m_ParameterMapInterface->ReadParameter(
144  parameterValue, parameterName, entry_nr,
145  printThisErrorMessage, errorMessage );
146  if ( errorMessage != "" )
147  {
148  xl::xout["error"] << errorMessage;
149  }
150 
151  return found;
152  }
153 
155  template <class T>
156  bool ReadParameter( T & parameterValue, const std::string & parameterName,
157  const unsigned int entry_nr )
158  {
159  std::string errorMessage = "";
160  bool found = this->m_ParameterMapInterface->ReadParameter(
161  parameterValue, parameterName, entry_nr, errorMessage );
162  if ( errorMessage != "" )
163  {
164  xl::xout["error"] << errorMessage;
165  }
166 
167  return found;
168  }
169 
171  template <class T>
172  bool ReadParameter( T & parameterValue, const std::string & parameterName,
173  const std::string & prefix,
174  const unsigned int entry_nr, const int default_entry_nr,
175  const bool printThisErrorMessage ) const
176  {
177  std::string errorMessage = "";
178  bool found = this->m_ParameterMapInterface->ReadParameter(
179  parameterValue, parameterName, prefix, entry_nr, default_entry_nr,
180  printThisErrorMessage, errorMessage );
181  if ( errorMessage != "" )
182  {
183  xl::xout["error"] << errorMessage;
184  }
185 
186  return found;
187  }
188 
190  template <class T>
191  bool ReadParameter( T & parameterValue, const std::string & parameterName,
192  const std::string & prefix,
193  const unsigned int entry_nr, const int default_entry_nr ) const
194  {
195  std::string errorMessage = "";
196  bool found = this->m_ParameterMapInterface->ReadParameter(
197  parameterValue, parameterName, prefix, entry_nr, default_entry_nr,
198  errorMessage );
199  if ( errorMessage != "" )
200  {
201  xl::xout["error"] << errorMessage;
202  }
203 
204  return found;
205  }
206 
208  template <class T>
209  bool ReadParameter( std::vector<T> & parameterValues,
210  const std::string & parameterName,
211  const unsigned int entry_nr_start,
212  const unsigned int entry_nr_end,
213  const bool printThisErrorMessage ) const
214  {
215  std::string errorMessage = "";
216  bool found = this->m_ParameterMapInterface->ReadParameter(
217  parameterValues, parameterName, entry_nr_start, entry_nr_end,
218  printThisErrorMessage, errorMessage );
219  if ( errorMessage != "" )
220  {
221  xl::xout["error"] << errorMessage;
222  }
223 
224  return found;
225  }
226 
227  protected:
228 
229  Configuration();
230  virtual ~Configuration() {};
231 
236  virtual void PrintParameterFile( void ) const;
237 
238  private:
239 
240  Configuration( const Self& ); // purposely not implemented
241  void operator=( const Self& ); // purposely not implemented
242 
244  std::string m_ParameterFileName;
247 
249  unsigned int m_ElastixLevel;
251 
252  }; // end class Configuration
253 
254 
255 } // end namespace elastix
256 
257 
258 #endif // end #ifndef __elxConfiguration_H__
259 
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)
std::map< std::string, std::string > CommandLineArgumentMapType
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
The BaseComponent class is a class that all elastix components should inherit from.
#define xout
Definition: xoutmain.h:28
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
itk::SmartPointer< Self > Pointer
ParameterFileParserPointer m_ParameterFileParser
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
itk::SmartPointer< const Self > ConstPointer


Generated on 04-01-2014 for elastix by doxygen 1.8.5 elastix logo