1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: Model_Events.h
4 // Created: 10 Apr 2014
5 // Author: Mikhail PONIKAROV
7 #ifndef Model_Events_H_
8 #define Model_Events_H_
11 #include <ModelAPI_Events.h>
15 /// Allovs to create ModelAPI messages
16 class Model_EventCreator : public ModelAPI_EventCreator
19 /// creates created, updated or moved messages and sends to the loop
20 virtual void sendUpdated(const ObjectPtr& theObject, const Events_ID& theEvent,
21 const bool isGroupped = true) const;
22 /// creates deleted message and sends to the loop
23 virtual void sendDeleted(const std::shared_ptr<ModelAPI_Document>& theDoc,
24 const std::string& theGroup) const;
26 /// must be one per application, the constructor for internal usage only
30 /// Message that feature was changed (used for Object Browser update): moved, updated and deleted
31 class Model_ObjectUpdatedMessage : public ModelAPI_ObjectUpdatedMessage
33 std::set<ObjectPtr> myObjects; ///< which feature is changed
35 /// Sender is not important, all information is located in the feature.
36 /// Use ModelAPI for creation of this event. Used for creation, movement and edition events.
37 Model_ObjectUpdatedMessage(const ObjectPtr& theObject, const Events_ID& theEvent);
39 friend class Model_EventCreator;
42 /// Returns the feature that has been updated
43 virtual const std::set<ObjectPtr>& objects() const;
45 //! Creates a new empty group (to store it in the loop before flush)
46 virtual std::shared_ptr<Events_MessageGroup> newEmpty();
48 //! Allows to join the given message with the current one
49 virtual void Join(const std::shared_ptr<Events_MessageGroup>& theJoined);
52 /// Message that feature was deleted (used for Object Browser update)
53 class Model_ObjectDeletedMessage : public ModelAPI_ObjectDeletedMessage
55 std::shared_ptr<ModelAPI_Document> myDoc; ///< document owner of the feature
56 std::set<std::string> myGroups; ///< group identifiers that contained the deleted feature
58 /// Use ModelAPI for creation of this event.
59 Model_ObjectDeletedMessage(const std::shared_ptr<ModelAPI_Document>& theDoc,
60 const std::string& theGroup);
62 friend class Model_EventCreator;
64 /// Returns the feature that has been updated
65 virtual std::shared_ptr<ModelAPI_Document> document() const
70 /// Returns the group where the feature was deleted
71 virtual const std::set<std::string>& groups() const
76 /// Returns the new empty message of this type
77 virtual std::shared_ptr<Events_MessageGroup> newEmpty();
79 /// Returns the identifier of this message
80 virtual const Events_ID messageId();
82 /// Appends to this message the given one
83 virtual void Join(const std::shared_ptr<Events_MessageGroup>& theJoined);