OTB  10.0.0
Orfeo Toolbox
otbWrapperCommandLineLauncher.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2024 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 otbWrapperCommandLineLauncher_h
22 #define otbWrapperCommandLineLauncher_h
23 
24 
25 #include "otbWrapperApplication.h"
26 #include "otbWrapperParameter.h"
27 #include "itksys/SystemTools.hxx"
29 
30 #include "itkStdStreamLogOutput.h"
31 
33 
34 #include "itkCommand.h"
35 
36 #include <vector>
37 #include <string>
38 
39 namespace otb
40 {
41 namespace Wrapper
42 {
43 
57 class ITK_ABI_EXPORT CommandLineLauncher : public itk::Object
58 {
59 public:
62  typedef itk::Object Superclass;
63  typedef itk::SmartPointer<Self> Pointer;
64  typedef itk::SmartPointer<const Self> ConstPointer;
65 
67  itkNewMacro(Self);
68 
70  itkTypeMacro(CommandLineLauncher, itk::Object);
71 
74  typedef enum { OKPARAM, MISSINGMANDATORYPARAMETER, MISSINGPARAMETERVALUE, WRONGPARAMETERVALUE, INVALIDNUMBEROFVALUE, DEFAULT } ParamResultType;
75 
77  typedef std::vector<StandardOneLineFilterWatcher<>*> WatcherListType;
78 
80  typedef itk::MemberCommand<Self> AddProcessCommandType;
81 
86  bool Load();
87 
89  bool Load(const std::vector<std::string>& vexp);
90 
95  bool Execute();
96 
103 
109 
111  void DisplayHelp(bool longHelp = false);
112 
114  void LoadTestEnv();
115 
116 protected:
119 
122 
126  bool LoadPath();
127 
134 
140 
142  std::string DisplayParameterHelp(const Parameter::Pointer& param, const std::string paramKey, bool longHelp = false);
143 
145  bool CheckUnicity();
146 
149 
151  bool CheckKeyValidity(std::string& key);
152 
155 
157  void LinkWatchers(itk::Object* caller, const itk::EventObject& event);
158 
161 
163  unsigned int GetMaxKeySize() const;
164 
165 private:
167  bool CheckMissingMandatoryParameter(const std::string& paramKey) const;
168 
170  void CheckUnusedParameter(const std::string& paramKey) const;
171 
174  bool CheckOutputPathsValidity(const std::string& paramKey) const;
175 
177  void operator=(const CommandLineLauncher&) = delete;
178 
183 
184 
185  std::string m_Path;
186 
188  // std::string m_Expression;
189  std::vector<std::string> m_VExpression;
191 
193 
194  itk::StdStreamLogOutput::Pointer m_LogOutput;
195 
196  AddProcessCommandType::Pointer m_AddProcessCommand;
198 
199 }; // end class
200 
201 } // end namespace Wrapper
202 } // end namespace otb
203 
204 #endif // otbWrapperCommandLineLauncher_h_
itk::SmartPointer< Self > Pointer
This class check the validity of a command line application.
bool CheckKeyValidity(std::string &key)
bool CheckMissingMandatoryParameter(const std::string &paramKey) const
itk::MemberCommand< Self > AddProcessCommandType
CommandLineParser::ParseResultType ParseResultType
std::string DisplayParameterHelp(const Parameter::Pointer &param, const std::string paramKey, bool longHelp=false)
bool CheckOutputPathsValidity(const std::string &paramKey) const
unsigned int GetMaxKeySize() const
CommandLineLauncher::ParamResultType LoadParameters()
bool Load(const std::vector< std::string > &vexp)
void DisplayHelp(bool longHelp=false)
itk::StdStreamLogOutput::Pointer m_LogOutput
void LinkWatchers(itk::Object *caller, const itk::EventObject &event)
void CheckUnusedParameter(const std::string &paramKey) const
void operator=(const CommandLineLauncher &)=delete
itk::SmartPointer< const Self > ConstPointer
AddProcessCommandType::Pointer m_AddProcessCommand
std::vector< StandardOneLineFilterWatcher<> * > WatcherListType
CommandLineLauncher(const CommandLineLauncher &)=delete
itk::SmartPointer< Self > Pointer
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.