1 // File: Event_Loop.hxx
2 // Created: Thu Mar 13 2014
3 // Author: Mikhail PONIKAROV
5 #ifndef Event_Loop_HeaderFile
6 #define Event_Loop_HeaderFile
8 #include <Event_Message.h>
9 #include <Event_Listener.h>
16 * \brief Base class that manages the receiving and sending of all
17 * not Qt-events in the application.
19 * One per application, initialized on start. Listeners must register in this loop
20 * to get events, called by senders. Sending of events is very fast (just adding to container).
21 * Performing of events is processed in separated thread, so, sender takes
22 * control back immideately.
25 std::map<char*, std::map<void*, std::list<Event_Listener*> > >
26 myListeners; ///< map from event ID to sender pointer to listeners that must be called for this
28 //! The empty constructor, will be called at startup of the application, only once
31 ///! Returns the main object of the loop, one per application.
32 EVENT_EXPORT static Event_Loop* loop();
33 //! Returns the unique event by the given name. Call this method only on initialization of object
34 //! to speedup the events processing without parsing of the string.
35 EVENT_EXPORT static Event_ID eventByName(const char* theName);
37 //! Allows to send an event
38 EVENT_EXPORT void send(Event_Message& theMessage);
40 //! Registers (or adds if such listener is already registered) a listener
41 //! that will be called on the event and from the defined sender
42 EVENT_EXPORT void registerListener(Event_Listener* theListener, const Event_ID theID,