1 // File: Model_Events.h
2 // Created: 10 Apr 2014
3 // Author: Mikhail PONIKAROV
5 #ifndef Model_Events_H_
6 #define Model_Events_H_
9 #include <ModelAPI_Events.h>
13 /// Allovs to create ModelAPI messages
14 class Model_EventCreator : public ModelAPI_EventCreator
17 /// creates created, updated or moved messages and sends to the loop
18 virtual void sendUpdated(const ObjectPtr& theObject, const Events_ID& theEvent,
19 const bool isGroupped = true) const;
20 /// creates deleted message and sends to the loop
21 virtual void sendDeleted(const std::shared_ptr<ModelAPI_Document>& theDoc,
22 const std::string& theGroup) const;
24 /// must be one per application, the constructor for internal usage only
28 /// Message that feature was changed (used for Object Browser update): moved, updated and deleted
29 class Model_ObjectUpdatedMessage : public ModelAPI_ObjectUpdatedMessage
31 std::set<ObjectPtr> myObjects; ///< which feature is changed
33 /// Sender is not important, all information is located in the feature.
34 /// Use ModelAPI for creation of this event. Used for creation, movement and edition events.
35 Model_ObjectUpdatedMessage(const ObjectPtr& theObject, const Events_ID& theEvent);
37 friend class Model_EventCreator;
40 /// Returns the feature that has been updated
41 virtual const std::set<ObjectPtr>& objects() const;
43 //! Creates a new empty group (to store it in the loop before flush)
44 virtual std::shared_ptr<Events_MessageGroup> newEmpty();
46 //! Allows to join the given message with the current one
47 virtual void Join(const std::shared_ptr<Events_MessageGroup>& theJoined);
50 /// Message that feature was deleted (used for Object Browser update)
51 class Model_ObjectDeletedMessage : public ModelAPI_ObjectDeletedMessage
53 std::shared_ptr<ModelAPI_Document> myDoc; ///< document owner of the feature
54 std::set<std::string> myGroups; ///< group identifiers that contained the deleted feature
56 /// Use ModelAPI for creation of this event.
57 Model_ObjectDeletedMessage(const std::shared_ptr<ModelAPI_Document>& theDoc,
58 const std::string& theGroup);
60 friend class Model_EventCreator;
62 /// Returns the feature that has been updated
63 virtual std::shared_ptr<ModelAPI_Document> document() const
68 /// Returns the group where the feature was deleted
69 virtual const std::set<std::string>& groups() const
74 virtual std::shared_ptr<Events_MessageGroup> newEmpty();
76 virtual const Events_ID messageId();
78 virtual void Join(const std::shared_ptr<Events_MessageGroup>& theJoined);