Salome HOME
Merge branch 'master' of newgeom:newgeom.git
[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 <Events_Message.h>
10 #include <boost/shared_ptr.hpp>
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 Events_Message {
25   boost::shared_ptr<ModelAPI_Document> myDoc; ///< document owner of the feature
26   boost::shared_ptr<ModelAPI_Feature> myFeature; ///< which feature is changed
27 public:
28   /// sender is not important, all information is located in the feature
29   ModelAPI_FeatureUpdatedMessage(
30     const boost::shared_ptr<ModelAPI_Document>& theDoc,
31     const boost::shared_ptr<ModelAPI_Feature>& theFeature,
32     const Events_ID& theEvent);
33
34   /// Returns the feature that has been updated
35   boost::shared_ptr<ModelAPI_Feature> feature() const {return myFeature;}
36   /// Returns the document that has been updated
37   boost::shared_ptr<ModelAPI_Document> document() const {return myDoc;}
38 };
39
40 /// Message that feature was deleted (used for Object Browser update)
41 class ModelAPI_FeatureDeletedMessage : public Events_Message {
42   boost::shared_ptr<ModelAPI_Document> myDoc; ///< document owner of the feature
43   std::string myGroup; ///< group identifier that contained the deleted feature
44 public:
45   /// creates a message by initialization of fields
46   ModelAPI_FeatureDeletedMessage(const boost::shared_ptr<ModelAPI_Document>& theDoc,
47     const std::string& theGroup);
48
49   /// Returns the ID of this message (EVENT_FEATURE_DELETED)
50   static const Events_ID messageId();
51
52   /// Returns the feature that has been updated
53   boost::shared_ptr<ModelAPI_Document> document() const {return myDoc;}
54
55   /// Returns the group where the feature was deleted
56   const std::string& group() const {return myGroup;}
57 };
58
59 #endif