X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FEvents%2FEvents_Listener.h;h=74aac548334feda5a60f33c7e95b84c2f9dd626d;hb=b5893b0a30fac08134c24de4565cb513a43affa6;hp=90dedcdfd14e9b0654c12545a755a0a3228c62f3;hpb=3874b57fe5aba25ff5aee2a07654fc23c1ee8eb0;p=modules%2Fshaper.git diff --git a/src/Events/Events_Listener.h b/src/Events/Events_Listener.h index 90dedcdfd..74aac5483 100644 --- a/src/Events/Events_Listener.h +++ b/src/Events/Events_Listener.h @@ -9,8 +9,10 @@ #include #include +#include class Events_Message; +class Events_ID; /**\class Events_Listener * \ingroup EventsLoop @@ -19,12 +21,26 @@ class Events_Message; * If some object wants to listen some events it must inherit * this class and register in the Loop. */ -class EVENTS_EXPORT Events_Listener -{ +class Events_Listener { + /// map from event ID to groupped messages (for flush for groupMessages=true listeners) + std::map > myGroups; public: //! This method is called by loop when the event is started to process. - virtual void processEvent(const std::shared_ptr& theMessage) = 0; + EVENTS_EXPORT virtual void processEvent(const std::shared_ptr& theMessage) = 0; + + //! Listener that needs mostly grouped messages received returns true in this method. + //! In this case during the message is flushed, all the new messages are grouped, not sended + //! immideately and then sent in the end of flush. + EVENTS_EXPORT virtual bool groupMessages() {return false;} + +protected: + //! Allows to group messages while they are flushed (for flush for groupMessages=true listeners) + void groupWhileFlush(const std::shared_ptr& theMessage); + //! Sends myGroups on flush finish + EVENTS_EXPORT void flushGrouped(const Events_ID& theID); + + friend class Events_Loop; }; #endif