Salome HOME
updated copyright message
[modules/shaper.git] / src / InitializationPlugin / InitializationPlugin_EvalListener.h
1 // Copyright (C) 2014-2023  CEA, EDF
2 //
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.
7 //
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.
12 //
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
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #ifndef SRC_INITIALIZATIONPLUGIN_EVALLISTENER_H_
21 #define SRC_INITIALIZATIONPLUGIN_EVALLISTENER_H_
22
23 #include <InitializationPlugin.h>
24 #include <Events_Loop.h>
25
26 class ModelAPI_Attribute;
27 class ModelAPI_Document;
28 class ModelAPI_Feature;
29 class ModelAPI_ResultParameter;
30 class InitializationPlugin_Parameter;
31 class InitializationPlugin_PyInterp;
32
33 /**
34  * \class InitializationPlugin_EvalListener
35  * \ingroup Plugins
36  * \brief Class which process the events from the event loop.
37  */
38 class InitializationPlugin_EvalListener : public Events_Listener
39 {
40  public:
41   INITIALIZATIONPLUGIN_EXPORT InitializationPlugin_EvalListener();
42   INITIALIZATIONPLUGIN_EXPORT virtual ~InitializationPlugin_EvalListener();
43
44   /// Reimplemented from Events_Listener::processEvent().
45   INITIALIZATIONPLUGIN_EXPORT
46     virtual void processEvent(const std::shared_ptr<Events_Message>& theMessage);
47
48   // performs the python call to initialize high level data model on internal data model creation
49   void initDataModel();
50
51  protected:
52   /// Evaluates theExpression and returns its value.
53   double evaluate(std::shared_ptr<ModelAPI_Feature> theParameter,
54                   const std::wstring& theExpression, std::string& theError,
55                   std::list<std::shared_ptr<ModelAPI_ResultParameter> >& theParamsList,
56                   const bool theIsParameter = false);
57
58   /// Evaluates theExpression with variable local and returns its value.
59   double evaluate(std::wstring& theVariable,
60                   double theValueVariable,
61                   std::shared_ptr<ModelAPI_Feature> theParameter,
62                   const std::wstring& theExpression,
63                   std::string& theError,
64                   std::list<std::shared_ptr<ModelAPI_ResultParameter> >& theParamsList,
65                   bool theIsFirstTime);
66
67
68   /// Processes Evaluation event.
69   void processEvaluationEvent(const std::shared_ptr<Events_Message>& theMessage);
70
71  private:
72   std::shared_ptr<InitializationPlugin_PyInterp> myInterp;
73 };
74
75 #endif /* SRC_INITIALIZATIONPLUGIN_INITIALIZATIONPLUGIN_EVALLISTENER_H_ */