2 * ParametersPlugin_EvalListener.h
4 * Created on: Apr 28, 2015
8 #ifndef SRC_PARAMETERSPLUGIN_EVALLISTENER_H_
9 #define SRC_PARAMETERSPLUGIN_EVALLISTENER_H_
11 #include <ParametersPlugin.h>
12 #include <Events_Loop.h>
14 class ModelAPI_Attribute;
15 class ModelAPI_Document;
16 class ModelAPI_ResultParameter;
17 class ParametersPlugin_Parameter;
18 class ParametersPlugin_PyInterp;
21 * \class ParametersPlugin_EvalListener
23 * \brief Class which process the events from the event loop.
25 class ParametersPlugin_EvalListener : public Events_Listener
28 PARAMETERSPLUGIN_EXPORT ParametersPlugin_EvalListener();
29 PARAMETERSPLUGIN_EXPORT virtual ~ParametersPlugin_EvalListener();
31 /// Reimplemented from Events_Listener::processEvent().
32 PARAMETERSPLUGIN_EXPORT virtual void processEvent(const std::shared_ptr<Events_Message>& theMessage);
35 /// Evaluates theExpression and returns its value.
36 double evaluate(const std::string& theExpression, std::string& theError,
37 const std::shared_ptr<ModelAPI_Document>& theDocument);
39 /// Processes Evaluation event.
40 void processEvaluationEvent(const std::shared_ptr<Events_Message>& theMessage);
41 /// Processes ObjectRenamed event.
42 void processObjectRenamedEvent(const std::shared_ptr<Events_Message>& theMessage);
43 /// Processes ReplaceParameter event.
44 void processReplaceParameterEvent(const std::shared_ptr<Events_Message>& theMessage);
46 /// Renames theOldName in theExpression by theNewName.
47 std::string renameInPythonExpression(const std::string& theExpression,
48 const std::string& theOldName,
49 const std::string& theNewName);
50 /// Renames theOldName in the expression attribute of theParameter by theNewName.
51 void renameInParameter(std::shared_ptr<ParametersPlugin_Parameter> theParameter,
52 const std::string& theOldName,
53 const std::string& theNewName);
54 /// Renames theOldName in the text fields of theAttribute by theNewName.
55 void renameInAttribute(std::shared_ptr<ModelAPI_Attribute> theAttribute,
56 const std::string& theOldName,
57 const std::string& theNewName);
58 /// Renames theOldName in all dependents of theResultParameter by theNewName.
59 void renameInDependents(std::shared_ptr<ModelAPI_ResultParameter> theResultParameter,
60 const std::string& theOldName,
61 const std::string& theNewName);
64 std::shared_ptr<ParametersPlugin_PyInterp> myInterp;
67 #endif /* SRC_PARAMETERSPLUGIN_PARAMETERSPLUGIN_EVALLISTENER_H_ */