Salome HOME
Update copyrights
[modules/shaper.git] / src / InitializationPlugin / InitializationPlugin_EvalListener.h
1 // Copyright (C) 2014-2019  CEA/DEN, EDF R&D
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  protected:
49   /// Evaluates theExpression and returns its value.
50    double evaluate(std::shared_ptr<ModelAPI_Feature> theParameter,
51                   const std::string& theExpression, std::string& theError,
52                   std::list<std::shared_ptr<ModelAPI_ResultParameter> >& theParamsList,
53                   const bool theIsParameter = false);
54
55   /// Processes Evaluation event.
56   void processEvaluationEvent(const std::shared_ptr<Events_Message>& theMessage);
57
58  private:
59   std::shared_ptr<InitializationPlugin_PyInterp> myInterp;
60 };
61
62 #endif /* SRC_INITIALIZATIONPLUGIN_INITIALIZATIONPLUGIN_EVALLISTENER_H_ */