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_FeatureStateMessage::ModelAPI_FeatureStateMessage(const Events_ID theID,
38 const void* theSender)
39 : Events_Message(theID, theSender)
41 myCurrentFeature = std::shared_ptr<ModelAPI_Feature>();
44 ModelAPI_FeatureStateMessage::~ModelAPI_FeatureStateMessage()
49 std::shared_ptr<ModelAPI_Feature> ModelAPI_FeatureStateMessage::feature() const
51 return myCurrentFeature;
54 void ModelAPI_FeatureStateMessage::setFeature(std::shared_ptr<ModelAPI_Feature>& theFeature)
56 myCurrentFeature = theFeature;
59 bool ModelAPI_FeatureStateMessage::hasState(const std::string& theKey) const
61 return myFeatureState.find(theKey) != myFeatureState.end();
64 bool ModelAPI_FeatureStateMessage::state(const std::string& theFeatureId, bool theDefault) const
66 if(hasState(theFeatureId)) {
67 return myFeatureState.at(theFeatureId);
72 void ModelAPI_FeatureStateMessage::setState(const std::string& theFeatureId, bool theValue)
74 myFeatureState[theFeatureId] = theValue;
77 std::list<std::string> ModelAPI_FeatureStateMessage::features() const
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);
88 ModelAPI_DocumentCreatedMessage::ModelAPI_DocumentCreatedMessage(const Events_ID theID,
89 const void* theSender)
90 : Events_Message(theID, theSender)
95 ModelAPI_DocumentCreatedMessage::~ModelAPI_DocumentCreatedMessage()
100 DocumentPtr ModelAPI_DocumentCreatedMessage::document() const
105 void ModelAPI_DocumentCreatedMessage::setDocument(DocumentPtr theDocument)
107 myDocument = theDocument;
110 ModelAPI_AttributeEvalMessage::ModelAPI_AttributeEvalMessage(const Events_ID theID,
111 const void* theSender)
112 : Events_Message(theID, theSender)
117 ModelAPI_AttributeEvalMessage::~ModelAPI_AttributeEvalMessage()
122 AttributePtr ModelAPI_AttributeEvalMessage::attribute() const
127 void ModelAPI_AttributeEvalMessage::setAttribute(AttributePtr theDocument)
129 myAttribute = theDocument;
132 ModelAPI_ObjectRenamedMessage::ModelAPI_ObjectRenamedMessage(const Events_ID theID,
133 const void* theSender)
134 : Events_Message(theID, theSender)
139 ModelAPI_ObjectRenamedMessage::~ModelAPI_ObjectRenamedMessage()
144 void ModelAPI_ObjectRenamedMessage::send(ObjectPtr theObject,
145 const std::string& theOldName,
146 const std::string& theNewName,
147 const void* theSender)
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);
157 ObjectPtr ModelAPI_ObjectRenamedMessage::object() const
162 void ModelAPI_ObjectRenamedMessage::setObject(ObjectPtr theObject)
164 myObject = theObject;
167 std::string ModelAPI_ObjectRenamedMessage::oldName() const
172 void ModelAPI_ObjectRenamedMessage::setOldName(const std::string& theOldName)
174 myOldName = theOldName;
177 std::string ModelAPI_ObjectRenamedMessage::newName() const
182 void ModelAPI_ObjectRenamedMessage::setNewName(const std::string& theNewName)
184 myNewName = theNewName;