Salome HOME
updated copyright message
[modules/shaper.git] / src / Events / Events_Message.h
1 // Copyright (C) 2014-2023  CEA, EDF
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #ifndef Events_Message_H_
21 #define Events_Message_H_
22
23 #include <Events.h>
24
25 /**\class Events_ID
26  * \ingroup EventsLoop
27  * \brief Identifier of the event kind.
28  *
29  * Each event ID is created in main Envent_Loop class
30  * that stores correspondence between the string-name of the
31  * identifier and the pointer to the static string that is really
32  * used as an identifier (this is useful for debugging of the events
33  * with log files and in debugger).
34  */
35 class EVENTS_EXPORT Events_ID
36 {
37   /// pointer to the text-identifier of the event, unique pointer for all events of such type
38   char* myID;
39
40   Events_ID(char* theID)
41   {
42     myID = theID;
43   }
44
45   friend class Events_Loop;
46  public:
47   /// Returns the text-identifier of the event (for debugging reasons)
48   char* eventText() const
49   {
50     return myID;
51   }
52   /// Allows to compare identifiers
53   bool operator==(const Events_ID& theID) const
54   {
55     return myID == theID.myID;
56   }
57 };
58
59 /**\class Events_Message
60  * \ingroup EventsLoop
61  * \brief Message for communication between sender and listener of event.
62  * Normally it is inherited by the higher-level 
63  */
64 class EVENTS_EXPORT Events_Message
65 {
66   Events_ID myEventsId;  ///< identifier of the event
67   void* mySender;  ///< the sender object
68
69  public:
70
71   //! Creates the message
72   Events_Message(const Events_ID theID, const void* theSender = 0)
73       : myEventsId(theID),
74         mySender((void*) theSender)
75   {
76   }
77   //! do nothing in the destructor yet
78   virtual ~Events_Message()
79   {
80   }
81
82   //! Returns identifier of the message
83   const Events_ID& eventID() const
84   {
85     return myEventsId;
86   }
87
88   //! Returns sender of the message or NULL if it is anonymous message
89   void* sender() const
90   {
91     return mySender;
92   }
93 };
94
95 #endif