]> SALOME platform Git repositories - modules/shaper.git/blob - src/ModelAPI/ModelAPI_Events.h
Salome HOME
Issue #273: Add copyright string
[modules/shaper.git] / src / ModelAPI / ModelAPI_Events.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        ModelAPI_Events.h
4 // Created:     10 Apr 2014
5 // Author:      Mikhail PONIKAROV
6
7 #ifndef MODELAPI_EVENTS_H_
8 #define MODELAPI_EVENTS_H_
9
10 #include <ModelAPI.h>
11 #include <ModelAPI_Object.h>
12 #include <Events_MessageGroup.h>
13
14 #include <memory>
15 #include <string>
16 #include <set>
17
18
19 class ModelAPI_Document;
20
21 /// Event ID that feature is created (comes with ModelAPI_ObjectUpdatedMessage)
22 static const char * EVENT_OBJECT_CREATED = "ObjectCreated";
23 /// Event ID that data of feature is updated (comes with Model_ObjectUpdatedMessage)
24 static const char * EVENT_OBJECT_UPDATED = "ObjectUpdated";
25 /// Event ID that data of feature is deleted (comes with Model_ObjectDeletedMessage)
26 static const char * EVENT_OBJECT_DELETED = "ObjectDeleted";
27 /// Event ID that data of feature is updated (comes with ModelAPI_ObjectUpdatedMessage)
28 static const char * EVENT_OBJECT_MOVED = "ObjectsMoved";
29 /// Event ID that visualization must be redisplayed (comes with ModelAPI_ObjectUpdatedMessage)
30 static const char * EVENT_OBJECT_TO_REDISPLAY = "ObjectsToRedisplay";
31 /// Event ID that visualization must be redisplayed (comes with ModelAPI_ObjectUpdatedMessage)
32 static const char * EVENT_OPERATION_LAUNCHED = "OperationLaunched";
33 /// Event ID that plugin is loaded (comes with ModelAPI_ObjectUpdatedMessage)
34 static const char * EVENT_PLUGIN_LOADED = "PliginLoaded";
35 /// Event ID that data of feature has to be shown (comes with ModelAPI_ObjectUpdatedMessage)
36 static const char * EVENT_OBJECT_TOSHOW = "ObjectShow";
37 /// Event ID that data of feature has to be shown (comes with ModelAPI_ObjectUpdatedMessage)
38 static const char * EVENT_OBJECT_TOHIDE = "ObjectHide";
39
40 /// Message that feature was changed (used for Object Browser update): moved, updated and deleted
41 class MODELAPI_EXPORT ModelAPI_ObjectUpdatedMessage : public Events_MessageGroup
42 {
43  protected:
44   ModelAPI_ObjectUpdatedMessage(const Events_ID theID, const void* theSender = 0);
45   virtual ~ModelAPI_ObjectUpdatedMessage();
46
47  public:
48   /// Returns the feature that has been updated
49   virtual const std::set<ObjectPtr>& objects() const = 0;
50
51   //! Creates a new empty group (to store it in the loop before flush)
52   virtual std::shared_ptr<Events_MessageGroup> newEmpty() = 0;
53
54   //! Allows to join the given message with the current one
55   virtual void Join(const std::shared_ptr<Events_MessageGroup>& theJoined) = 0;
56 };
57
58 /// Message that feature was deleted (used for Object Browser update)
59 class MODELAPI_EXPORT ModelAPI_ObjectDeletedMessage : public Events_MessageGroup
60 {
61  protected:
62   ModelAPI_ObjectDeletedMessage(const Events_ID theID, const void* theSender = 0);
63   virtual ~ModelAPI_ObjectDeletedMessage();
64
65  public:
66   /// Returns the feature that has been updated
67   virtual std::shared_ptr<ModelAPI_Document> document() const = 0;
68
69   /// Returns the group where the feature was deleted
70   virtual const std::set<std::string>& groups() const = 0;
71
72   virtual std::shared_ptr<Events_MessageGroup> newEmpty() = 0;
73
74   virtual const Events_ID messageId() = 0;
75
76   virtual void Join(const std::shared_ptr<Events_MessageGroup>& theJoined) = 0;
77 };
78
79 /// Allows to create ModelAPI messages
80 class MODELAPI_EXPORT ModelAPI_EventCreator
81 {
82  public:
83   /// creates created, updated or moved messages and sends to the loop
84   virtual void sendUpdated(const ObjectPtr& theObject, const Events_ID& theEvent,
85                            const bool isGroupped = true) const = 0;
86   /// creates deleted message and sends to the loop
87   virtual void sendDeleted(const std::shared_ptr<ModelAPI_Document>& theDoc,
88                            const std::string& theGroup) const = 0;
89
90   /// returns the creator instance
91   static const ModelAPI_EventCreator* get();
92
93   /// sets the creator instance
94   static void set(const ModelAPI_EventCreator* theCreator);
95 };
96
97 #endif