Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

TrkErrCode Class Reference

#include <TrkErrCode.h>

List of all members.

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
TrkErrCodeoperator= (const TrkErrCode &)
TrkErrCodeoperator= (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


Member Enumeration Documentation

enum TrkErrCode::TrkSuccess
 

Enumeration values:
fail 
succeed 
00051 {fail,succeed};

enum TrkErrCode::TrkSuccess
 

Enumeration values:
fail 
succeed 
00051 {fail,succeed};


Constructor & Destructor Documentation

TrkErrCode::TrkErrCode TrkSuccess  = succeed,
int  code = 1,
const char *  str = 0
 

00024   : _string(0)
00025 {
00026   setMessage(str);
00027   if (succ) {
00028     _failure = 0; _success = code;
00029   } else {
00030     _success = 0; _failure = code;
00031   }
00032 }

TrkErrCode::~TrkErrCode  ) 
 

00048                         {
00049   if (_string != 0) {
00050     delete _string;
00051     _string = 0;
00052   }
00053 }

TrkErrCode::TrkErrCode const TrkErrCode  ) 
 

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 }

TrkErrCode::TrkErrCode TrkSuccess  = succeed,
int  code = 1,
const char *  str = 0
 

TrkErrCode::~TrkErrCode  ) 
 

TrkErrCode::TrkErrCode const TrkErrCode  ) 
 


Member Function Documentation

int TrkErrCode::failure  )  const [inline]
 

00061 {return _failure;}

int TrkErrCode::failure  )  const [inline]
 

00061 {return _failure;}

const std::string& TrkErrCode::message  )  const [inline]
 

00064   {
00065     return (_string != 0) ? *_string : _nullStr; 
00066   }

const std::string& TrkErrCode::message  )  const [inline]
 

00064   {
00065     return (_string != 0) ? *_string : _nullStr; 
00066   }

TrkErrCode& TrkErrCode::operator= const TrkErrCode  ) 
 

TrkErrCode & TrkErrCode::operator= const TrkErrCode  ) 
 

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 }

void TrkErrCode::print std::ostream ostr  )  const
 

void TrkErrCode::print std::ostream ostr  )  const
 

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 }

void TrkErrCode::setFailure int  i,
const char *  str = 0
[inline]
 

00080   {
00081     setMessage(str);
00082     _failure=(i==0?1:i); _success=0;
00083   }

void TrkErrCode::setFailure int  i,
const char *  str = 0
[inline]
 

00080   {
00081     setMessage(str);
00082     _failure=(i==0?1:i); _success=0;
00083   }

void TrkErrCode::setMessage const char *  str = 0  )  [inline]
 

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   }

void TrkErrCode::setMessage const char *  str = 0  )  [inline]
 

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   }

void TrkErrCode::setSuccess int  i,
const char *  str = 0
[inline]
 

00084                                               {
00085     setMessage(str);
00086     _success=(i==0?1:i); _failure=0;
00087   }

void TrkErrCode::setSuccess int  i,
const char *  str = 0
[inline]
 

00084                                               {
00085     setMessage(str);
00086     _success=(i==0?1:i); _failure=0;
00087   }

int TrkErrCode::success  )  const [inline]
 

00062 {return _success;}

int TrkErrCode::success  )  const [inline]
 

00062 {return _success;}


Member Data Documentation

int TrkErrCode::_failure [private]
 

std::string TrkErrCode::_nullStr [static, private]
 

std::string* TrkErrCode::_string [private]
 

std::string* TrkErrCode::_string [private]
 

int TrkErrCode::_success [private]
 


The documentation for this class was generated from the following files:
Generated on Wed Feb 2 19:06:47 2011 for BOSS6.5.5 by  doxygen 1.3.9.1