Orfeo Toolbox  4.2
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 "itkObject.h"
23 #include "itkObjectFactory.h"
24 
25 #include "otbWrapperTypes.h"
26 
27 namespace otb
28 {
29 namespace Wrapper
30 {
32  {
43 
49  };
50 
51 
58 class ITK_ABI_EXPORT Parameter
59  : public itk::Object
60 {
61 public:
63  typedef Parameter Self;
67 
69  itkNewMacro(Self);
70 
72  itkTypeMacro(Parameter, itk::Object);
73 
75  itkSetStringMacro(Name);
76 
78  itkGetStringMacro(Name);
79 
81  itkSetStringMacro(Description);
82 
84  itkGetStringMacro(Description);
85 
87  itkSetStringMacro(Key);
88 
90  itkGetStringMacro(Key);
91 
93  itkSetMacro(Active, bool);
94 
96  bool GetActive(bool recurseParents = false) const
97  {
98  bool result = m_Active;
99  if (recurseParents && !IsRoot())
100  {
101  result = result && GetRoot()->GetActive(recurseParents);
102  }
103  return result;
104  }
105 
107  itkSetMacro(Mandatory, bool);
108 
110  itkGetConstMacro(Mandatory, bool);
111 
113  itkBooleanMacro(Mandatory);
114 
116  itkSetMacro(AutomaticValue, bool);
117 
119  itkGetConstMacro(AutomaticValue, bool);
120 
122  itkBooleanMacro(AutomaticValue);
123 
125  itkSetEnumMacro(DefaultValueMode, DefaultValueMode);
126 
128  itkGetEnumMacro(DefaultValueMode, DefaultValueMode);
129 
131  itkSetEnumMacro(UserLevel, UserLevel);
132 
134  itkGetEnumMacro(UserLevel, UserLevel);
135 
137  itkSetEnumMacro(Role, Role);
138 
140  itkGetEnumMacro(Role, Role);
141 
145  virtual void Reset()
146  {
147  }
148 
149  virtual bool HasValue() const
150  {
151  itkExceptionMacro(<<"HasValue() method must be re-implemented by sub-classes.");
152  }
153 
154  virtual bool HasUserValue() const
155  {
156  return HasValue() && m_UserValue;
157  }
158 
159  virtual void SetUserValue(bool isUserValue)
160  {
161  m_UserValue = isUserValue;
162  }
163 
164  virtual void ClearValue()
165  {
166  itkExceptionMacro(<<"ClearValue() method must be re-implemented by sub-classes.");
167  }
168 
170  virtual void SetRoot(const Parameter::Pointer root)
171  {
172  m_Root = root.GetPointer();
173  }
174 
175  virtual const Parameter::Pointer GetRoot() const
176  {
177  return m_Root.GetPointer();
178  }
179 
181  virtual bool IsRoot() const
182  {
183  return (this == m_Root.GetPointer());
184  }
185 
189  virtual void AddChild(Parameter::Pointer child)
190  {
191  m_ChildrenList.push_back(child);
192  }
193 
197  virtual std::vector<Parameter::Pointer > GetChildrenList()
198  {
199  return m_ChildrenList;
200  }
201 
205  virtual bool IsChecked()
206  {
207  return m_IsChecked;
208  }
209 
211  virtual void SetChecked(const bool value)
212  {
213  m_IsChecked = value;
214  }
215 
216 protected:
218  Parameter() : m_Name(""),
219  m_Description(""),
220  m_Key(""),
221  m_Mandatory(true),
222  m_Active(false),
223  m_UserValue(false),
224  m_AutomaticValue(false),
225  m_DefaultValueMode(DefaultValueMode_UNKNOWN),
226  m_UserLevel(UserLevel_Basic),
227  m_Role(Role_Input),
228  m_Root(this),
229  m_IsChecked(false)
230  {}
231 
233  virtual ~Parameter()
234  {}
235 
237  std::string m_Name;
238 
240  std::string m_Description;
241 
243  std::string m_Key;
244 
247 
249  bool m_Active;
250 
253 
256 
259 
261 
264 
267 
269  std::vector<Parameter::Pointer > m_ChildrenList;
270 
273 
274 private:
275  Parameter(const Parameter &); //purposely not implemented
276  void operator =(const Parameter&); //purposely not implemented
277 
278 }; // End class Parameter
279 
280 } // End namespace Wrapper
281 } // End namespace otb
282 
283 #endif

Generated at Sat Aug 30 2014 16:36:33 for Orfeo Toolbox with doxygen 1.8.3.1