SHAPER  9.12.0
Events_InfoMessage.h
1 // Copyright (C) 2014-2023 CEA, EDF
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 email : webmaster.salome@opencascade.com
18 //
19 
20 #ifndef Events_InfoMessage_H_
21 #define Events_InfoMessage_H_
22 
23 #include <Events.h>
24 #include <Events_Message.h>
25 #include <Events_Loop.h>
26 
27 #include <string>
28 #include <list>
29 
35 {
36 public:
37 
40  explicit Events_InfoMessage(const void* theSender = 0):
41  Events_Message(Events_Loop::eventByName("InfoMessage"), theSender) {}
42 
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) {}
49 
51  virtual ~Events_InfoMessage() {}
52 
54  static Events_ID errorID() { return Events_Loop::loop()->eventByName("InfoMessage"); }
55 
58  void setContext(const std::string& theContext) { myContext = theContext; }
59 
60 
62  std::string context() const { return myContext; }
63 
66  void setMessageString(const std::string& theMsg) { myMessage = theMsg; }
67 
69  std::string messageString() const { return myMessage; }
70 
71  Events_InfoMessage& operator=(const std::string& theMsg) {
72  setMessageString(theMsg);
73  return *this;
74  }
75 
76  bool empty() const {
77  return myMessage.empty();
78  }
79 
82  void addParameter(const std::string& theParam)
83  {
84  myParameters.push_back(theParam);
85  }
86 
89  EVENTS_EXPORT void addParameter(double theParam);
90 
93  EVENTS_EXPORT void addParameter(int theParam);
94 
96  std::list<std::string> parameters() const { return myParameters; }
97 
100  EVENTS_EXPORT Events_InfoMessage& arg(const std::wstring& theParam);
101 
104  Events_InfoMessage& arg(const std::string& theParam) { addParameter(theParam); return *this; }
105 
108  Events_InfoMessage& arg(int theParam) { addParameter(theParam); return *this; }
109 
112  Events_InfoMessage& arg(double theParam) { addParameter(theParam); return *this; }
113 
115  EVENTS_EXPORT void send();
116 
117 private:
118 
120  std::string myContext;
121 
123  std::string myMessage;
124 
126  std::list<std::string> myParameters;
127 };
128 
129 #endif
Identifier of the event kind.
Definition: Events_Message.h:36
An event message for sending a string message which has to be translated.
Definition: Events_InfoMessage.h:35
static Events_ID errorID()
Identifier of this event (one for all errors)
Definition: Events_InfoMessage.h:54
Events_InfoMessage(const void *theSender=0)
Constructor.
Definition: Events_InfoMessage.h:40
Events_InfoMessage & arg(double theParam)
Add parameter for message string of double type.
Definition: Events_InfoMessage.h:112
Events_InfoMessage & arg(const std::string &theParam)
Add parameter for message string of string type.
Definition: Events_InfoMessage.h:104
Events_InfoMessage & arg(int theParam)
Add parameter for message string of integer type.
Definition: Events_InfoMessage.h:108
void addParameter(const std::string &theParam)
Add parameter for message string of string type.
Definition: Events_InfoMessage.h:82
void setMessageString(const std::string &theMsg)
Set message string for translation.
Definition: Events_InfoMessage.h:66
std::string messageString() const
Returns message.
Definition: Events_InfoMessage.h:69
virtual ~Events_InfoMessage()
default destructor
Definition: Events_InfoMessage.h:51
Events_InfoMessage(const std::string &theContext, const std::string &theMsg, const void *theSender=0)
Constructor.
Definition: Events_InfoMessage.h:45
EVENTS_EXPORT void send()
Send the message.
Definition: Events_InfoMessage.cpp:38
std::list< std::string > parameters() const
Returns list of parameters.
Definition: Events_InfoMessage.h:96
void setContext(const std::string &theContext)
Set a context string.
Definition: Events_InfoMessage.h:58
EVENTS_EXPORT Events_InfoMessage & arg(const std::wstring &theParam)
Add parameter for message string of wstring type.
Definition: Events_InfoMessage.cpp:44
std::string context() const
Returns context string.
Definition: Events_InfoMessage.h:62
Base class that manages the receiving and sending of all not Qt-events in the application.
Definition: Events_Loop.h:43
static EVENTS_EXPORT Events_Loop * loop()
! Returns the main object of the loop, one per application.
Definition: Events_Loop.cpp:26
static EVENTS_EXPORT Events_ID eventByName(const char *theName)
Returns the unique event by the given name.
Definition: Events_Loop.cpp:33
Message for communication between sender and listener of event.
Definition: Events_Message.h:65