OTB  9.0.0
Orfeo Toolbox
otbParser.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 otbParser_h
22 #define otbParser_h
23 
24 #include "itkLightObject.h"
25 #include "itkObjectFactory.h"
26 
27 #include "otb_muparser.h"
28 
29 namespace otb
30 {
31 
32 class ParserImpl;
33 
34 
44 class ITK_EXPORT Parser : public itk::LightObject
45 {
46 public:
48  typedef Parser Self;
49  typedef itk::LightObject Superclass;
50  typedef itk::SmartPointer<Self> Pointer;
51  typedef itk::SmartPointer<const Self> ConstPointer;
52 
54  itkNewMacro(Self);
55 
57  itkTypeMacro(Parser, itk::LightObject);
58 
60  typedef Parser ParserType;
61  typedef double ValueType;
62 
64  typedef std::map<std::string, int> FunctionMapType;
65 
67  virtual void SetExpr(const std::string& Expression);
68 
70  ValueType Eval();
71 
73  void DefineVar(const std::string& sName, ValueType* fVar);
74 
76  void ClearVar();
77 
79  const std::string& GetExpr() const;
80 
82  const std::map<std::string, Parser::ValueType*>& GetVar() const;
83 
85  FunctionMapType GetFunList() const;
86 
88  bool CheckExpr();
89 
90 protected:
91  Parser();
92  ~Parser() override;
93  void PrintSelf(std::ostream& os, itk::Indent indent) const override;
94 
95 
96 private:
97  Parser(const Self&) = delete;
98  void operator=(const Self&) = delete;
99 
100  typedef itk::SmartPointer<ParserImpl> ParserImplPtr;
102 }; // end class
103 
104 } // end namespace otb
105 
106 #endif
otb::Parser::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbParser.h:51
otb::Parser::FunctionMapType
std::map< std::string, int > FunctionMapType
Definition: otbParser.h:64
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::Parser::Superclass
itk::LightObject Superclass
Definition: otbParser.h:49
otb::Parser::ParserType
Parser ParserType
Definition: otbParser.h:57
otb::Parser::Self
Parser Self
Definition: otbParser.h:48
otb::Parser
Definition of the standard floating point parser. Standard implementation of the mathematical express...
Definition: otbParser.h:44
otb::Parser::m_InternalParser
ParserImplPtr m_InternalParser
Definition: otbParser.h:101
otb::Parser::ValueType
double ValueType
Definition: otbParser.h:61
otb::Parser::ParserImplPtr
itk::SmartPointer< ParserImpl > ParserImplPtr
Definition: otbParser.h:100
otb::Parser::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbParser.h:50