OTB  5.9.0
Orfeo Toolbox
otbWrapperParameter.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: ORFEO Toolbox
4  Language: C++
5  Date: $Date$
6  Version: $Revision$
7 
8 
9  Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
10  See OTBCopyright.txt for details.
11 
12 
13  This software is distributed WITHOUT ANY WARRANTY; without even
14  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  PURPOSE. See the above copyright notices for more information.
16 
17 =========================================================================*/
18 #ifndef otbWrapperParameter_h
19 #define otbWrapperParameter_h
20 
21 #include "otbMacro.h"
22 #include "itkObjectFactory.h"
23 
24 #include "otbWrapperTypes.h"
25 #include "OTBApplicationEngineExport.h"
26 
27 namespace otb
28 {
29 namespace Wrapper
30 {
32  {
38 
44 
50  };
51 
52 
61 class OTBApplicationEngine_EXPORT Parameter
62  : public itk::Object
63 {
64 public:
66  typedef Parameter Self;
70 
72  itkNewMacro(Self);
73 
75  itkTypeMacro(Parameter, itk::Object);
76 
78  itkSetStringMacro(Name);
79 
81  itkGetStringMacro(Name);
82 
84  itkSetStringMacro(Description);
85 
87  itkGetStringMacro(Description);
88 
90  itkSetStringMacro(Key);
91 
93  itkGetStringMacro(Key);
94 
96  itkSetMacro(Active, bool);
97 
99  bool GetActive(bool recurseParents = false) const
100  {
101  bool result = m_Active;
102  if (recurseParents && !IsRoot())
103  {
104  result = result && GetRoot()->GetActive(recurseParents);
105  }
106  return result;
107  }
109 
111  itkSetMacro(Mandatory, bool);
112 
114  itkGetConstMacro(Mandatory, bool);
115 
117  itkBooleanMacro(Mandatory);
118 
120  itkSetMacro(AutomaticValue, bool);
121 
123  itkGetConstMacro(AutomaticValue, bool);
124 
126  itkBooleanMacro(AutomaticValue);
127 
129  itkSetEnumMacro(DefaultValueMode, DefaultValueMode);
130 
132  itkGetEnumMacro(DefaultValueMode, DefaultValueMode);
133 
135  itkSetEnumMacro(UserLevel, UserLevel);
136 
138  itkGetEnumMacro(UserLevel, UserLevel);
139 
141  itkSetEnumMacro(Role, Role);
142 
144  itkGetEnumMacro(Role, Role);
145 
149  virtual void Reset()
150  {
151  }
152 
153  virtual bool HasValue() const
154  {
155  itkExceptionMacro(<<"HasValue() method must be re-implemented by sub-classes.");
156  }
157 
158  virtual bool HasUserValue() const
159  {
160  return HasValue() && m_UserValue;
161  }
162 
163  virtual void SetUserValue(bool isUserValue)
164  {
165  m_UserValue = isUserValue;
166  }
167 
168  virtual void ClearValue()
169  {
170  itkExceptionMacro(<<"ClearValue() method must be re-implemented by sub-classes.");
171  }
172 
174  virtual void SetRoot(const Parameter::Pointer root)
175  {
176  m_Root = root.GetPointer();
177  }
178 
179  virtual const Parameter::Pointer GetRoot() const
180  {
181  return m_Root.GetPointer();
182  }
183 
185  virtual bool IsRoot() const
186  {
187  return (this == m_Root.GetPointer());
188  }
189 
193  virtual void AddChild(Parameter::Pointer child)
194  {
195  m_ChildrenList.push_back(child);
196  }
197 
201  virtual std::vector<Parameter::Pointer > GetChildrenList()
202  {
203  return m_ChildrenList;
204  }
205 
209  virtual bool IsChecked()
210  {
211  return m_IsChecked;
212  }
213 
215  virtual void SetChecked(const bool value)
216  {
217  m_IsChecked = value;
218  }
219 
220 protected:
222  Parameter() : m_Name(""),
223  m_Description(""),
224  m_Key(""),
225  m_Mandatory(true),
226  m_Active(false),
227  m_UserValue(false),
228  m_AutomaticValue(false),
229  m_DefaultValueMode(DefaultValueMode_UNKNOWN),
230  m_UserLevel(UserLevel_Basic),
231  m_Role(Role_Input),
232  m_Root(this),
233  m_IsChecked(false)
234  {}
235 
237  ~Parameter() ITK_OVERRIDE
238  {}
239 
241  std::string m_Name;
242 
244  std::string m_Description;
245 
247  std::string m_Key;
248 
251 
253  bool m_Active;
254 
257 
260 
263 
265 
268 
271 
273  std::vector<Parameter::Pointer > m_ChildrenList;
274 
277 
278 private:
279  Parameter(const Parameter &); //purposely not implemented
280  void operator =(const Parameter&); //purposely not implemented
281 
282 }; // End class Parameter
283 
284 } // End namespace Wrapper
285 } // End namespace otb
286 
287 #endif
virtual void SetUserValue(bool isUserValue)
virtual void AddChild(Parameter::Pointer child)
itk::WeakPointer< Parameter > m_Root
bool GetActive(bool recurseParents=false) const
This class represent a parameter for the wrapper framework This class is a high level class represent...
virtual void SetChecked(const bool value)
virtual void SetRoot(const Parameter::Pointer root)
ObjectType * GetPointer() const
virtual bool IsRoot() const
virtual std::vector< Parameter::Pointer > GetChildrenList()
itk::SmartPointer< const Self > ConstPointer
std::vector< Parameter::Pointer > m_ChildrenList
virtual const Parameter::Pointer GetRoot() const
virtual bool HasValue() const
virtual bool HasUserValue() const
itk::SmartPointer< Self > Pointer
DefaultValueMode m_DefaultValueMode