OTB  6.5.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  itkTypeMacro(Parameter, itk::Object);
76 
78  itkSetStringMacro(Name);
79 
81  itkGetStringMacro(Name);
82 
84  itkSetStringMacro(Description);
85 
87  itkGetConstReferenceMacro( Description, std::string );
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 = 0;
154 
155  virtual bool HasUserValue() const
156  {
157  return this->HasValue() && m_UserValue;
158  }
159 
160  virtual void SetUserValue(bool isUserValue)
161  {
162  m_UserValue = isUserValue;
163  }
164 
165  virtual void ClearValue()
166  {
167  SetActive( false );
168  Modified();
169  }
170 
172  virtual void SetRoot(const Parameter::Pointer root)
173  {
174  m_Root = root.GetPointer();
175  }
176 
177  virtual const Parameter::Pointer GetRoot() const
178  {
179  return m_Root.GetPointer();
180  }
181 
183  virtual bool IsRoot() const
184  {
185  return (this == m_Root.GetPointer());
186  }
187 
191  virtual void AddChild(Parameter::Pointer child)
192  {
193  m_ChildrenList.push_back(child);
194  }
195 
199  virtual std::vector<Parameter::Pointer > GetChildrenList()
200  {
201  return m_ChildrenList;
202  }
203 
207  virtual bool IsChecked() const
208  {
209  return m_IsChecked;
210  }
211 
213  virtual void SetChecked(const bool value)
214  {
215  m_IsChecked = value;
216  }
217 
218 protected:
221  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  ~Parameter() ITK_OVERRIDE {}
237 
239  std::string m_Name;
240 
242  std::string m_Description;
243 
245  std::string m_Key;
246 
249 
251  bool m_Active;
252 
255 
258 
261 
263 
266 
269 
271  std::vector<Parameter::Pointer > m_ChildrenList;
272 
275 
276 private:
277  Parameter(const Parameter &); //purposely not implemented
278  void operator =(const Parameter&); //purposely not implemented
279 
280 }; // End class Parameter
281 
282 } // End namespace Wrapper
283 } // End namespace otb
284 
285 #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 bool IsChecked() 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 HasUserValue() const
itk::SmartPointer< Self > Pointer
DefaultValueMode m_DefaultValueMode