Salome HOME
Issue #588: Renaming a parameter used in an expression
[modules/shaper.git] / src / ModelAPI / ModelAPI_Events.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 /*
4  * ModelAPI_Events.cpp
5  *
6  *  Created on: Dec 8, 2014
7  *      Author: sbh
8  */
9
10 #include <ModelAPI.h>
11 #include <ModelAPI_Events.h>
12
13 ModelAPI_ObjectUpdatedMessage::ModelAPI_ObjectUpdatedMessage(const Events_ID theID,
14                                                              const void* theSender)
15     : Events_MessageGroup(theID, theSender)
16 {
17
18 }
19
20 ModelAPI_ObjectUpdatedMessage::~ModelAPI_ObjectUpdatedMessage()
21 {
22
23 }
24
25 ModelAPI_ObjectDeletedMessage::ModelAPI_ObjectDeletedMessage(const Events_ID theID,
26                                                              const void* theSender)
27     : Events_MessageGroup(theID, theSender)
28 {
29
30 }
31
32 ModelAPI_ObjectDeletedMessage::~ModelAPI_ObjectDeletedMessage()
33 {
34
35 }
36
37 ModelAPI_FeatureStateMessage::ModelAPI_FeatureStateMessage(const Events_ID theID,
38                                                            const void* theSender)
39  : Events_Message(theID, theSender)
40 {
41   myCurrentFeature = std::shared_ptr<ModelAPI_Feature>();
42 }
43
44 ModelAPI_FeatureStateMessage::~ModelAPI_FeatureStateMessage()
45 {
46
47 }
48
49 std::shared_ptr<ModelAPI_Feature> ModelAPI_FeatureStateMessage::feature() const
50 {
51   return myCurrentFeature;
52 }
53
54 void ModelAPI_FeatureStateMessage::setFeature(std::shared_ptr<ModelAPI_Feature>& theFeature)
55 {
56   myCurrentFeature = theFeature;
57 }
58
59 bool ModelAPI_FeatureStateMessage::hasState(const std::string& theKey) const
60 {
61   return myFeatureState.find(theKey) != myFeatureState.end();
62 }
63
64 bool ModelAPI_FeatureStateMessage::state(const  std::string& theFeatureId, bool theDefault) const
65 {
66   if(hasState(theFeatureId)) {
67     return myFeatureState.at(theFeatureId);
68   }
69   return theDefault;
70 }
71
72 void ModelAPI_FeatureStateMessage::setState(const std::string& theFeatureId, bool theValue)
73 {
74   myFeatureState[theFeatureId] = theValue;
75 }
76
77 std::list<std::string> ModelAPI_FeatureStateMessage::features() const
78 {
79   std::list<std::string> result;
80   std::map<std::string, bool>::const_iterator it = myFeatureState.begin();
81   for( ; it != myFeatureState.end(); ++it) {
82     result.push_back(it->first);
83   }
84   return result;
85 }
86
87
88 ModelAPI_DocumentCreatedMessage::ModelAPI_DocumentCreatedMessage(const Events_ID theID,
89                                                                  const void* theSender)
90 : Events_Message(theID, theSender)
91 {
92
93 }
94
95 ModelAPI_DocumentCreatedMessage::~ModelAPI_DocumentCreatedMessage()
96 {
97
98 }
99
100 DocumentPtr ModelAPI_DocumentCreatedMessage::document() const
101 {
102   return myDocument;
103 }
104
105 void ModelAPI_DocumentCreatedMessage::setDocument(DocumentPtr theDocument)
106 {
107   myDocument = theDocument;
108 }
109
110 ModelAPI_AttributeEvalMessage::ModelAPI_AttributeEvalMessage(const Events_ID theID,
111                                                                          const void* theSender)
112 : Events_Message(theID, theSender)
113 {
114
115 }
116
117 ModelAPI_AttributeEvalMessage::~ModelAPI_AttributeEvalMessage()
118 {
119
120 }
121
122 AttributePtr ModelAPI_AttributeEvalMessage::attribute() const
123 {
124   return myAttribute;
125 }
126
127 void ModelAPI_AttributeEvalMessage::setAttribute(AttributePtr theDocument)
128 {
129   myAttribute = theDocument;
130 }
131
132 ModelAPI_ObjectRenamedMessage::ModelAPI_ObjectRenamedMessage(const Events_ID theID,
133                                                              const void* theSender)
134 : Events_Message(theID, theSender)
135 {
136
137 }
138
139 ModelAPI_ObjectRenamedMessage::~ModelAPI_ObjectRenamedMessage()
140 {
141
142 }
143
144 void ModelAPI_ObjectRenamedMessage::send(ObjectPtr theObject,
145                                          const std::string& theOldName,
146                                          const std::string& theNewName,
147                                          const void* theSender)
148 {
149   std::shared_ptr<ModelAPI_ObjectRenamedMessage> aMessage(
150     new ModelAPI_ObjectRenamedMessage(eventId(), theSender));
151   aMessage->setObject(theObject);
152   aMessage->setOldName(theOldName);
153   aMessage->setNewName(theNewName);
154   Events_Loop::loop()->send(aMessage);
155 }
156
157 ObjectPtr ModelAPI_ObjectRenamedMessage::object() const
158 {
159   return myObject;
160 }
161
162 void ModelAPI_ObjectRenamedMessage::setObject(ObjectPtr theObject)
163 {
164   myObject = theObject;
165 }
166
167 std::string ModelAPI_ObjectRenamedMessage::oldName() const
168 {
169   return myOldName;
170 }
171
172 void ModelAPI_ObjectRenamedMessage::setOldName(const std::string& theOldName)
173 {
174   myOldName = theOldName;
175 }
176
177 std::string ModelAPI_ObjectRenamedMessage::newName() const
178 {
179   return myNewName;
180 }
181
182 void ModelAPI_ObjectRenamedMessage::setNewName(const std::string& theNewName)
183 {
184   myNewName = theNewName;
185 }