1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: Events_Listener.hxx
4 // Created: Thu Mar 13 2014
5 // Author: Mikhail PONIKAROV
7 #ifndef Events_Listener_H_
8 #define Events_Listener_H_
17 /**\class Events_Listener
19 * \brief Base interface for any event listener.
21 * If some object wants to listen some events it must inherit
22 * this class and register in the Loop.
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;
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;
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;}
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);
43 friend class Events_Loop;