1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
6 * Created on: Dec 8, 2014
11 #include <ModelAPI_Events.h>
13 ModelAPI_ObjectUpdatedMessage::ModelAPI_ObjectUpdatedMessage(const Events_ID theID,
14 const void* theSender)
15 : Events_MessageGroup(theID, theSender)
20 ModelAPI_ObjectUpdatedMessage::~ModelAPI_ObjectUpdatedMessage()
25 ModelAPI_ObjectDeletedMessage::ModelAPI_ObjectDeletedMessage(const Events_ID theID,
26 const void* theSender)
27 : Events_MessageGroup(theID, theSender)
32 ModelAPI_ObjectDeletedMessage::~ModelAPI_ObjectDeletedMessage()
37 ModelAPI_OrderUpdatedMessage::ModelAPI_OrderUpdatedMessage(const Events_ID theID,
38 const void* theSender)
39 : Events_Message(theID, theSender)
44 ModelAPI_OrderUpdatedMessage::~ModelAPI_OrderUpdatedMessage()
49 ModelAPI_FeatureStateMessage::ModelAPI_FeatureStateMessage(const Events_ID theID,
50 const void* theSender)
51 : Events_Message(theID, theSender)
53 myCurrentFeature = std::shared_ptr<ModelAPI_Feature>();
56 ModelAPI_FeatureStateMessage::~ModelAPI_FeatureStateMessage()
61 std::shared_ptr<ModelAPI_Feature> ModelAPI_FeatureStateMessage::feature() const
63 return myCurrentFeature;
66 void ModelAPI_FeatureStateMessage::setFeature(std::shared_ptr<ModelAPI_Feature>& theFeature)
68 myCurrentFeature = theFeature;
71 bool ModelAPI_FeatureStateMessage::hasState(const std::string& theKey) const
73 return myFeatureState.find(theKey) != myFeatureState.end();
76 bool ModelAPI_FeatureStateMessage::state(const std::string& theFeatureId, bool theDefault) const
78 if(hasState(theFeatureId)) {
79 return myFeatureState.at(theFeatureId);
84 void ModelAPI_FeatureStateMessage::setState(const std::string& theFeatureId, bool theValue)
86 myFeatureState[theFeatureId] = theValue;
89 std::list<std::string> ModelAPI_FeatureStateMessage::features() const
91 std::list<std::string> result;
92 std::map<std::string, bool>::const_iterator it = myFeatureState.begin();
93 for( ; it != myFeatureState.end(); ++it) {
94 result.push_back(it->first);
100 ModelAPI_DocumentCreatedMessage::ModelAPI_DocumentCreatedMessage(const Events_ID theID,
101 const void* theSender)
102 : Events_Message(theID, theSender)
107 ModelAPI_DocumentCreatedMessage::~ModelAPI_DocumentCreatedMessage()
112 DocumentPtr ModelAPI_DocumentCreatedMessage::document() const
117 void ModelAPI_DocumentCreatedMessage::setDocument(DocumentPtr theDocument)
119 myDocument = theDocument;
122 ModelAPI_AttributeEvalMessage::ModelAPI_AttributeEvalMessage(const Events_ID theID,
123 const void* theSender)
124 : Events_Message(theID, theSender)
129 ModelAPI_AttributeEvalMessage::~ModelAPI_AttributeEvalMessage()
134 AttributePtr ModelAPI_AttributeEvalMessage::attribute() const
139 void ModelAPI_AttributeEvalMessage::setAttribute(AttributePtr theDocument)
141 myAttribute = theDocument;
144 ModelAPI_ObjectRenamedMessage::ModelAPI_ObjectRenamedMessage(const Events_ID theID,
145 const void* theSender)
146 : Events_Message(theID, theSender)
151 ModelAPI_ObjectRenamedMessage::~ModelAPI_ObjectRenamedMessage()
156 void ModelAPI_ObjectRenamedMessage::send(ObjectPtr theObject,
157 const std::string& theOldName,
158 const std::string& theNewName,
159 const void* theSender)
161 std::shared_ptr<ModelAPI_ObjectRenamedMessage> aMessage(
162 new ModelAPI_ObjectRenamedMessage(eventId(), theSender));
163 aMessage->setObject(theObject);
164 aMessage->setOldName(theOldName);
165 aMessage->setNewName(theNewName);
166 Events_Loop::loop()->send(aMessage);
169 ObjectPtr ModelAPI_ObjectRenamedMessage::object() const
174 void ModelAPI_ObjectRenamedMessage::setObject(ObjectPtr theObject)
176 myObject = theObject;
179 std::string ModelAPI_ObjectRenamedMessage::oldName() const
184 void ModelAPI_ObjectRenamedMessage::setOldName(const std::string& theOldName)
186 myOldName = theOldName;
189 std::string ModelAPI_ObjectRenamedMessage::newName() const
194 void ModelAPI_ObjectRenamedMessage::setNewName(const std::string& theNewName)
196 myNewName = theNewName;
199 ModelAPI_ReplaceParameterMessage::ModelAPI_ReplaceParameterMessage(const Events_ID theID,
200 const void* theSender)
201 : Events_Message(theID, theSender)
206 ModelAPI_ReplaceParameterMessage::~ModelAPI_ReplaceParameterMessage()
211 void ModelAPI_ReplaceParameterMessage::send(ObjectPtr theObject,
212 const void* theSender)
214 std::shared_ptr<ModelAPI_ReplaceParameterMessage> aMessage(
215 new ModelAPI_ReplaceParameterMessage(eventId(), theSender));
216 aMessage->setObject(theObject);
217 Events_Loop::loop()->send(aMessage);
220 ObjectPtr ModelAPI_ReplaceParameterMessage::object() const
225 void ModelAPI_ReplaceParameterMessage::setObject(ObjectPtr theObject)
227 myObject = theObject;