Salome HOME
Define guards are corrected according to the code style
[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_H_
6 #define Model_Events_H_
7
8 #include <Model.h>
9 #include <ModelAPI_Events.h>
10
11 /// Allovs to create ModelAPI messages
12 class Model_EventCreator : public ModelAPI_EventCreator {
13 public:
14   /// creates created, updated or moved messages and sends to the loop
15   virtual void sendUpdated(
16     const ObjectPtr& theObject, 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;
20
21   /// must be one per application, the constructor for internal usage only
22   Model_EventCreator();
23 };
24
25 /// Message that feature was changed (used for Object Browser update): moved, updated and deleted
26 class Model_ObjectUpdatedMessage : public ModelAPI_ObjectUpdatedMessage {
27   std::set<ObjectPtr> myObjects; ///< which feature is changed
28
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_ObjectUpdatedMessage(
32     const ObjectPtr& theObject,
33     const Events_ID& theEvent);
34
35   friend class Model_EventCreator;
36 public:
37
38   /// Returns the feature that has been updated
39   virtual std::set<ObjectPtr> objects() const;
40
41   //! Creates a new empty group (to store it in the loop before flush)
42   virtual Events_MessageGroup* newEmpty();
43
44   //! Allows to join the given message with the current one
45   virtual void Join(Events_MessageGroup& theJoined);
46 };
47
48 /// Message that feature was deleted (used for Object Browser update)
49 class Model_ObjectDeletedMessage : public ModelAPI_ObjectDeletedMessage {
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
52
53   /// Use ModelAPI for creation of this event.
54   Model_ObjectDeletedMessage(
55     const boost::shared_ptr<ModelAPI_Document>& theDoc, const std::string& theGroup);
56
57   friend class Model_EventCreator;
58 public:
59   /// Returns the feature that has been updated
60   virtual boost::shared_ptr<ModelAPI_Document> document() const {return myDoc;}
61
62   /// Returns the group where the feature was deleted
63   virtual const std::set<std::string >& groups() const {return myGroups;}
64
65   virtual Events_MessageGroup* newEmpty();
66
67
68   virtual const Events_ID messageId();
69
70   virtual void Join(Events_MessageGroup& theJoined);
71 };
72
73 #endif