OTB  9.0.0
Orfeo Toolbox
otbWrapperParameter.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2022 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 
25 #include "OTBApplicationEngineExport.h"
26 #include "otbMacro.h"
27 #include "otbWrapperTypes.h"
28 
29 
30 #include <itkObjectFactory.h>
31 
32 
33 #include <string>
34 
35 
36 namespace otb
37 {
38 namespace Wrapper
39 {
40 
49 class OTBApplicationEngine_EXPORT Parameter : public itk::Object
50 {
51 public:
53  typedef Parameter Self;
54  typedef itk::Object Superclass;
55  typedef itk::SmartPointer<Self> Pointer;
56  typedef itk::SmartPointer<const Self> ConstPointer;
57 
59  itkTypeMacro(Parameter, itk::Object);
60 
62  virtual void SetName(const std::string&);
63  virtual const char* GetName() const;
65 
67  virtual void SetDescription(const std::string&);
68  virtual const std::string& GetDescription() const;
70 
72  virtual void SetKey(const std::string&);
73  virtual const char* GetKey() const;
75 
77  virtual void SetActive(bool flag);
78  bool GetActive(bool recurseParents = false) const;
80 
82  virtual void SetMandatory(bool flag);
83  virtual bool GetMandatory() const;
84  virtual void MandatoryOn();
85  virtual void MandatoryOff();
87 
89  virtual void SetAutomaticValue(bool flag);
90 
92  virtual bool GetAutomaticValue() const;
93 
95  void AutomaticValueOn();
96 
98  void AutomaticValueOff();
99 
101  virtual void SetUserLevel(const UserLevel level);
102 
104  virtual UserLevel GetUserLevel() const;
105 
107  virtual void SetRole(const Role role);
108 
110  virtual Role GetRole() const;
111 
115  virtual void Reset();
116 
117  virtual bool HasValue() const = 0;
118 
119  virtual bool HasUserValue() const;
120 
121  virtual void SetUserValue(bool isUserValue);
122 
123  virtual void ClearValue();
124 
126  virtual void SetRoot(const Parameter::Pointer root);
127 
128  virtual const Parameter::Pointer GetRoot() const;
129 
131  virtual bool IsRoot() const;
132 
136  virtual void AddChild(Parameter::Pointer child);
137 
138 
142  virtual std::vector<Parameter::Pointer> GetChildrenList();
143 
145  virtual ParameterType GetType() const = 0;
146 
148  [[noreturn]] void TypeError(const std::string& target_type) const;
149 
153  virtual int ToInt() const;
154  virtual float ToFloat() const;
155  virtual double ToDouble() const;
156  virtual std::string ToString() const;
157  virtual std::vector<std::string> ToStringList() const;
159 
160  virtual void FromInt(int);
161  virtual void FromFloat(float);
162  virtual void FromDouble(double);
163  virtual void FromString(const std::string&);
164  virtual void FromStringList(const std::vector<std::string>&);
165 
166 protected:
168  Parameter();
169 
171  std::string m_Name;
172 
174  std::string m_Description;
175 
177  std::string m_Key;
178 
181 
183  bool m_Active;
184 
187 
189 
192 
194  itk::WeakPointer<Parameter> m_Root;
195 
197  std::vector<Parameter::Pointer> m_ChildrenList;
198 
199 private:
200  Parameter(const Parameter&) = delete;
201  void operator=(const Parameter&) = delete;
202 
203 }; // End class Parameter
204 
205 } // End namespace Wrapper
206 } // End namespace otb
207 
208 #endif
otb::Wrapper::UserLevel
UserLevel
Definition: otbWrapperTypes.h:102
otb::Wrapper::Parameter::m_Mandatory
bool m_Mandatory
Definition: otbWrapperParameter.h:180
otb::Wrapper::Parameter
This class represent a parameter for the wrapper framework This class is a high level class represent...
Definition: otbWrapperParameter.h:49
otb::Wrapper::Parameter::Self
Parameter Self
Definition: otbWrapperParameter.h:53
otb::Wrapper::Parameter::m_ChildrenList
std::vector< Parameter::Pointer > m_ChildrenList
Definition: otbWrapperParameter.h:197
otb::Wrapper::Parameter::m_Role
Role m_Role
Definition: otbWrapperParameter.h:191
otb::Wrapper::Parameter::m_UserValue
bool m_UserValue
Definition: otbWrapperParameter.h:186
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otbMacro.h
otb::Wrapper::Parameter::m_Active
bool m_Active
Definition: otbWrapperParameter.h:183
otb::Wrapper::Role
Role
Definition: otbWrapperTypes.h:126
otb::Wrapper::Parameter::m_Key
std::string m_Key
Definition: otbWrapperParameter.h:177
otb::Wrapper::Parameter::m_Description
std::string m_Description
Definition: otbWrapperParameter.h:174
otb::Wrapper::Parameter::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbWrapperParameter.h:55
otb::Wrapper::Parameter::m_Name
std::string m_Name
Definition: otbWrapperParameter.h:171
otb::Wrapper::Parameter::m_Root
itk::WeakPointer< Parameter > m_Root
Definition: otbWrapperParameter.h:194
otb::Wrapper::Parameter::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbWrapperParameter.h:56
otb::Wrapper::MetaDataHelper::GetType
OTBApplicationEngine_EXPORT MDType GetType(const std::string &val)
otb::Wrapper::Parameter::m_UserLevel
UserLevel m_UserLevel
Definition: otbWrapperParameter.h:188
otb::Wrapper::ParameterType
ParameterType
Definition: otbWrapperTypes.h:37
otb::Wrapper::Parameter::Superclass
itk::Object Superclass
Definition: otbWrapperParameter.h:54
otbWrapperTypes.h