OTB  6.7.0
Orfeo Toolbox
otbWrapperChoiceParameter.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2019 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 otbWrapperChoiceParameter_h
22 #define otbWrapperChoiceParameter_h
23 
25 #include <string>
26 
27 namespace otb
28 {
29 namespace Wrapper
30 {
31 
40 class OTBApplicationEngine_EXPORT ChoiceParameter
41  : public Parameter
42 {
43 public:
49 
51  itkNewMacro(Self);
52 
54  itkTypeMacro(ChoiceParameter, Parameter);
55 
57  void AddChoice( std::string choicekey, std::string choiceName );
58 
60  std::string GetChoiceKey(int i) const;
61 
63  std::vector<std::string> GetChoiceKeys();
64 
66  std::string GetChoiceName( int i );
67 
69  std::vector<std::string> GetChoiceNames();
70 
72  ParameterGroup::Pointer GetChoiceParameterGroupByIndex( int i );
73 
75  ParameterGroup::Pointer GetChoiceParameterGroupByKey( std::string choiceKey );
76 
78  std::vector<std::string> GetParametersKeys();
79 
81  unsigned int GetNbChoices( void );
82 
84  virtual void SetValue(unsigned int v);
85 
87  virtual void SetValue(std::string choiceKey);
88 
90  virtual unsigned int GetValue() const;
91 
92  bool HasValue() const override;
93  void ClearValue() override;
94 
95  ParameterType GetType() const override;
96 
97  int ToInt() const override;
98  void FromInt(int value) override;
99 
100  std::string ToString() const override;
101  void FromString(const std::string& value) override;
102 
103 protected:
105  ChoiceParameter();
106 
108  ~ChoiceParameter() override;
109 
110  struct Choice
111  {
112  Choice() {}
113 
114  std::string m_Key;
115  std::string m_Name;
117  };
118 
119  typedef std::vector<Choice> ChoiceList;
121 
122  unsigned int m_CurrentChoice;
123 
124 private:
125  ChoiceParameter(const ChoiceParameter &) = delete;
126  void operator =(const ChoiceParameter&) = delete;
127 
128 }; // End class Parameter
129 
130 } // End namespace Wrapper
131 } // End namespace otb
132 
133 #endif
This class represent a parameter for the wrapper framework This class is a high level class represent...
OTBApplicationEngine_EXPORT MDType GetType(const std::string &val)
This class represent a multiple choice parameter for the wrapper framework.
const char * ToString(const QString &str)
Append the content of a StringVector object to the content of a QStringList object.
Definition: mvdAlgorithm.h:521
itk::SmartPointer< const Self > ConstPointer