1 // Copyright (C) 2014-2017 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
21 * InitializationPlugin_PyInterp.h
23 * Created on: Apr 2, 2015
27 #ifndef INITIALIZATIONPLUGIN_PYINTERP_H_
28 #define INITIALIZATIONPLUGIN_PYINTERP_H_
30 #include <PyInterp_Interp.h>
31 #include <InitializationPlugin.h>
38 * \class InitializationPlugin_PyInterp
40 * \brief Helper class for using Python interpreter.
42 class INITIALIZATIONPLUGIN_EXPORT InitializationPlugin_PyInterp : public PyInterp_Interp
45 InitializationPlugin_PyInterp();
46 virtual ~InitializationPlugin_PyInterp();
48 /// Returns a list of positions for theName in theExpression.
49 std::list<std::pair<int, int> > positions(const std::string& theExpression,
50 const std::string& theName);
51 /// Compiles theExpression and returns a list of parameters used in theExpression.
52 std::list<std::string> compile(const std::string& theExpression);
53 /// Extends local context with the list of parameters.
54 void extendLocalContext(const std::list<std::string>& theParameters);
55 /// Clears local context.
56 void clearLocalContext();
57 /// Evaluates theExpression and returns its value.
58 double evaluate(const std::string& theExpression, std::string& theError);
61 /// Returns error message.
62 std::string errorMessage();
63 /// Overrides PyInterp_Interp.
64 virtual bool initContext();
65 /// Reimplemented from PyInterp_Interp::closeContext().
66 virtual void closeContext();
69 #endif /* INITIALIZATIONPLUGIN_PYINTERP_H_ */