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