]> SALOME platform Git repositories - modules/shaper.git/blob - src/Event/Event_Message.hxx
Salome HOME
Auto-formatting according to the defined code standard.
[modules/shaper.git] / src / Event / Event_Message.hxx
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.hxx>
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 {
22   char* myID; ///< pointer to the text-identifier of the event, unique pointer for all events of such type
23
24   Event_ID(char* theID)
25   {
26     myID = theID;
27   }
28
29   friend class Event_Loop;
30 public:
31   /// Returns the text-identifier of the event (for debugging reasons)
32   char* EventText() const
33   {
34     return myID;
35   }
36   /// Allows to compare identifiers
37   bool operator==(const Event_ID& theID) const
38   {
39     return myID == theID.myID;
40   }
41 };
42
43 /**\class Event_Message
44  * \ingroup EventLoop
45  * \brief Message for communication between sender and listener of event.
46  * Normally it is inherited by the higher-level 
47  */
48 class EVENT_EXPORT Event_Message
49 {
50   Event_ID myEventId; ///< identifier of the event
51   void* mySender; ///< the sender object
52
53 public:
54
55   //! Creates the message
56   Event_Message(const Event_ID theID, const void* theSender = 0);
57   virtual ~Event_Message()
58   {
59   }
60
61   //! Returns identifier of the message
62   const Event_ID& EventID() const
63   {
64     return myEventId;
65   }
66
67   //! Returns sender of the message or NULL if it is anonymous message
68   void* Sender()
69   {
70     return mySender;
71   }
72 };
73
74 #endif