Salome HOME
Add copyright header according to request of CEA from 06.06.2017
[modules/shaper.git] / src / ParametersPlugin / ParametersPlugin_EvalListener.h
1 // Copyright (C) 2014-2017  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<mailto:webmaster.salome@opencascade.com>
18 //
19
20 /*
21  * ParametersPlugin_EvalListener.h
22  *
23  *  Created on: Apr 28, 2015
24  *      Author: sbh
25  */
26
27 #ifndef SRC_PARAMETERSPLUGIN_EVALLISTENER_H_
28 #define SRC_PARAMETERSPLUGIN_EVALLISTENER_H_
29
30 #include <ParametersPlugin.h>
31 #include <Events_Loop.h>
32
33 class ModelAPI_Attribute;
34 class ModelAPI_Document;
35 class ModelAPI_Feature;
36 class ModelAPI_ResultParameter;
37 class ParametersPlugin_Parameter;
38
39 /**
40  * \class ParametersPlugin_EvalListener
41  * \ingroup Plugins
42  * \brief Class which process the events from the event loop.
43  */
44 class ParametersPlugin_EvalListener : public Events_Listener
45 {
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;
49  public:
50   PARAMETERSPLUGIN_EXPORT ParametersPlugin_EvalListener();
51   PARAMETERSPLUGIN_EXPORT virtual ~ParametersPlugin_EvalListener();
52
53   /// Reimplemented from Events_Listener::processEvent().
54   PARAMETERSPLUGIN_EXPORT
55     virtual void processEvent(const std::shared_ptr<Events_Message>& theMessage);
56
57  protected:
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);
62
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);
79 };
80
81 #endif /* SRC_PARAMETERSPLUGIN_PARAMETERSPLUGIN_EVALLISTENER_H_ */