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(
101 const Events_ID theID, const void* theSender)
102 : Events_Message(theID, theSender)
105 ModelAPI_DocumentCreatedMessage::~ModelAPI_DocumentCreatedMessage()
108 DocumentPtr ModelAPI_DocumentCreatedMessage::document() const
113 void ModelAPI_DocumentCreatedMessage::setDocument(DocumentPtr theDocument)
115 myDocument = theDocument;
118 ModelAPI_AttributeEvalMessage::ModelAPI_AttributeEvalMessage(
119 const Events_ID theID, const void* theSender)
120 : Events_Message(theID, theSender)
123 ModelAPI_AttributeEvalMessage::~ModelAPI_AttributeEvalMessage()
126 AttributePtr ModelAPI_AttributeEvalMessage::attribute() const
131 void ModelAPI_AttributeEvalMessage::setAttribute(AttributePtr theAttribute)
133 myAttribute = theAttribute;
136 ModelAPI_ParameterEvalMessage::ModelAPI_ParameterEvalMessage(
137 const Events_ID theID, const void* theSender)
138 : Events_Message(theID, theSender), myIsProcessed(false)
141 ModelAPI_ParameterEvalMessage::~ModelAPI_ParameterEvalMessage()
144 FeaturePtr ModelAPI_ParameterEvalMessage::parameter() const
149 void ModelAPI_ParameterEvalMessage::setParameter(FeaturePtr theParam)
154 void ModelAPI_ParameterEvalMessage::setResults(
155 const std::list<std::shared_ptr<ModelAPI_ResultParameter> >& theParamsList,
156 const double theResult, const std::string& theError)
158 myParamsList = theParamsList;
159 myResult = theResult;
161 myIsProcessed = true;
164 bool ModelAPI_ParameterEvalMessage::isProcessed()
166 return myIsProcessed;
169 const std::list<std::shared_ptr<ModelAPI_ResultParameter> >&
170 ModelAPI_ParameterEvalMessage::params() const
175 const double& ModelAPI_ParameterEvalMessage::result() const
180 const std::string& ModelAPI_ParameterEvalMessage::error() const
185 ModelAPI_ComputePositionsMessage::ModelAPI_ComputePositionsMessage(
186 const Events_ID theID, const void* theSender)
187 : Events_Message(theID, theSender)
190 ModelAPI_ComputePositionsMessage::~ModelAPI_ComputePositionsMessage()
193 const std::string& ModelAPI_ComputePositionsMessage::expression() const
198 const std::string& ModelAPI_ComputePositionsMessage::parameter() const
203 void ModelAPI_ComputePositionsMessage::set(
204 const std::string& theExpression, const std::string& theParameter)
206 myExpression = theExpression;
207 myParamName = theParameter;
210 void ModelAPI_ComputePositionsMessage::setPositions(
211 const std::list<std::pair<int, int> >& thePositions)
213 myPositions = thePositions;
216 const std::list<std::pair<int, int> >& ModelAPI_ComputePositionsMessage::positions() const
222 ModelAPI_ObjectRenamedMessage::ModelAPI_ObjectRenamedMessage(const Events_ID theID,
223 const void* theSender)
224 : Events_Message(theID, theSender)
229 ModelAPI_ObjectRenamedMessage::~ModelAPI_ObjectRenamedMessage()
234 void ModelAPI_ObjectRenamedMessage::send(ObjectPtr theObject,
235 const std::string& theOldName,
236 const std::string& theNewName,
237 const void* theSender)
239 std::shared_ptr<ModelAPI_ObjectRenamedMessage> aMessage(
240 new ModelAPI_ObjectRenamedMessage(eventId(), theSender));
241 aMessage->setObject(theObject);
242 aMessage->setOldName(theOldName);
243 aMessage->setNewName(theNewName);
244 Events_Loop::loop()->send(aMessage);
247 ObjectPtr ModelAPI_ObjectRenamedMessage::object() const
252 void ModelAPI_ObjectRenamedMessage::setObject(ObjectPtr theObject)
254 myObject = theObject;
257 std::string ModelAPI_ObjectRenamedMessage::oldName() const
262 void ModelAPI_ObjectRenamedMessage::setOldName(const std::string& theOldName)
264 myOldName = theOldName;
267 std::string ModelAPI_ObjectRenamedMessage::newName() const
272 void ModelAPI_ObjectRenamedMessage::setNewName(const std::string& theNewName)
274 myNewName = theNewName;
277 ModelAPI_ReplaceParameterMessage::ModelAPI_ReplaceParameterMessage(const Events_ID theID,
278 const void* theSender)
279 : Events_Message(theID, theSender)
284 ModelAPI_ReplaceParameterMessage::~ModelAPI_ReplaceParameterMessage()
289 void ModelAPI_ReplaceParameterMessage::send(ObjectPtr theObject,
290 const void* theSender)
292 std::shared_ptr<ModelAPI_ReplaceParameterMessage> aMessage(
293 new ModelAPI_ReplaceParameterMessage(eventId(), theSender));
294 aMessage->setObject(theObject);
295 Events_Loop::loop()->send(aMessage);
298 ObjectPtr ModelAPI_ReplaceParameterMessage::object() const
303 void ModelAPI_ReplaceParameterMessage::setObject(ObjectPtr theObject)
305 myObject = theObject;
309 // ===== ModelAPI_SolverFailedMessage =====
310 ModelAPI_SolverFailedMessage::ModelAPI_SolverFailedMessage(const Events_ID theID,
311 const void* theSender)
312 : Events_Message(theID, theSender),
317 ModelAPI_SolverFailedMessage::~ModelAPI_SolverFailedMessage()
321 void ModelAPI_SolverFailedMessage::setObjects(const std::set<ObjectPtr>& theObjects)
323 myObjects = theObjects;
326 const std::set<ObjectPtr>& ModelAPI_SolverFailedMessage::objects() const