#include <TrkErrCode.h>
Public Types | |
enum | TrkSuccess { fail, succeed } |
enum | TrkSuccess { fail, succeed } |
Public Member Functions | |
int | failure () const |
int | failure () const |
const std::string & | message () const |
const std::string & | message () const |
TrkErrCode & | operator= (const TrkErrCode &) |
TrkErrCode & | operator= (const TrkErrCode &) |
void | print (std::ostream &ostr) const |
void | print (std::ostream &ostr) const |
void | setFailure (int i, const char *str=0) |
void | setFailure (int i, const char *str=0) |
void | setMessage (const char *str=0) |
void | setMessage (const char *str=0) |
void | setSuccess (int i, const char *str=0) |
void | setSuccess (int i, const char *str=0) |
int | success () const |
int | success () const |
TrkErrCode (const TrkErrCode &) | |
TrkErrCode (TrkSuccess=succeed, int code=1, const char *str=0) | |
TrkErrCode (const TrkErrCode &) | |
TrkErrCode (TrkSuccess=succeed, int code=1, const char *str=0) | |
~TrkErrCode () | |
~TrkErrCode () | |
Private Attributes | |
int | _failure |
std::string * | _string |
std::string * | _string |
int | _success |
Static Private Attributes | |
std::string | _nullStr |
|
00051 {fail,succeed};
|
|
00051 {fail,succeed};
|
|
00024 : _string(0) 00025 { 00026 setMessage(str); 00027 if (succ) { 00028 _failure = 0; _success = code; 00029 } else { 00030 _success = 0; _failure = code; 00031 } 00032 }
|
|
|
|
00036 : _failure(theCode._failure) 00037 , _success(theCode._success) 00038 { 00039 if (theCode._string != 0) { 00040 _string = new std::string(*theCode._string); 00041 } 00042 else { 00043 _string = 0; 00044 } 00045 }
|
|
|
|
|
|
|
|
00061 {return _failure;}
|
|
00061 {return _failure;}
|
|
|
|
|
|
|
|
00057 { 00058 _failure = theCode._failure; 00059 _success = theCode._success; 00060 00061 if (theCode._string != 0) { 00062 if (_string != 0) { 00063 *_string = *theCode._string; 00064 } 00065 else { 00066 _string = new std::string(*theCode._string); 00067 } 00068 } 00069 else { 00070 if (_string != 0) delete _string; 00071 _string = 0; 00072 } 00073 00074 return *this; 00075 }
|
|
|
|
00080 { 00081 const char* pstatus = 0; 00082 int code; 00083 if (success()) { 00084 pstatus = "succeeded"; 00085 code = success(); 00086 } else { 00087 pstatus = "failed"; 00088 code = failure(); 00089 } 00090 std::string pstring; 00091 static const std::string failed[4] = { "Arithmetic error.", 00092 "Failed to converge.", 00093 "Failed because parallel.", 00094 "Undefined error." }; 00095 00096 static const std::string succeeded[4] = { "Normal completion.", 00097 "Didn't converge.", 00098 "Parallel.", 00099 "Undefined success state."}; 00100 00101 if (code > 0 && code < 10) { 00102 if (failure()) { 00103 pstring = failed[std::min(code-1,3) ]; 00104 } else if (success()) { 00105 pstring = succeeded[std::min(code-1,3) ]; 00106 } 00107 } else if (_string == 0 ) { 00108 pstring = "Unknown error."; 00109 } else { 00110 pstring = *_string; 00111 } 00112 00113 ostr << "TrkErrCode: " << pstatus << ", code " << code 00114 << ". Status: " << pstring.c_str(); 00115 }
|
|
00080 { 00081 setMessage(str); 00082 _failure=(i==0?1:i); _success=0; 00083 }
|
|
00080 { 00081 setMessage(str); 00082 _failure=(i==0?1:i); _success=0; 00083 }
|
|
00070 { 00071 if (_string != 0) delete _string; 00072 if (str != 0) { 00073 _string= new std::string(str); 00074 } 00075 else { 00076 _string = 0; 00077 } 00078 }
|
|
00070 { 00071 if (_string != 0) delete _string; 00072 if (str != 0) { 00073 _string= new std::string(str); 00074 } 00075 else { 00076 _string = 0; 00077 } 00078 }
|
|
00084 { 00085 setMessage(str); 00086 _success=(i==0?1:i); _failure=0; 00087 }
|
|
00084 { 00085 setMessage(str); 00086 _success=(i==0?1:i); _failure=0; 00087 }
|
|
00062 {return _success;}
|
|
00062 {return _success;}
|
|
|
|
|
|
|
|
|
|
|