Salome HOME
Issue #1860: fix end lines with spaces
[modules/shaper.git] / src / Events / Events_InfoMessage.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        Events_InfoMessage.hxx
4 // Created:     31 May 2016
5 // Author:      Vitaly SMETANNIKOV
6
7 #ifndef Events_InfoMessage_H_
8 #define Events_InfoMessage_H_
9
10 #include <Events.h>
11 #include <Events_Message.h>
12 #include <Events_Loop.h>
13
14 #include <string>
15 #include <list>
16
17 /**\class Events_InfoMessage
18  * \ingroup EventsLoop
19  * \brief An event message for sending a string message which has to be translated.
20  */
21 class Events_InfoMessage: public Events_Message
22 {
23 public:
24
25   /// Constructor
26   /// \param theSender a pointer on sender object
27   explicit Events_InfoMessage(const void* theSender = 0):
28     Events_Message(Events_Loop::eventByName("InfoMessage"), theSender) {}
29
30   /// Constructor
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) {}
36
37   /// default destructor
38   virtual ~Events_InfoMessage() {}
39
40   /// Identifier of this event (one for all errors)
41   static Events_ID errorID()  { return Events_Loop::loop()->eventByName("InfoMessage"); }
42
43   /// Set a context string
44   /// \param theContext a context string
45   void  setContext(const std::string& theContext) { myContext = theContext; }
46
47
48   /// Returns context string
49   std::string context() const { return myContext; }
50
51   /// Set message string for translation
52   /// \param theMsg the string of message
53   void setMessageString(const std::string& theMsg) { myMessage = theMsg; }
54
55   /// Returns message
56   EVENTS_EXPORT std::string messageString() const;
57
58   Events_InfoMessage& operator=(const std::string& theMsg) {
59     setMessageString(theMsg);
60     return *this;
61   }
62
63   bool empty() const {
64     return myMessage.empty();
65   }
66
67   /// Add parameter for message string of string type
68   /// \param theParam the parameter
69   void addParameter(const std::string& theParam)
70   {
71     myParameters.push_back(theParam);
72   }
73
74   /// Add parameter for message string of double type
75   /// \param theParam the parameter
76   EVENTS_EXPORT void addParameter(double theParam);
77
78   /// Add parameter for message string of integer type
79   /// \param theParam the parameter
80   EVENTS_EXPORT void addParameter(int theParam);
81
82   /// Returns list of parameters
83   std::list<std::string> parameters() const { return myParameters; }
84
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; }
88
89   /// Add parameter for message string of integer type
90   /// \param theParam the parameter
91   Events_InfoMessage& arg(int theParam) { addParameter(theParam); return *this; }
92
93   /// Add parameter for message string of double type
94   /// \param theParam the parameter
95   Events_InfoMessage& arg(double theParam) { addParameter(theParam); return *this; }
96
97   /// Send the message
98   EVENTS_EXPORT void send();
99
100 private:
101
102   /// Context of the messgae
103   std::string myContext;
104
105   /// String of the message
106   std::string myMessage;
107
108   /// Parameters of the message
109   std::list<std::string> myParameters;
110 };
111
112 #endif