OTB  5.0.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 
26 namespace otb
27 {
28 namespace Wrapper
29 {
31  {
37 
43 
49  };
50 
51 
60 class ITK_ABI_EXPORT Parameter
61  : public itk::Object
62 {
63 public:
65  typedef Parameter Self;
69 
71  itkNewMacro(Self);
72 
74  itkTypeMacro(Parameter, itk::Object);
75 
77  itkSetStringMacro(Name);
78 
80  itkGetStringMacro(Name);
81 
83  itkSetStringMacro(Description);
84 
86  itkGetStringMacro(Description);
87 
89  itkSetStringMacro(Key);
90 
92  itkGetStringMacro(Key);
93 
95  itkSetMacro(Active, bool);
96 
98  bool GetActive(bool recurseParents = false) const
99  {
100  bool result = m_Active;
101  if (recurseParents && !IsRoot())
102  {
103  result = result && GetRoot()->GetActive(recurseParents);
104  }
105  return result;
106  }
108 
110  itkSetMacro(Mandatory, bool);
111 
113  itkGetConstMacro(Mandatory, bool);
114 
116  itkBooleanMacro(Mandatory);
117 
119  itkSetMacro(AutomaticValue, bool);
120 
122  itkGetConstMacro(AutomaticValue, bool);
123 
125  itkBooleanMacro(AutomaticValue);
126 
128  itkSetEnumMacro(DefaultValueMode, DefaultValueMode);
129 
131  itkGetEnumMacro(DefaultValueMode, DefaultValueMode);
132 
134  itkSetEnumMacro(UserLevel, UserLevel);
135 
137  itkGetEnumMacro(UserLevel, UserLevel);
138 
140  itkSetEnumMacro(Role, Role);
141 
143  itkGetEnumMacro(Role, Role);
144 
148  virtual void Reset()
149  {
150  }
151 
152  virtual bool HasValue() const
153  {
154  itkExceptionMacro(<<"HasValue() method must be re-implemented by sub-classes.");
155  }
156 
157  virtual bool HasUserValue() const
158  {
159  return HasValue() && m_UserValue;
160  }
161 
162  virtual void SetUserValue(bool isUserValue)
163  {
164  m_UserValue = isUserValue;
165  }
166 
167  virtual void ClearValue()
168  {
169  itkExceptionMacro(<<"ClearValue() method must be re-implemented by sub-classes.");
170  }
171 
173  virtual void SetRoot(const Parameter::Pointer root)
174  {
175  m_Root = root.GetPointer();
176  }
177 
178  virtual const Parameter::Pointer GetRoot() const
179  {
180  return m_Root.GetPointer();
181  }
182 
184  virtual bool IsRoot() const
185  {
186  return (this == m_Root.GetPointer());
187  }
188 
192  virtual void AddChild(Parameter::Pointer child)
193  {
194  m_ChildrenList.push_back(child);
195  }
196 
200  virtual std::vector<Parameter::Pointer > GetChildrenList()
201  {
202  return m_ChildrenList;
203  }
204 
208  virtual bool IsChecked()
209  {
210  return m_IsChecked;
211  }
212 
214  virtual void SetChecked(const bool value)
215  {
216  m_IsChecked = value;
217  }
218 
219 protected:
221  Parameter() : m_Name(""),
222  m_Description(""),
223  m_Key(""),
224  m_Mandatory(true),
225  m_Active(false),
226  m_UserValue(false),
227  m_AutomaticValue(false),
228  m_DefaultValueMode(DefaultValueMode_UNKNOWN),
229  m_UserLevel(UserLevel_Basic),
230  m_Role(Role_Input),
231  m_Root(this),
232  m_IsChecked(false)
233  {}
234 
236  virtual ~Parameter()
237  {}
238 
240  std::string m_Name;
241 
243  std::string m_Description;
244 
246  std::string m_Key;
247 
250 
252  bool m_Active;
253 
256 
259 
262 
264 
267 
270 
272  std::vector<Parameter::Pointer > m_ChildrenList;
273 
276 
277 private:
278  Parameter(const Parameter &); //purposely not implemented
279  void operator =(const Parameter&); //purposely not implemented
280 
281 }; // End class Parameter
282 
283 } // End namespace Wrapper
284 } // End namespace otb
285 
286 #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