Salome HOME
Documentation fixes.
[modules/shaper.git] / src / ParametersPlugin / ParametersPlugin_PyInterp.h
1 /*
2  * ParametersPlugin_PyInterp.h
3  *
4  *  Created on: Apr 2, 2015
5  *      Author: sbh
6  */
7
8 #ifndef PARAMETERSPLUGIN_PYINTERP_H_
9 #define PARAMETERSPLUGIN_PYINTERP_H_
10
11 #include <PyInterp_Interp.h>
12 #include <ParametersPlugin.h>
13
14 #include <list>
15 #include <string>
16 #include <utility>
17
18 /**
19  * \class ParametersPlugin_PyInterp
20  * \ingroup Plugins
21  * \brief Helper class for using Python interpreter.
22  */
23 class PARAMETERSPLUGIN_EXPORT ParametersPlugin_PyInterp : public PyInterp_Interp
24 {
25  public:
26   ParametersPlugin_PyInterp();
27   virtual ~ParametersPlugin_PyInterp();
28
29   /// Returns a list of positions for theName in theExpression.
30   std::list<std::pair<int, int> > positions(const std::string& theExpression,
31                                             const std::string& theName);
32   /// Compiles theExpression and returns a list of parameters from theExpression.
33   std::list<std::string> compile(const std::string& theExpression);
34   /// Extends local context with the list of parameters with values.
35   void extendLocalContext(const std::list<std::string>& theParameters);
36   /// Clears local context.
37   void clearLocalContext();
38   /// Evaluates theExpression and returns its value.
39   double evaluate(const std::string& theExpression, std::string& theError);
40
41  protected:
42   /// Returns error message.
43   std::string errorMessage();
44   /// Overrides PyInterp_Interp.
45   virtual bool initContext();
46   /// Reimplemented from PyInterp_Interp::closeContext().
47   virtual void closeContext();
48 };
49
50 #endif /* PARAMETERSPLUGIN_PYINTERP_H_ */