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  * Copyright UMC Utrecht and contributors
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef __elxConfiguration_H__
19 #define __elxConfiguration_H__
20 
21 #include "itkObject.h"
22 #include "elxBaseComponent.h"
23 
24 #include "itkParameterFileParser.h"
26 #include <map>
27 #include "xoutmain.h"
28 
29 namespace elastix
30 {
31 
50 class Configuration : public itk::Object, public BaseComponent
51 {
52 public:
53 
56  typedef itk::Object Superclass1;
58  typedef itk::SmartPointer< Self > Pointer;
59  typedef itk::SmartPointer< const Self > ConstPointer;
60 
62  itkNewMacro( Self );
63 
65  itkTypeMacro( Configuration, itk::Object );
66 
68  typedef std::map< std::string, std::string > CommandLineArgumentMapType;
69  typedef CommandLineArgumentMapType::value_type CommandLineEntryType;
70 
76 
78  const std::string GetCommandLineArgument( const std::string & key ) const;
79 
80  void SetCommandLineArgument( const std::string & key, const std::string & value );
81 
83  itkGetStringMacro( ParameterFileName );
84  itkSetStringMacro( ParameterFileName );
85 
93  virtual int Initialize( const CommandLineArgumentMapType & _arg );
94 
95  virtual int Initialize( const CommandLineArgumentMapType & _arg,
97 
99  virtual bool IsInitialized( void ) const; //to elxconfigurationbase
100 
104  itkSetMacro( ElastixLevel, unsigned int );
105  itkGetConstMacro( ElastixLevel, unsigned int );
106 
108  itkSetMacro( TotalNumberOfElastixLevels, unsigned int );
109  itkGetConstMacro( TotalNumberOfElastixLevels, unsigned int );
110 
111  /***/
112  virtual bool GetPrintErrorMessages( void )
113  {
114  return this->m_ParameterMapInterface->GetPrintErrorMessages();
115  }
116 
117 
126  virtual int BeforeAll( void );
127 
131  virtual int BeforeAllTransformix( void );
132 
137  const std::string & parameterName ) const
138  {
139  return this->m_ParameterMapInterface->CountNumberOfParameterEntries(
140  parameterName );
141  }
142 
143 
145  template< class T >
146  bool ReadParameter( T & parameterValue, const std::string & parameterName,
147  const unsigned int entry_nr, const bool printThisErrorMessage )
148  {
149  std::string errorMessage = "";
150  bool found = this->m_ParameterMapInterface->ReadParameter(
151  parameterValue, parameterName, entry_nr,
152  printThisErrorMessage, errorMessage );
153  if( errorMessage != "" )
154  {
155  xl::xout[ "error" ] << errorMessage;
156  }
157 
158  return found;
159  }
160 
161 
163  template< class T >
164  bool ReadParameter( T & parameterValue, const std::string & parameterName,
165  const unsigned int entry_nr )
166  {
167  std::string errorMessage = "";
168  bool found = this->m_ParameterMapInterface->ReadParameter(
169  parameterValue, parameterName, entry_nr, errorMessage );
170  if( errorMessage != "" )
171  {
172  xl::xout[ "error" ] << errorMessage;
173  }
174 
175  return found;
176  }
177 
178 
180  template< class T >
181  bool ReadParameter( T & parameterValue, const std::string & parameterName,
182  const std::string & prefix,
183  const unsigned int entry_nr, const int default_entry_nr,
184  const bool printThisErrorMessage ) const
185  {
186  std::string errorMessage = "";
187  bool found = this->m_ParameterMapInterface->ReadParameter(
188  parameterValue, parameterName, prefix, entry_nr, default_entry_nr,
189  printThisErrorMessage, errorMessage );
190  if( errorMessage != "" )
191  {
192  xl::xout[ "error" ] << errorMessage;
193  }
194 
195  return found;
196  }
197 
198 
200  template< class T >
201  bool ReadParameter( T & parameterValue, const std::string & parameterName,
202  const std::string & prefix,
203  const unsigned int entry_nr, const int default_entry_nr ) const
204  {
205  std::string errorMessage = "";
206  bool found = this->m_ParameterMapInterface->ReadParameter(
207  parameterValue, parameterName, prefix, entry_nr, default_entry_nr,
208  errorMessage );
209  if( errorMessage != "" )
210  {
211  xl::xout[ "error" ] << errorMessage;
212  }
213 
214  return found;
215  }
216 
217 
219  template< class T >
220  bool ReadParameter( std::vector< T > & parameterValues,
221  const std::string & parameterName,
222  const unsigned int entry_nr_start,
223  const unsigned int entry_nr_end,
224  const bool printThisErrorMessage ) const
225  {
226  std::string errorMessage = "";
227  bool found = this->m_ParameterMapInterface->ReadParameter(
228  parameterValues, parameterName, entry_nr_start, entry_nr_end,
229  printThisErrorMessage, errorMessage );
230  if( errorMessage != "" )
231  {
232  xl::xout[ "error" ] << errorMessage;
233  }
234 
235  return found;
236  }
237 
238 
239 protected:
240 
241  Configuration();
242  virtual ~Configuration() {}
243 
248  virtual void PrintParameterFile( void ) const;
249 
250 private:
251 
252  Configuration( const Self & ); // purposely not implemented
253  void operator=( const Self & ); // purposely not implemented
254 
255  CommandLineArgumentMapType m_CommandLineArgumentMap;
256  std::string m_ParameterFileName;
257  ParameterFileParserPointer m_ParameterFileParser;
258  ParameterMapInterfacePointer m_ParameterMapInterface;
259 
261  unsigned int m_ElastixLevel;
263 
264 };
265 
266 } // end namespace elastix
267 
268 #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:30
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
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 04-09-2015 for elastix by doxygen 1.8.9.1 elastix logo