1 // Copyright (C) 2014-2019 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 email : webmaster.salome@opencascade.com
20 #ifndef Events_InfoMessage_H_
21 #define Events_InfoMessage_H_
24 #include <Events_Message.h>
25 #include <Events_Loop.h>
30 /**\class Events_InfoMessage
32 * \brief An event message for sending a string message which has to be translated.
34 class Events_InfoMessage: public Events_Message
39 /// \param theSender a pointer on sender object
40 explicit Events_InfoMessage(const void* theSender = 0):
41 Events_Message(Events_Loop::eventByName("InfoMessage"), theSender) {}
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) {}
50 /// default destructor
51 virtual ~Events_InfoMessage() {}
53 /// Identifier of this event (one for all errors)
54 static Events_ID errorID() { return Events_Loop::loop()->eventByName("InfoMessage"); }
56 /// Set a context string
57 /// \param theContext a context string
58 void setContext(const std::string& theContext) { myContext = theContext; }
61 /// Returns context string
62 std::string context() const { return myContext; }
64 /// Set message string for translation
65 /// \param theMsg the string of message
66 void setMessageString(const std::string& theMsg) { myMessage = theMsg; }
69 std::string messageString() const { return myMessage; }
71 Events_InfoMessage& operator=(const std::string& theMsg) {
72 setMessageString(theMsg);
77 return myMessage.empty();
80 /// Add parameter for message string of string type
81 /// \param theParam the parameter
82 void addParameter(const std::string& theParam)
84 myParameters.push_back(theParam);
87 /// Add parameter for message string of double type
88 /// \param theParam the parameter
89 EVENTS_EXPORT void addParameter(double theParam);
91 /// Add parameter for message string of integer type
92 /// \param theParam the parameter
93 EVENTS_EXPORT void addParameter(int theParam);
95 /// Returns list of parameters
96 std::list<std::string> parameters() const { return myParameters; }
98 /// Add parameter for message string of wstring type
99 /// \param theParam the parameter
100 EVENTS_EXPORT Events_InfoMessage& arg(const std::wstring& theParam);
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; }
106 /// Add parameter for message string of integer type
107 /// \param theParam the parameter
108 Events_InfoMessage& arg(int theParam) { addParameter(theParam); return *this; }
110 /// Add parameter for message string of double type
111 /// \param theParam the parameter
112 Events_InfoMessage& arg(double theParam) { addParameter(theParam); return *this; }
115 EVENTS_EXPORT void send();
119 /// Context of the messgae
120 std::string myContext;
122 /// String of the message
123 std::string myMessage;
125 /// Parameters of the message
126 std::list<std::string> myParameters;