BOSS 6.6.4.p01
BESIII Offline Software System
Loading...
Searching...
No Matches
TrkErrCode Class Reference

#include <TrkErrCode.h>

Public Types

enum  TrkSuccess { fail , succeed }
 

Public Member Functions

 TrkErrCode (TrkSuccess=succeed, int code=1, const char *str=0)
 
 ~TrkErrCode ()
 
 TrkErrCode (const TrkErrCode &)
 
TrkErrCodeoperator= (const TrkErrCode &)
 
int failure () const
 
int success () const
 
const std::string & message () const
 
void print (std::ostream &ostr) const
 
void setMessage (const char *str=0)
 
void setFailure (int i, const char *str=0)
 
void setSuccess (int i, const char *str=0)
 

Detailed Description

Definition at line 48 of file TrkErrCode.h.

Member Enumeration Documentation

◆ TrkSuccess

Enumerator
fail 
succeed 

Definition at line 51 of file TrkErrCode.h.

Constructor & Destructor Documentation

◆ TrkErrCode() [1/2]

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

Definition at line 23 of file TrkErrCode.cxx.

24 : _string(0)
25{
26 setMessage(str);
27 if (succ) {
28 _failure = 0; _success = code;
29 } else {
30 _success = 0; _failure = code;
31 }
32}
void setMessage(const char *str=0)
Definition: TrkErrCode.h:70

◆ ~TrkErrCode()

TrkErrCode::~TrkErrCode ( )

Definition at line 48 of file TrkErrCode.cxx.

48 {
49 if (_string != 0) {
50 delete _string;
51 _string = 0;
52 }
53}

◆ TrkErrCode() [2/2]

TrkErrCode::TrkErrCode ( const TrkErrCode theCode)

Definition at line 35 of file TrkErrCode.cxx.

36 : _failure(theCode._failure)
37 , _success(theCode._success)
38{
39 if (theCode._string != 0) {
40 _string = new std::string(*theCode._string);
41 }
42 else {
43 _string = 0;
44 }
45}

Member Function Documentation

◆ failure()

◆ message()

const std::string & TrkErrCode::message ( ) const
inline

Definition at line 63 of file TrkErrCode.h.

64 {
65 return (_string != 0) ? *_string : _nullStr;
66 }

◆ operator=()

TrkErrCode & TrkErrCode::operator= ( const TrkErrCode theCode)

Definition at line 56 of file TrkErrCode.cxx.

57{
58 _failure = theCode._failure;
59 _success = theCode._success;
60
61 if (theCode._string != 0) {
62 if (_string != 0) {
63 *_string = *theCode._string;
64 }
65 else {
66 _string = new std::string(*theCode._string);
67 }
68 }
69 else {
70 if (_string != 0) delete _string;
71 _string = 0;
72 }
73
74 return *this;
75}

◆ print()

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

Definition at line 79 of file TrkErrCode.cxx.

80{
81 const char* pstatus = 0;
82 int code;
83 if (success()) {
84 pstatus = "succeeded";
85 code = success();
86 } else {
87 pstatus = "failed";
88 code = failure();
89 }
90 std::string pstring;
91 static const std::string failed[4] = { "Arithmetic error.",
92 "Failed to converge.",
93 "Failed because parallel.",
94 "Undefined error." };
95
96 static const std::string succeeded[4] = { "Normal completion.",
97 "Didn't converge.",
98 "Parallel.",
99 "Undefined success state."};
100
101 if (code > 0 && code < 10) {
102 if (failure()) {
103 pstring = failed[std::min(code-1,3) ];
104 } else if (success()) {
105 pstring = succeeded[std::min(code-1,3) ];
106 }
107 } else if (_string == 0 ) {
108 pstring = "Unknown error.";
109 } else {
110 pstring = *_string;
111 }
112
113 ostr << "TrkErrCode: " << pstatus << ", code " << code
114 << ". Status: " << pstring.c_str();
115}
int success() const
Definition: TrkErrCode.h:62
int failure() const
Definition: TrkErrCode.h:61

Referenced by MdcTrackListBase::arbitrateHits(), MdcTrackList::finishCircle(), MdcTrackList::finishHelix(), TrkHelixFitter::fit(), and operator<<().

◆ setFailure()

void TrkErrCode::setFailure ( int  i,
const char *  str = 0 
)
inline

Definition at line 79 of file TrkErrCode.h.

80 {
81 setMessage(str);
82 _failure=(i==0?1:i); _success=0;
83 }

Referenced by TrkHelixFitter::fit(), TrkPocaBase::minimize(), TrkPocaBase::stepToPointPoca(), and TrkPocaXY::TrkPocaXY().

◆ setMessage()

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

Definition at line 70 of file TrkErrCode.h.

70 {
71 if (_string != 0) delete _string;
72 if (str != 0) {
73 _string= new std::string(str);
74 }
75 else {
76 _string = 0;
77 }
78 }

Referenced by setFailure(), setSuccess(), and TrkErrCode().

◆ setSuccess()

void TrkErrCode::setSuccess ( int  i,
const char *  str = 0 
)
inline

Definition at line 84 of file TrkErrCode.h.

84 {
85 setMessage(str);
86 _success=(i==0?1:i); _failure=0;
87 }

Referenced by TrkHelixFitter::fit(), TrkPocaBase::minimize(), TrkPocaBase::stepTowardPoca(), and TrkPocaXY::TrkPocaXY().

◆ success()


The documentation for this class was generated from the following files: