Salome HOME
updated copyright message
[modules/shaper.git] / src / Events / Events_InfoMessage.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_InfoMessage_H_
21 #define Events_InfoMessage_H_
22
23 #include <Events.h>
24 #include <Events_Message.h>
25 #include <Events_Loop.h>
26
27 #include <string>
28 #include <list>
29
30 /**\class Events_InfoMessage
31  * \ingroup EventsLoop
32  * \brief An event message for sending a string message which has to be translated.
33  */
34 class Events_InfoMessage: public Events_Message
35 {
36 public:
37
38   /// Constructor
39   /// \param theSender a pointer on sender object
40   explicit Events_InfoMessage(const void* theSender = 0):
41     Events_Message(Events_Loop::eventByName("InfoMessage"), theSender) {}
42
43   /// Constructor
44   /// \param theSender a pointer on sender object
45   Events_InfoMessage(const std::string& theContext,
46     const std::string& theMsg, const void* theSender = 0):
47   Events_Message(Events_Loop::eventByName("InfoMessage"), theSender),
48     myContext(theContext), myMessage(theMsg) {}
49
50   /// default destructor
51   virtual ~Events_InfoMessage() {}
52
53   /// Identifier of this event (one for all errors)
54   static Events_ID errorID()  { return Events_Loop::loop()->eventByName("InfoMessage"); }
55
56   /// Set a context string
57   /// \param theContext a context string
58   void  setContext(const std::string& theContext) { myContext = theContext; }
59
60
61   /// Returns context string
62   std::string context() const { return myContext; }
63
64   /// Set message string for translation
65   /// \param theMsg the string of message
66   void setMessageString(const std::string& theMsg) { myMessage = theMsg; }
67
68   /// Returns message
69   std::string messageString() const { return myMessage; }
70
71   Events_InfoMessage& operator=(const std::string& theMsg) {
72     setMessageString(theMsg);
73     return *this;
74   }
75
76   bool empty() const {
77     return myMessage.empty();
78   }
79
80   /// Add parameter for message string of string type
81   /// \param theParam the parameter
82   void addParameter(const std::string& theParam)
83   {
84     myParameters.push_back(theParam);
85   }
86
87   /// Add parameter for message string of double type
88   /// \param theParam the parameter
89   EVENTS_EXPORT void addParameter(double theParam);
90
91   /// Add parameter for message string of integer type
92   /// \param theParam the parameter
93   EVENTS_EXPORT void addParameter(int theParam);
94
95   /// Returns list of parameters
96   std::list<std::string> parameters() const { return myParameters; }
97
98   /// Add parameter for message string of wstring type
99   /// \param theParam the parameter
100   EVENTS_EXPORT Events_InfoMessage& arg(const std::wstring& theParam);
101
102   /// Add parameter for message string of string type
103   /// \param theParam the parameter
104   Events_InfoMessage& arg(const std::string& theParam) { addParameter(theParam); return *this; }
105
106   /// Add parameter for message string of integer type
107   /// \param theParam the parameter
108   Events_InfoMessage& arg(int theParam) { addParameter(theParam); return *this; }
109
110   /// Add parameter for message string of double type
111   /// \param theParam the parameter
112   Events_InfoMessage& arg(double theParam) { addParameter(theParam); return *this; }
113
114   /// Send the message
115   EVENTS_EXPORT void send();
116
117 private:
118
119   /// Context of the messgae
120   std::string myContext;
121
122   /// String of the message
123   std::string myMessage;
124
125   /// Parameters of the message
126   std::list<std::string> myParameters;
127 };
128
129 #endif