This class is used to track the status results of some methods in the BAM classes. More...
#include <StatGenStatus.h>
Public Types | |
enum | Status { SUCCESS = 0, UNKNOWN, NO_MORE_RECS, FAIL_IO, FAIL_ORDER, FAIL_PARSE, INVALID_SORT, INVALID, FAIL_MEM } |
Return value enum for StatGenFile methods. More... | |
Public Member Functions | |
StatGenStatus (ErrorHandler::HandlingType handleType=ErrorHandler::EXCEPTION) | |
Constructor that takes in the handling type, defaulting it to exception. | |
~StatGenStatus () | |
Destructor. | |
void | reset () |
Reset this status to a default state. | |
void | setHandlingType (ErrorHandler::HandlingType handleType) |
Set how to handle the errors when they are set. | |
void | setStatus (Status newStatus, const char *newMessage) |
Set the status with the specified status enum and message. | |
void | addError (Status newStatus, const char *newMessage) |
Add the specified error message to the status message, setting the status to newStatus if the current status is SUCCESS. | |
void | addError (StatGenStatus newStatus) |
Add the specified status to the status message, setting the status to newStatus if the current status is SUCCESS. | |
Status | getStatus () const |
Return the enum for this status object. | |
const char * | getStatusMessage () const |
Return the status message for this object. | |
StatGenStatus & | operator= (Status newStatus) |
Overload operator = to set the StatGen status type to the passed in status and to clear the message string. | |
StatGenStatus & | operator= (StatGenStatus newStatus) |
Overload operator = to copy the specified status object to this one. | |
bool | operator!= (const StatGenStatus::Status &compStatus) const |
Overload operator != to determine if the passed in type is not equal to this status's type. | |
bool | operator== (const StatGenStatus::Status &compStatus) const |
Overload operator == to determine if the passed in type is equal to this status's type. | |
Static Public Member Functions | |
static const char * | getStatusString (StatGenStatus::Status statusEnum) |
Return a string representation of the passed in status enum. | |
static bool | isContinuableStatus (StatGenStatus::Status status) |
Returns whether or not it is "safe" to keep processing the file after the specified status return. |
This class is used to track the status results of some methods in the BAM classes.
It contains a status enum that describing the status.
Definition at line 26 of file StatGenStatus.h.
Return value enum for StatGenFile methods.
Definition at line 31 of file StatGenStatus.h.
00032 { SUCCESS = 0, ///< method completed successfully. 00033 UNKNOWN, ///< unknown result (default value should never be used) 00034 /// NO_MORE_RECS: failed to read a record since there are no more to 00035 /// read either in the file or section if section based reading. 00036 NO_MORE_RECS, 00037 FAIL_IO, ///< method failed due to an I/O issue. 00038 /// FAIL_ORDER: method failed because it was called out of order, 00039 /// like trying to read a file without opening it for read or trying 00040 /// to read a record before the header. 00041 FAIL_ORDER, 00042 FAIL_PARSE, ///< failed to parse a record/header - invalid format. 00043 INVALID_SORT, ///< record is invalid due to it not being sorted. 00044 INVALID, ///< invalid other than for sorting. 00045 FAIL_MEM ///< fail a memory allocation. 00046 };
void StatGenStatus::addError | ( | StatGenStatus | newStatus | ) |
Add the specified status to the status message, setting the status to newStatus if the current status is SUCCESS.
Definition at line 122 of file StatGenStatus.cpp.
References SUCCESS.
00123 { 00124 if(myType == StatGenStatus::SUCCESS) 00125 { 00126 myType = newStatus.myType; 00127 } 00128 else 00129 { 00130 myMessage += "\n"; 00131 } 00132 myMessage += newStatus.myMessage; 00133 00134 if(newStatus != SUCCESS) 00135 { 00136 handleError(newStatus.myType, newStatus.myMessage.c_str()); 00137 } 00138 }
void StatGenStatus::addError | ( | Status | newStatus, | |
const char * | newMessage | |||
) |
Add the specified error message to the status message, setting the status to newStatus if the current status is SUCCESS.
Definition at line 99 of file StatGenStatus.cpp.
References getStatusString(), and SUCCESS.
00100 { 00101 if(myType == StatGenStatus::SUCCESS) 00102 { 00103 myType = newStatus; 00104 } 00105 else 00106 { 00107 myMessage += "\n"; 00108 } 00109 myMessage += getStatusString(newStatus); 00110 myMessage += ": "; 00111 myMessage += newMessage; 00112 00113 if(newStatus != SUCCESS) 00114 { 00115 handleError(newStatus, newMessage); 00116 } 00117 }
bool StatGenStatus::isContinuableStatus | ( | StatGenStatus::Status | status | ) | [static] |
Returns whether or not it is "safe" to keep processing the file after the specified status return.
Definition at line 41 of file StatGenStatus.cpp.
References FAIL_PARSE, INVALID, INVALID_SORT, and SUCCESS.
00042 { 00043 if(status == StatGenStatus::SUCCESS || status == StatGenStatus::FAIL_PARSE || 00044 status == StatGenStatus::INVALID_SORT || status == StatGenStatus::INVALID) 00045 { 00046 // The status is such that file processing can continue. 00047 return(true); 00048 } 00049 // UNKNOWN, NO_MORE_RECS, FAIL_IO, FAIL_ORDER, FAIL_MEM 00050 return(false); 00051 }
bool StatGenStatus::operator!= | ( | const StatGenStatus::Status & | compStatus | ) | const |
Overload operator != to determine if the passed in type is not equal to this status's type.
Definition at line 182 of file StatGenStatus.cpp.
StatGenStatus & StatGenStatus::operator= | ( | StatGenStatus::Status | newStatus | ) |
Overload operator = to set the StatGen status type to the passed in status and to clear the message string.
Definition at line 157 of file StatGenStatus.cpp.
References SUCCESS.
00158 { 00159 myType = newStatus; 00160 myMessage.clear(); 00161 00162 if(newStatus != SUCCESS) 00163 { 00164 handleError(newStatus, ""); 00165 } 00166 return(*this); 00167 }
bool StatGenStatus::operator== | ( | const StatGenStatus::Status & | compStatus | ) | const |
Overload operator == to determine if the passed in type is equal to this status's type.
Definition at line 190 of file StatGenStatus.cpp.