X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FEvents%2FEvents_InfoMessage.h;h=16398492d55afb2095c223902eea3c8d9127175e;hb=d5b5ce2284869d8b97ce638502c58c810bbeb0c7;hp=bf92b3af308f70a815628ecb56e4c92ff789ec13;hpb=a8cfbfb436c27ff96edd5c808e9a452c35cef207;p=modules%2Fshaper.git diff --git a/src/Events/Events_InfoMessage.h b/src/Events/Events_InfoMessage.h index bf92b3af3..16398492d 100644 --- a/src/Events/Events_InfoMessage.h +++ b/src/Events/Events_InfoMessage.h @@ -1,8 +1,22 @@ -// Copyright (C) 2014-20xx CEA/DEN, EDF R&D - -// File: Events_InfoMessage.hxx -// Created: 31 May 2016 -// Author: Vitaly SMETANNIKOV +// Copyright (C) 2014-2017 CEA/DEN, EDF R&D +// +// 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_ @@ -11,6 +25,9 @@ #include #include +#include +#include + /**\class Events_InfoMessage * \ingroup EventsLoop * \brief An event message for sending a string message which has to be translated. @@ -21,16 +38,17 @@ public: /// Constructor /// \param theSender a pointer on sender object - Events_InfoMessage(const void* theSender = 0):Events_Message(Events_Loop::eventByName("InfoMessage"), theSender) {} + 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, + 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 + /// default destructor virtual ~Events_InfoMessage() {} /// Identifier of this event (one for all errors) @@ -38,7 +56,7 @@ public: /// Set a context string /// \param theContext a context string - void setContext(const std::string& theContext) { myContext = theContext; } + void setContext(const std::string& theContext) { myContext = theContext; } /// Returns context string @@ -46,37 +64,34 @@ public: /// Set message string for translation /// \param theMsg the string of message - void setMessage(const std::string& theMsg) { myMessage = theMsg; } + void setMessageString(const std::string& theMsg) { myMessage = theMsg; } /// Returns message - std::string message() const { return myMessage; } + std::string messageString() const { return myMessage; } + + Events_InfoMessage& operator=(const std::string& theMsg) { + setMessageString(theMsg); + return *this; + } + + bool empty() const { + return myMessage.empty(); + } /// Add parameter for message string of string type /// \param theParam the parameter - void addParameter(const std::string& theParam) - { - myParameters.push_back(theParam); + void addParameter(const std::string& theParam) + { + myParameters.push_back(theParam); } /// Add parameter for message string of double type /// \param theParam the parameter - void addParameter(double theParam) - { - char aBuf[50]; - int n = sprintf_s(aBuf, "%g", theParam); - std::string aStr(aBuf); - myParameters.push_back(aStr); - } + EVENTS_EXPORT void addParameter(double theParam); /// Add parameter for message string of integer type /// \param theParam the parameter - void addParameter(int theParam) - { - char aBuf[50]; - int n = sprintf_s(aBuf, "%d", theParam); - std::string aStr(aBuf); - myParameters.push_back(aStr); - } + EVENTS_EXPORT void addParameter(int theParam); /// Returns list of parameters std::list parameters() const { return myParameters; } @@ -93,10 +108,8 @@ public: /// \param theParam the parameter Events_InfoMessage& arg(double theParam) { addParameter(theParam); return *this; } - void send() { - std::shared_ptr aMsg(new Events_InfoMessage(*this)); - Events_Loop::loop()->send(aMsg); - } + /// Send the message + EVENTS_EXPORT void send(); private: @@ -110,4 +123,4 @@ private: std::list myParameters; }; -#endif \ No newline at end of file +#endif