Salome HOME
Merge branch 'BR_coding_rules'
[modules/shaper.git] / src / Events / Events_Message.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        Events_Message.hxx
4 // Created:     Thu Mar 13 2014
5 // Author:      Mikhail PONIKAROV
6
7 #ifndef Events_Message_H_
8 #define Events_Message_H_
9
10 #include <Events.h>
11
12 /**\class Events_ID
13  * \ingroup EventsLoop
14  * \brief Identifier of the event kind.
15  *
16  * Each event ID is created in main Envent_Loop class
17  * that stores correspondence between the string-name of the
18  * identifier and the pointer to the static string that is really
19  * used as an identifier (this is useful for debugging of the events
20  * with log files and in debugger).
21  */
22 class EVENTS_EXPORT Events_ID
23 {
24   /// pointer to the text-identifier of the event, unique pointer for all events of such type
25   char* myID;
26
27   Events_ID(char* theID)
28   {
29     myID = theID;
30   }
31
32   friend class Events_Loop;
33  public:
34   /// Returns the text-identifier of the event (for debugging reasons)
35   char* eventText() const
36   {
37     return myID;
38   }
39   /// Allows to compare identifiers
40   bool operator==(const Events_ID& theID) const
41   {
42     return myID == theID.myID;
43   }
44 };
45
46 /**\class Events_Message
47  * \ingroup EventsLoop
48  * \brief Message for communication between sender and listener of event.
49  * Normally it is inherited by the higher-level 
50  */
51 class EVENTS_EXPORT Events_Message
52 {
53   Events_ID myEventsId;  ///< identifier of the event
54   void* mySender;  ///< the sender object
55
56  public:
57
58   //! Creates the message
59   Events_Message(const Events_ID theID, const void* theSender = 0)
60       : myEventsId(theID),
61         mySender((void*) theSender)
62   {
63   }
64   //! do nothing in the destructor yet
65   virtual ~Events_Message()
66   {
67   }
68
69   //! Returns identifier of the message
70   const Events_ID& eventID() const
71   {
72     return myEventsId;
73   }
74
75   //! Returns sender of the message or NULL if it is anonymous message
76   void* sender() const
77   {
78     return mySender;
79   }
80 };
81
82 #endif