1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
3 * ParametersPlugin_EvalListener.h
5 * Created on: Apr 28, 2015
9 #ifndef SRC_PARAMETERSPLUGIN_EVALLISTENER_H_
10 #define SRC_PARAMETERSPLUGIN_EVALLISTENER_H_
12 #include <ParametersPlugin.h>
13 #include <Events_Loop.h>
15 class ModelAPI_Attribute;
16 class ModelAPI_Document;
17 class ModelAPI_Feature;
18 class ModelAPI_ResultParameter;
19 class ParametersPlugin_Parameter;
20 class ParametersPlugin_PyInterp;
23 * \class ParametersPlugin_EvalListener
25 * \brief Class which process the events from the event loop.
27 class ParametersPlugin_EvalListener : public Events_Listener
30 PARAMETERSPLUGIN_EXPORT ParametersPlugin_EvalListener();
31 PARAMETERSPLUGIN_EXPORT virtual ~ParametersPlugin_EvalListener();
33 /// Reimplemented from Events_Listener::processEvent().
34 PARAMETERSPLUGIN_EXPORT
35 virtual void processEvent(const std::shared_ptr<Events_Message>& theMessage);
38 /// Evaluates theExpression and returns its value.
39 double evaluate(std::shared_ptr<ModelAPI_Feature> theParameter,
40 const std::string& theExpression, std::string& theError);
42 /// Processes Evaluation event.
43 void processEvaluationEvent(const std::shared_ptr<Events_Message>& theMessage);
44 /// Processes ObjectRenamed event.
45 void processObjectRenamedEvent(const std::shared_ptr<Events_Message>& theMessage);
46 /// Processes ReplaceParameter event.
47 void processReplaceParameterEvent(const std::shared_ptr<Events_Message>& theMessage);
49 /// Renames theOldName in theExpression by theNewName.
50 std::string renameInPythonExpression(const std::string& theExpression,
51 const std::string& theOldName,
52 const std::string& theNewName);
53 /// Renames theOldName in the expression attribute of theParameter by theNewName.
54 void renameInParameter(std::shared_ptr<ParametersPlugin_Parameter> theParameter,
55 const std::string& theOldName,
56 const std::string& theNewName);
57 /// Renames theOldName in the text fields of theAttribute by theNewName.
58 void renameInAttribute(std::shared_ptr<ModelAPI_Attribute> theAttribute,
59 const std::string& theOldName,
60 const std::string& theNewName);
61 /// Renames theOldName in all dependents of theResultParameter by theNewName.
62 void renameInDependents(std::shared_ptr<ModelAPI_ResultParameter> theResultParameter,
63 const std::string& theOldName,
64 const std::string& theNewName);
67 std::shared_ptr<ParametersPlugin_PyInterp> myInterp;
70 #endif /* SRC_PARAMETERSPLUGIN_PARAMETERSPLUGIN_EVALLISTENER_H_ */