OTB  6.1.0
Orfeo Toolbox
otbWrapperParameter.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES)
3  *
4  * This file is part of Orfeo Toolbox
5  *
6  * https://www.orfeo-toolbox.org/
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */
20 
21 #ifndef otbWrapperParameter_h
22 #define otbWrapperParameter_h
23 
24 #include "otbMacro.h"
25 #include "itkObjectFactory.h"
26 
27 #include "otbWrapperTypes.h"
28 #include "OTBApplicationEngineExport.h"
29 
30 namespace otb
31 {
32 namespace Wrapper
33 {
35  {
41 
47 
53  };
54 
55 
64 class OTBApplicationEngine_EXPORT Parameter
65  : public itk::Object
66 {
67 public:
69  typedef Parameter Self;
73 
75  itkNewMacro(Self);
76 
78  itkTypeMacro(Parameter, itk::Object);
79 
81  itkSetStringMacro(Name);
82 
84  itkGetStringMacro(Name);
85 
87  itkSetStringMacro(Description);
88 
90  itkGetStringMacro(Description);
91 
93  itkSetStringMacro(Key);
94 
96  itkGetStringMacro(Key);
97 
99  itkSetMacro(Active, bool);
100 
102  bool GetActive(bool recurseParents = false) const
103  {
104  bool result = m_Active;
105  if (recurseParents && !IsRoot())
106  {
107  result = result && GetRoot()->GetActive(recurseParents);
108  }
109  return result;
110  }
112 
114  itkSetMacro(Mandatory, bool);
115 
117  itkGetConstMacro(Mandatory, bool);
118 
120  itkBooleanMacro(Mandatory);
121 
123  itkSetMacro(AutomaticValue, bool);
124 
126  itkGetConstMacro(AutomaticValue, bool);
127 
129  itkBooleanMacro(AutomaticValue);
130 
132  itkSetEnumMacro(DefaultValueMode, DefaultValueMode);
133 
135  itkGetEnumMacro(DefaultValueMode, DefaultValueMode);
136 
138  itkSetEnumMacro(UserLevel, UserLevel);
139 
141  itkGetEnumMacro(UserLevel, UserLevel);
142 
144  itkSetEnumMacro(Role, Role);
145 
147  itkGetEnumMacro(Role, Role);
148 
152  virtual void Reset()
153  {
154  }
155 
156  virtual bool HasValue() const
157  {
158  itkExceptionMacro(<<"HasValue() method must be re-implemented by sub-classes.");
159  }
160 
161  virtual bool HasUserValue() const
162  {
163  return HasValue() && m_UserValue;
164  }
165 
166  virtual void SetUserValue(bool isUserValue)
167  {
168  m_UserValue = isUserValue;
169  }
170 
171  virtual void ClearValue()
172  {
173  itkExceptionMacro(<<"ClearValue() method must be re-implemented by sub-classes.");
174  }
175 
177  virtual void SetRoot(const Parameter::Pointer root)
178  {
179  m_Root = root.GetPointer();
180  }
181 
182  virtual const Parameter::Pointer GetRoot() const
183  {
184  return m_Root.GetPointer();
185  }
186 
188  virtual bool IsRoot() const
189  {
190  return (this == m_Root.GetPointer());
191  }
192 
196  virtual void AddChild(Parameter::Pointer child)
197  {
198  m_ChildrenList.push_back(child);
199  }
200 
204  virtual std::vector<Parameter::Pointer > GetChildrenList()
205  {
206  return m_ChildrenList;
207  }
208 
212  virtual bool IsChecked()
213  {
214  return m_IsChecked;
215  }
216 
218  virtual void SetChecked(const bool value)
219  {
220  m_IsChecked = value;
221  }
222 
223 protected:
225  Parameter() : m_Name(""),
226  m_Description(""),
227  m_Key(""),
228  m_Mandatory(true),
229  m_Active(false),
230  m_UserValue(false),
231  m_AutomaticValue(false),
232  m_DefaultValueMode(DefaultValueMode_UNKNOWN),
233  m_UserLevel(UserLevel_Basic),
234  m_Role(Role_Input),
235  m_Root(this),
236  m_IsChecked(false)
237  {}
238 
240  ~Parameter() ITK_OVERRIDE
241  {}
242 
244  std::string m_Name;
245 
247  std::string m_Description;
248 
250  std::string m_Key;
251 
254 
256  bool m_Active;
257 
260 
263 
266 
268 
271 
274 
276  std::vector<Parameter::Pointer > m_ChildrenList;
277 
280 
281 private:
282  Parameter(const Parameter &); //purposely not implemented
283  void operator =(const Parameter&); //purposely not implemented
284 
285 }; // End class Parameter
286 
287 } // End namespace Wrapper
288 } // End namespace otb
289 
290 #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