00001 // MCC_Status.h 00002 00003 #ifndef __MCC_Status__ 00004 #define __MCC_Status__ 00005 00006 #include <string> 00007 00008 namespace Arc { 00009 00011 00013 enum StatusKind { 00014 STATUS_UNDEFINED = 0, 00015 STATUS_OK = 1, 00016 GENERIC_ERROR = 2, 00017 PARSING_ERROR = 4, 00018 PROTOCOL_RECOGNIZED_ERROR = 8, 00019 UNKNOWN_SERVICE_ERROR = 16, 00020 BUSY_ERROR = 32, 00021 SESSION_CLOSE = 64 00022 }; 00023 00025 00028 std::string string(StatusKind kind); 00029 00030 00031 00033 00037 class MCC_Status { 00038 public: 00039 00041 00046 MCC_Status(StatusKind kind = STATUS_UNDEFINED, 00047 const std::string& origin = "???", 00048 const std::string& explanation = "No explanation."); 00049 00051 00055 bool isOk() const; 00056 00058 00061 StatusKind getKind() const; 00062 00064 00068 const std::string& getOrigin() const; 00069 00071 00074 const std::string& getExplanation() const; 00075 00077 00079 operator std::string() const; 00080 00082 00086 operator bool(void) const { return isOk(); }; 00087 00089 00092 bool operator!(void) const { return !isOk(); }; 00093 00094 private: 00095 00097 StatusKind kind; 00098 00100 std::string origin; 00101 00103 std::string explanation; 00104 00105 }; 00106 00107 } 00108 00109 #endif 00110