1 // Copyright (C) 2014-2017 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
21 #ifndef Events_InfoMessage_H_
22 #define Events_InfoMessage_H_
25 #include <Events_Message.h>
26 #include <Events_Loop.h>
31 /**\class Events_InfoMessage
33 * \brief An event message for sending a string message which has to be translated.
35 class Events_InfoMessage: public Events_Message
40 /// \param theSender a pointer on sender object
41 explicit Events_InfoMessage(const void* theSender = 0):
42 Events_Message(Events_Loop::eventByName("InfoMessage"), theSender) {}
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) {}
51 /// default destructor
52 virtual ~Events_InfoMessage() {}
54 /// Identifier of this event (one for all errors)
55 static Events_ID errorID() { return Events_Loop::loop()->eventByName("InfoMessage"); }
57 /// Set a context string
58 /// \param theContext a context string
59 void setContext(const std::string& theContext) { myContext = theContext; }
62 /// Returns context string
63 std::string context() const { return myContext; }
65 /// Set message string for translation
66 /// \param theMsg the string of message
67 void setMessageString(const std::string& theMsg) { myMessage = theMsg; }
70 std::string messageString() const { return myMessage; }
72 Events_InfoMessage& operator=(const std::string& theMsg) {
73 setMessageString(theMsg);
78 return myMessage.empty();
81 /// Add parameter for message string of string type
82 /// \param theParam the parameter
83 void addParameter(const std::string& theParam)
85 myParameters.push_back(theParam);
88 /// Add parameter for message string of double type
89 /// \param theParam the parameter
90 EVENTS_EXPORT void addParameter(double theParam);
92 /// Add parameter for message string of integer type
93 /// \param theParam the parameter
94 EVENTS_EXPORT void addParameter(int theParam);
96 /// Returns list of parameters
97 std::list<std::string> parameters() const { return myParameters; }
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; }
103 /// Add parameter for message string of integer type
104 /// \param theParam the parameter
105 Events_InfoMessage& arg(int theParam) { addParameter(theParam); return *this; }
107 /// Add parameter for message string of double type
108 /// \param theParam the parameter
109 Events_InfoMessage& arg(double theParam) { addParameter(theParam); return *this; }
112 EVENTS_EXPORT void send();
116 /// Context of the messgae
117 std::string myContext;
119 /// String of the message
120 std::string myMessage;
122 /// Parameters of the message
123 std::list<std::string> myParameters;