Salome HOME
Fix for the issue #1755 : for now the sketch solver receives all modified entities...
[modules/shaper.git] / src / Events / Events_Listener.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        Events_Listener.hxx
4 // Created:     Thu Mar 13 2014
5 // Author:      Mikhail PONIKAROV
6
7 #ifndef Events_Listener_H_
8 #define Events_Listener_H_
9
10 #include <Events.h>
11 #include <memory>
12 #include <map>
13
14 class Events_Message;
15 class Events_ID;
16
17 /**\class Events_Listener
18  * \ingroup EventsLoop
19  * \brief Base interface for any event listener.
20  *
21  * If some object wants to listen some events it must inherit
22  * this class and register in the Loop.
23  */
24 class Events_Listener {
25   /// map from event ID to groupped messages (for flush for groupMessages=true listeners)
26   std::map<char*, std::shared_ptr<Events_Message> > myGroups;
27
28  public:
29   //! This method is called by loop when the event is started to process.
30   EVENTS_EXPORT virtual void processEvent(const std::shared_ptr<Events_Message>& theMessage) = 0;
31
32   //! Listener that needs mostly grouped messages received returns true in this method.
33   //! In this case during the message is flushed, all the new messages are grouped, not sended
34   //! immideately and then sent in the end of flush.
35   EVENTS_EXPORT virtual bool groupMessages() {return false;}
36
37 protected:
38   //! Allows to group messages while they are flushed (for flush for groupMessages=true listeners)
39   void groupWhileFlush(const std::shared_ptr<Events_Message>& theMessage);
40   //! Sends myGroups on flush finish
41   EVENTS_EXPORT void flushGrouped(const Events_ID& theID);
42
43   friend class Events_Loop;
44 };
45
46 #endif