1 // File: Model_Events.h
2 // Created: 10 Apr 2014
3 // Author: Mikhail PONIKAROV
5 #ifndef Model_Events_HeaderFile
6 #define Model_Events_HeaderFile
9 #include <ModelAPI_Events.h>
11 /// Allovs to create ModelAPI messages
12 class Model_EventCreator : public ModelAPI_EventCreator {
14 /// creates created, updated or moved messages and sends to the loop
15 virtual void sendUpdated(
16 const FeaturePtr& theFeature, const Events_ID& theEvent, const bool isGroupped = true) const;
17 /// creates deleted message and sends to the loop
18 virtual void sendDeleted(
19 const boost::shared_ptr<ModelAPI_Document>& theDoc, const std::string& theGroup) const;
21 /// must be one per application, the constructor for internal usage only
25 /// Message that feature was changed (used for Object Browser update): moved, updated and deleted
26 class Model_FeatureUpdatedMessage : public ModelAPI_FeatureUpdatedMessage {
27 std::set<FeaturePtr> myFeatures; ///< which feature is changed
29 /// Sender is not important, all information is located in the feature.
30 /// Use ModelAPI for creation of this event. Used for creation, movement and edition events.
31 Model_FeatureUpdatedMessage(
32 const FeaturePtr& theFeature,
33 const Events_ID& theEvent);
35 friend class Model_EventCreator;
38 /// Returns the feature that has been updated
39 virtual std::set<FeaturePtr> features() 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_FeatureDeletedMessage : public ModelAPI_FeatureDeletedMessage {
50 boost::shared_ptr<ModelAPI_Document> myDoc; ///< document owner of the feature
51 std::set<std::string> myGroups; ///< group identifiers that contained the deleted feature
53 /// Use ModelAPI for creation of this event.
54 Model_FeatureDeletedMessage(
55 const boost::shared_ptr<ModelAPI_Document>& theDoc, const std::string& theGroup);
57 friend class Model_EventCreator;
59 /// Returns the feature that has been updated
60 virtual boost::shared_ptr<ModelAPI_Document> document() const {return myDoc;}
62 /// Returns the group where the feature was deleted
63 virtual const std::set<std::string >& groups() const {return myGroups;}
65 virtual Events_MessageGroup* newEmpty();
68 virtual const Events_ID messageId();
70 virtual void Join(Events_MessageGroup& theJoined);