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>
11 /// Allovs to create ModelAPI messages
12 class Model_EventCreator : public ModelAPI_EventCreator
15 /// creates created, updated or moved messages and sends to the loop
16 virtual void sendUpdated(const ObjectPtr& theObject, const Events_ID& theEvent,
17 const bool isGroupped = true) const;
18 /// creates deleted message and sends to the loop
19 virtual void sendDeleted(const boost::shared_ptr<ModelAPI_Document>& theDoc,
20 const std::string& theGroup) const;
22 /// must be one per application, the constructor for internal usage only
26 /// Message that feature was changed (used for Object Browser update): moved, updated and deleted
27 class Model_ObjectUpdatedMessage : public ModelAPI_ObjectUpdatedMessage
29 std::set<ObjectPtr> myObjects; ///< which feature is changed
31 /// Sender is not important, all information is located in the feature.
32 /// Use ModelAPI for creation of this event. Used for creation, movement and edition events.
33 Model_ObjectUpdatedMessage(const ObjectPtr& theObject, const Events_ID& theEvent);
35 friend class Model_EventCreator;
38 /// Returns the feature that has been updated
39 virtual std::set<ObjectPtr> objects() const;
41 //! Creates a new empty group (to store it in the loop before flush)
42 virtual Events_MessageGroup* newEmpty();
44 //! Allows to join the given message with the current one
45 virtual void Join(Events_MessageGroup& theJoined);
48 /// Message that feature was deleted (used for Object Browser update)
49 class Model_ObjectDeletedMessage : public ModelAPI_ObjectDeletedMessage
51 boost::shared_ptr<ModelAPI_Document> myDoc; ///< document owner of the feature
52 std::set<std::string> myGroups; ///< group identifiers that contained the deleted feature
54 /// Use ModelAPI for creation of this event.
55 Model_ObjectDeletedMessage(const boost::shared_ptr<ModelAPI_Document>& theDoc,
56 const std::string& theGroup);
58 friend class Model_EventCreator;
60 /// Returns the feature that has been updated
61 virtual boost::shared_ptr<ModelAPI_Document> document() const
66 /// Returns the group where the feature was deleted
67 virtual const std::set<std::string>& groups() const
72 virtual Events_MessageGroup* newEmpty();
74 virtual const Events_ID messageId();
76 virtual void Join(Events_MessageGroup& theJoined);