00001 // Message.h 00002 00003 #ifndef MESSAGE_H 00004 #define MESSAGE_H 00005 00006 #include <string> 00007 00008 namespace Yosokumo 00009 { 00010 00011 /** 00012 * A text message with a type indicating if the message is information or 00013 * an error. Some responses from the Yokosumo service return messages, 00014 * especially in case of error. 00015 */ 00016 class Message 00017 { 00018 public: 00019 00020 /** 00021 * Indicates whether the message is informational or an error message. 00022 */ 00023 enum Type 00024 { 00025 /** 00026 * the message is informational. 00027 */ 00028 INFORMATION, 00029 /** 00030 * the message indicates an error. 00031 */ 00032 ERROR 00033 }; 00034 00035 private: 00036 00037 /** 00038 * The type of message. 00039 */ 00040 Type type; 00041 00042 /** 00043 * The message text. 00044 */ 00045 std::string text; 00046 00047 public: 00048 00049 // Constructors 00050 00051 /** 00052 * Initializes a newly created <code>Message</code> object with default 00053 * attributes: type == INFORMATION and text == "". 00054 */ 00055 Message(); 00056 00057 /** 00058 * Initializes a newly created <code>Message</code> object with attributes 00059 * specified by the input parameters. 00060 * 00061 * @param type the type of the message: INFORMATION or ERROR. 00062 * @param text the text of the message. 00063 */ 00064 Message(Type type, const std::string &text); 00065 00066 00067 // Getters 00068 00069 /** 00070 * Return the message text. 00071 * 00072 * @return the text of the message. 00073 */ 00074 std::string getText() const; 00075 00076 /** 00077 * Return the message type. 00078 * 00079 * @return the type of this message. 00080 */ 00081 Type getType() const; 00082 00083 00084 // Setters 00085 00086 /** 00087 * Set the message text. 00088 * 00089 * @param text the text of the message is set to this. 00090 */ 00091 void setText(const std::string &text); 00092 00093 /** 00094 * Set the message type. 00095 * 00096 * @param type the type of the message is set to this. 00097 */ 00098 void setType(Type type); 00099 00100 00101 // Utility 00102 00103 /** 00104 * Return a string representation of this <code>Message</code>. 00105 * 00106 * @return the string representation of this <code>Message</code>. 00107 */ 00108 std::string toString() const; 00109 00110 }; // end class Message 00111 00112 } // end namespace Yosokumo 00113 00114 #endif // MESSAGE_H 00115 00116 // end Message.h