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