Salome HOME
Merge branch 'Dev_0.6.1' of newgeom:newgeom into Dev_0.6.1
[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 correspondance 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 usefull for debugging of the events
20  * with log files and in debugger).
21  */
22 class EVENTS_EXPORT Events_ID
23 {
24   char* myID;  ///< pointer to the text-identifier of the event, unique pointer for all events of such type
25
26   Events_ID(char* theID)
27   {
28     myID = theID;
29   }
30
31   friend class Events_Loop;
32  public:
33   /// Returns the text-identifier of the event (for debugging reasons)
34   char* eventText() const
35   {
36     return myID;
37   }
38   /// Allows to compare identifiers
39   bool operator==(const Events_ID& theID) const
40   {
41     return myID == theID.myID;
42   }
43 };
44
45 /**\class Events_Message
46  * \ingroup EventsLoop
47  * \brief Message for communication between sender and listener of event.
48  * Normally it is inherited by the higher-level 
49  */
50 class EVENTS_EXPORT Events_Message
51 {
52   Events_ID myEventsId;  ///< identifier of the event
53   void* mySender;  ///< the sender object
54
55  public:
56
57   //! Creates the message
58   Events_Message(const Events_ID theID, const void* theSender = 0)
59       : myEventsId(theID),
60         mySender((void*) theSender)
61   {
62   }
63   //! do nothing in the destructor yet
64   virtual ~Events_Message()
65   {
66   }
67
68   //! Returns identifier of the message
69   const Events_ID& eventID() const
70   {
71     return myEventsId;
72   }
73
74   //! Returns sender of the message or NULL if it is anonymous message
75   void* sender() const
76   {
77     return mySender;
78   }
79 };
80
81 #endif