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
26#include <map>
27#include "xoutmain.h"
28
29namespace elastix
30{
31
50class Configuration : public itk::Object, public BaseComponent
51{
52public:
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 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 int BeforeAll( void ) override;
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
239protected:
240
242 ~Configuration() override {}
243
248 virtual void PrintParameterFile( void ) const;
249
250private:
251
252 Configuration( const Self & ); // purposely not implemented
253 void operator=( const Self & ); // purposely not implemented
254
259
261 unsigned int m_ElastixLevel;
263
264};
265
266} // end namespace elastix
267
268#endif // end #ifndef __elxConfiguration_H__
The BaseComponent class is a class that all elastix components should inherit from.
A class that deals with user given parameters and command line arguments.
void SetCommandLineArgument(const std::string &key, const std::string &value)
bool ReadParameter(T &parameterValue, const std::string &parameterName, const std::string &prefix, const unsigned int entry_nr, const int default_entry_nr) const
ParameterFileParserType::Pointer ParameterFileParserPointer
itk::SmartPointer< Self > Pointer
bool ReadParameter(T &parameterValue, const std::string &parameterName, const unsigned int entry_nr)
itk::ParameterFileParser ParameterFileParserType
Configuration(const Self &)
virtual bool GetPrintErrorMessages(void)
std::vcl_size_t CountNumberOfParameterEntries(const std::string &parameterName) const
void operator=(const Self &)
virtual int BeforeAllTransformix(void)
unsigned int m_TotalNumberOfElastixLevels
ParameterMapInterfaceType::Pointer ParameterMapInterfacePointer
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
ParameterFileParserPointer m_ParameterFileParser
virtual void PrintParameterFile(void) const
itk::ParameterMapInterface ParameterMapInterfaceType
std::map< std::string, std::string > CommandLineArgumentMapType
virtual bool IsInitialized(void) const
CommandLineArgumentMapType m_CommandLineArgumentMap
virtual int Initialize(const CommandLineArgumentMapType &_arg)
CommandLineArgumentMapType::value_type CommandLineEntryType
virtual int Initialize(const CommandLineArgumentMapType &_arg, const ParameterFileParserType::ParameterMapType &inputMap)
int BeforeAll(void) override
bool ReadParameter(T &parameterValue, const std::string &parameterName, const unsigned int entry_nr, const bool printThisErrorMessage)
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
itk::SmartPointer< const Self > ConstPointer
ParameterMapInterfacePointer m_ParameterMapInterface
std::string GetCommandLineArgument(const std::string &key) const
Implements functionality to read a parameter file.
std::map< std::string, ParameterValuesType > ParameterMapType
Implements functionality to get parameters from a parameter map.
#define xout
Definition: xoutmain.h:30


Generated on 1667476801 for elastix by doxygen 1.9.4 elastix logo