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 * ParametersPlugin_EvalListener.h
23 * Created on: Apr 28, 2015
27 #ifndef SRC_PARAMETERSPLUGIN_EVALLISTENER_H_
28 #define SRC_PARAMETERSPLUGIN_EVALLISTENER_H_
30 #include <ParametersPlugin.h>
31 #include <Events_Loop.h>
33 class ModelAPI_Attribute;
34 class ModelAPI_Document;
35 class ModelAPI_Feature;
36 class ModelAPI_ResultParameter;
37 class ParametersPlugin_Parameter;
40 * \class ParametersPlugin_EvalListener
42 * \brief Class which process the events from the event loop.
44 class ParametersPlugin_EvalListener : public Events_Listener
46 /// map of old names, that were valid for perameres, but now parameter name is changed to invalid
47 /// stored not shared pointers to features to avoid memory keeping on the feature delete
48 std::map<ParametersPlugin_Parameter*, std::string> myOldNames;
50 PARAMETERSPLUGIN_EXPORT ParametersPlugin_EvalListener();
51 PARAMETERSPLUGIN_EXPORT virtual ~ParametersPlugin_EvalListener();
53 /// Reimplemented from Events_Listener::processEvent().
54 PARAMETERSPLUGIN_EXPORT
55 virtual void processEvent(const std::shared_ptr<Events_Message>& theMessage);
58 /// Processes ObjectRenamed event.
59 void processObjectRenamedEvent(const std::shared_ptr<Events_Message>& theMessage);
60 /// Processes ReplaceParameter event.
61 void processReplaceParameterEvent(const std::shared_ptr<Events_Message>& theMessage);
63 /// Renames theOldName in theExpression by theNewName.
64 std::string renameInPythonExpression(const std::string& theExpression,
65 const std::string& theOldName,
66 const std::string& theNewName);
67 /// Renames theOldName in the expression attribute of theParameter by theNewName.
68 void renameInParameter(std::shared_ptr<ParametersPlugin_Parameter> theParameter,
69 const std::string& theOldName,
70 const std::string& theNewName);
71 /// Renames theOldName in the text fields of theAttribute by theNewName.
72 void renameInAttribute(std::shared_ptr<ModelAPI_Attribute> theAttribute,
73 const std::string& theOldName,
74 const std::string& theNewName);
75 /// Renames theOldName in all dependents of theResultParameter by theNewName.
76 void renameInDependents(std::shared_ptr<ModelAPI_ResultParameter> theResultParameter,
77 const std::string& theOldName,
78 const std::string& theNewName);
81 #endif /* SRC_PARAMETERSPLUGIN_PARAMETERSPLUGIN_EVALLISTENER_H_ */