1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: Events_InfoMessage.hxx
4 // Created: 31 May 2016
5 // Author: Vitaly SMETANNIKOV
7 #ifndef Events_InfoMessage_H_
8 #define Events_InfoMessage_H_
11 #include <Events_Message.h>
12 #include <Events_Loop.h>
17 /**\class Events_InfoMessage
19 * \brief An event message for sending a string message which has to be translated.
21 class Events_InfoMessage: public Events_Message
26 /// \param theSender a pointer on sender object
27 explicit Events_InfoMessage(const void* theSender = 0):
28 Events_Message(Events_Loop::eventByName("InfoMessage"), theSender) {}
31 /// \param theSender a pointer on sender object
32 Events_InfoMessage(const std::string& theContext,
33 const std::string& theMsg, const void* theSender = 0):
34 Events_Message(Events_Loop::eventByName("InfoMessage"), theSender),
35 myContext(theContext), myMessage(theMsg) {}
37 /// default destructor
38 virtual ~Events_InfoMessage() {}
40 /// Identifier of this event (one for all errors)
41 static Events_ID errorID() { return Events_Loop::loop()->eventByName("InfoMessage"); }
43 /// Set a context string
44 /// \param theContext a context string
45 void setContext(const std::string& theContext) { myContext = theContext; }
48 /// Returns context string
49 std::string context() const { return myContext; }
51 /// Set message string for translation
52 /// \param theMsg the string of message
53 void setMessageString(const std::string& theMsg) { myMessage = theMsg; }
56 std::string messageString() const { return myMessage; }
58 Events_InfoMessage& operator=(const std::string& theMsg) {
59 setMessageString(theMsg);
64 return myMessage.empty();
67 /// Add parameter for message string of string type
68 /// \param theParam the parameter
69 void addParameter(const std::string& theParam)
71 myParameters.push_back(theParam);
74 /// Add parameter for message string of double type
75 /// \param theParam the parameter
76 EVENTS_EXPORT void addParameter(double theParam);
78 /// Add parameter for message string of integer type
79 /// \param theParam the parameter
80 EVENTS_EXPORT void addParameter(int theParam);
82 /// Returns list of parameters
83 std::list<std::string> parameters() const { return myParameters; }
85 /// Add parameter for message string of string type
86 /// \param theParam the parameter
87 Events_InfoMessage& arg(const std::string& theParam) { addParameter(theParam); return *this; }
89 /// Add parameter for message string of integer type
90 /// \param theParam the parameter
91 Events_InfoMessage& arg(int theParam) { addParameter(theParam); return *this; }
93 /// Add parameter for message string of double type
94 /// \param theParam the parameter
95 Events_InfoMessage& arg(double theParam) { addParameter(theParam); return *this; }
98 EVENTS_EXPORT void send();
102 /// Context of the messgae
103 std::string myContext;
105 /// String of the message
106 std::string myMessage;
108 /// Parameters of the message
109 std::list<std::string> myParameters;