Salome HOME
Updated events for Model and minor other changes
[modules/shaper.git] / src / Model / Model_Events.h
1 // File:        Model_Events.h
2 // Created:     10 Apr 2014
3 // Author:      Mikhail PONIKAROV
4
5 #ifndef Model_Events_HeaderFile
6 #define Model_Events_HeaderFile
7
8 #include <Model.h>
9 #include <Event_Message.h>
10 #include <memory>
11 #include <string>
12
13 class ModelAPI_Feature;
14 class ModelAPI_Document;
15
16 /// Event ID that feature is created (comes with ModelAPI_FeatureUpdatedMessage)
17 static const char * EVENT_FEATURE_CREATED = "FeatureCreated";
18 /// Event ID that data of feature is updated (comes with ModelAPI_FeatureUpdatedMessage)
19 static const char * EVENT_FEATURE_UPDATED = "FeatureUpdated";
20 /// Event ID that data of feature is deleted (comes with ModelAPI_FeatureDeletedMessage)
21 static const char * EVENT_FEATURE_DELETED = "FeatureDeleted";
22
23 /// Message that feature was changed (used for Object Browser update)
24 class ModelAPI_FeatureUpdatedMessage : public Event_Message {
25   std::shared_ptr<ModelAPI_Feature> myFeature; ///< which feature is changed
26 public:
27   /// sender is not important, all information is located in the feature
28   ModelAPI_FeatureUpdatedMessage(const std::shared_ptr<ModelAPI_Feature>& theFeature,
29     const Event_ID& theEvent);
30
31   /// Returns the feature that has been updated
32   std::shared_ptr<ModelAPI_Feature> feature() {return myFeature;}
33 };
34
35 /// Message that feature was deleted (used for Object Browser update)
36 class ModelAPI_FeatureDeletedMessage : public Event_Message {
37   std::shared_ptr<ModelAPI_Document> myDoc; ///< document owner of the feature
38   std::string myGroup; ///< group identifier that contained the deleted feature
39 public:
40   /// creates a message by initialization of fields
41   ModelAPI_FeatureDeletedMessage(const std::shared_ptr<ModelAPI_Document>& theDoc,
42     const std::string& theGroup);
43
44   /// Returns the ID of this message (EVENT_FEATURE_DELETED)
45   static const Event_ID messageId();
46
47   /// Returns the feature that has been updated
48   std::shared_ptr<ModelAPI_Document> document() {return myDoc;}
49
50   /// Returns the group where the feature was deleted
51   const std::string& group() {return myGroup;}
52 };
53
54 #endif