Salome HOME
Merge branch 'master' of newgeom:newgeom.git
[modules/shaper.git] / src / Event / Event_Message.h
1 // File:        Event_Message.hxx
2 // Created:     Thu Mar 13 2014
3 // Author:      Mikhail PONIKAROV
4
5 #ifndef Event_Message_HeaderFile
6 #define Event_Message_HeaderFile
7
8 #include <Event.h>
9
10 /**\class Event_ID
11  * \ingroup EventLoop
12  * \brief Identifier of the event kind.
13  *
14  * Each event ID is created in main Envent_Loop class
15  * that stores correspondance between the string-name of the
16  * identifier and the pointer to the static string that is really
17  * used as an identifier (this is usefull for debugging of the events
18  * with log files and in debugger).
19  */
20 class EVENT_EXPORT Event_ID {
21   char* myID; ///< pointer to the text-identifier of the event, unique pointer for all events of such type
22
23   Event_ID(char* theID) {myID = theID;}
24
25   friend class Event_Loop;
26 public:
27   /// Returns the text-identifier of the event (for debugging reasons)
28   char* EventText() const {return myID;}
29   /// Allows to compare identifiers
30   bool operator==(const Event_ID& theID) const {return myID == theID.myID;}
31 };
32
33 /**\class Event_Message
34  * \ingroup EventLoop
35  * \brief Message for communication between sender and listener of event.
36  * Normally it is inherited by the higher-level 
37  */
38 class EVENT_EXPORT Event_Message {
39   Event_ID myEventId; ///< identifier of the event
40   void* mySender; ///< the sender object
41
42 public:
43
44   //! Creates the message
45   Event_Message(const Event_ID theID, const void* theSender = 0);
46   virtual ~Event_Message() {}
47
48   //! Returns identifier of the message
49   const Event_ID& EventID() const {return myEventId;}
50
51   //! Returns sender of the message or NULL if it is anonymous message
52   void* Sender() {return mySender;}
53 };
54
55 #endif