-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
-
-// File: Events_InfoMessage.hxx
-// Created: 31 May 2016
-// Author: Vitaly SMETANNIKOV
+// Copyright (C) 2014-2023 CEA, EDF
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
#ifndef Events_InfoMessage_H_
#define Events_InfoMessage_H_
#include <Events_Message.h>
#include <Events_Loop.h>
-class EVENTS_EXPORT Events_InfoMessage: public Events_Message
+#include <string>
+#include <list>
+
+/**\class Events_InfoMessage
+ * \ingroup EventsLoop
+ * \brief An event message for sending a string message which has to be translated.
+ */
+class Events_InfoMessage: public Events_Message
{
public:
- Events_InfoMessage(const void* theSender = 0) :
- Events_Message(Events_Loop::eventByName("InfoMessage"), theSender) {}
- void setContext(const std::string& theContext) { myContext = theContext; }
+ /// Constructor
+ /// \param theSender a pointer on sender object
+ explicit Events_InfoMessage(const void* theSender = 0):
+ Events_Message(Events_Loop::eventByName("InfoMessage"), theSender) {}
+
+ /// Constructor
+ /// \param theSender a pointer on sender object
+ Events_InfoMessage(const std::string& theContext,
+ const std::string& theMsg, const void* theSender = 0):
+ Events_Message(Events_Loop::eventByName("InfoMessage"), theSender),
+ myContext(theContext), myMessage(theMsg) {}
+
+ /// default destructor
+ virtual ~Events_InfoMessage() {}
+
+ /// Identifier of this event (one for all errors)
+ static Events_ID errorID() { return Events_Loop::loop()->eventByName("InfoMessage"); }
+
+ /// Set a context string
+ /// \param theContext a context string
+ void setContext(const std::string& theContext) { myContext = theContext; }
+
+ /// Returns context string
std::string context() const { return myContext; }
- void setMessage(const std::string& theMsg) { myMessage = theMsg; }
+ /// Set message string for translation
+ /// \param theMsg the string of message
+ void setMessageString(const std::string& theMsg) { myMessage = theMsg; }
- std::string message() const { return myMessage; }
+ /// Returns message
+ std::string messageString() const { return myMessage; }
- void addParameter(const std::string& theParam)
- {
- myParameters.push_back(theParam);
+ Events_InfoMessage& operator=(const std::string& theMsg) {
+ setMessageString(theMsg);
+ return *this;
}
- void addParameter(double theParam)
- {
- char aBuf[50];
- int n = sprintf(aBuf, "%g", theParam);
- std::string aStr(aBuf);
- myParameters.push_back(aStr);
+ bool empty() const {
+ return myMessage.empty();
}
- void addParameter(int theParam)
- {
- char aBuf[50];
- int n = sprintf(aBuf, "%d", theParam);
- std::string aStr(aBuf);
- myParameters.push_back(aStr);
+ /// Add parameter for message string of string type
+ /// \param theParam the parameter
+ void addParameter(const std::string& theParam)
+ {
+ myParameters.push_back(theParam);
}
+ /// Add parameter for message string of double type
+ /// \param theParam the parameter
+ EVENTS_EXPORT void addParameter(double theParam);
+
+ /// Add parameter for message string of integer type
+ /// \param theParam the parameter
+ EVENTS_EXPORT void addParameter(int theParam);
+
+ /// Returns list of parameters
std::list<std::string> parameters() const { return myParameters; }
+ /// Add parameter for message string of wstring type
+ /// \param theParam the parameter
+ EVENTS_EXPORT Events_InfoMessage& arg(const std::wstring& theParam);
+
+ /// Add parameter for message string of string type
+ /// \param theParam the parameter
+ Events_InfoMessage& arg(const std::string& theParam) { addParameter(theParam); return *this; }
+
+ /// Add parameter for message string of integer type
+ /// \param theParam the parameter
+ Events_InfoMessage& arg(int theParam) { addParameter(theParam); return *this; }
+
+ /// Add parameter for message string of double type
+ /// \param theParam the parameter
+ Events_InfoMessage& arg(double theParam) { addParameter(theParam); return *this; }
+
+ /// Send the message
+ EVENTS_EXPORT void send();
+
private:
/// Context of the messgae
std::list<std::string> myParameters;
};
-#endif
\ No newline at end of file
+#endif