-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathitkCommandLineOption.h
executable file
·177 lines (144 loc) · 4.95 KB
/
itkCommandLineOption.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
/*=========================================================================
Program: Advanced Normalization Tools
Module: $RCSfile: itkCommandLineOption.h,v $
Language: C++
Date: $Date: 2009/01/22 22:48:30 $
Version: $Revision: 1.1 $
Copyright (c) ConsortiumOfANTS. All rights reserved.
See accompanying COPYING.txt or
http://sourceforge.net/projects/advants/files/ANTS/ANTSCopyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef __itkCommandLineOption_h
#define __itkCommandLineOption_h
#include "itkDataObject.h"
#include "itkObjectFactory.h"
#include "itkMacro.h"
#include "itkNumericTraits.h"
#include <list>
#include <string>
#include <deque>
namespace itk
{
/** \class CommandLineOption
\brief Simple data structure for holding command line options.
An option can have multiple values with each value holding 0 or more
parameters. E.g. suppose we were creating an image registration program
which has several transformation model options such as 'rigid', 'affine',
and 'deformable'. A instance of the command line option could have a
long name of "transformation", short name 't', and description
"Transformation model---rigid, affine, or deformable". The values for
this option would be "rigid", "affine", and "deformable". Each value
would then hold parameters that relate to that value. For example, a
possible subsection of the command line would be
" --transformation rigid[parameter1,parameter2,etc.]
-m mutualinformation[parameter1] --optimization gradientdescent"
*/
class ITK_EXPORT CommandLineOption
: public DataObject
{
public:
typedef CommandLineOption Self;
typedef DataObject Superclass;
typedef SmartPointer<Self> Pointer;
itkNewMacro( Self );
itkTypeMacro( Option, DataObject );
typedef std::string ValueType;
typedef std::deque<ValueType> ValueStackType;
typedef std::deque<ValueStackType> ParameterStackType;
ValueStackType GetValues()
{ return this->m_Values; }
unsigned int GetNumberOfValues()
{ return this->m_Values.size(); }
std::string GetValue( unsigned int i = 0 )
{
if( i < this->m_Values.size() )
{
return this->m_Values[i];
}
else
{
return std::string( "" );
}
}
ValueStackType GetUsageOptions()
{ return this->m_UsageOptions; }
unsigned int GetNumberOfUsageOptions()
{ return this->m_UsageOptions.size(); }
std::string GetUsageOption( unsigned int i = 0 )
{
if( i < this->m_UsageOptions.size() )
{
return this->m_UsageOptions[i];
}
else
{
return std::string( "" );
}
}
ValueStackType GetParameters( unsigned int i = 0 )
{
if( i < this->m_Parameters.size() )
{
return this->m_Parameters[i];
}
else
{
ValueStackType empty;
return empty;
}
}
std::string GetParameter( unsigned int i, unsigned int j )
{
if( i < this->m_Parameters.size() && j < this->m_Parameters[i].size() )
{
return this->m_Parameters[i][j];
}
else
{
return std::string( "" );
}
}
std::string GetParameter( unsigned int j )
{
return this->GetParameter( 0, j );
}
unsigned int GetNumberOfParameters( unsigned int i = 0 )
{
if( i < this->m_Parameters.size() )
{
return this->m_Parameters[i].size();
}
else
{
return 0;
}
}
itkSetMacro( ShortName, char );
itkGetMacro( ShortName, char );
itkSetMacro( LongName, std::string );
itkGetMacro( LongName, std::string );
itkSetMacro( Description, std::string );
itkGetMacro( Description, std::string );
void AddValue( std::string, char, char );
void AddValue( std::string s )
{
this->AddValue( s, '[', ']' );
}
void SetValue( unsigned int, std::string );
void SetUsageOption( unsigned int, std::string );
protected:
CommandLineOption();
virtual ~CommandLineOption() {};
private:
char m_ShortName;
std::string m_LongName;
std::string m_Description;
ValueStackType m_UsageOptions;
ValueStackType m_Values;
ParameterStackType m_Parameters;
};
} // end namespace itk
#endif