This class is used to track the status results of some methods in the BAM classes. More...
#include <SamStatus.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 the SamFile class methods. More... | |
Public Member Functions | |
SamStatus (ErrorHandler::HandlingType handleType=ErrorHandler::EXCEPTION) | |
Constructor that takes in the handling type, defaulting it to exception. | |
~SamStatus () | |
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 (SamStatus 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. | |
SamStatus & | operator= (Status newStatus) |
Overload operator = to set the sam status type to the passed in status and to clear the message string. | |
bool | operator!= (const SamStatus::Status &compStatus) const |
Overload operator != to determine if the passed in type is not equal to this status's type. | |
bool | operator== (const SamStatus::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 (SamStatus::Status statusEnum) |
Return a string representation of the passed in status enum. | |
static bool | isContinuableStatus (SamStatus::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 SamStatus.h.
enum SamStatus::Status |
Return value enum for the SamFile class methods.
Definition at line 31 of file SamStatus.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, ///< record is invalid other than for sorting. 00045 FAIL_MEM ///< fail a memory allocation. 00046 };
void SamStatus::addError | ( | SamStatus | 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 SamStatus.cpp.
References SUCCESS.
00123 { 00124 if(myType == SamStatus::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 SamStatus::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 SamStatus.cpp.
References getStatusString(), and SUCCESS.
00100 { 00101 if(myType == SamStatus::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 SamStatus::isContinuableStatus | ( | SamStatus::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 SamStatus.cpp.
References FAIL_PARSE, INVALID, INVALID_SORT, and SUCCESS.
00042 { 00043 if(status == SamStatus::SUCCESS || status == SamStatus::FAIL_PARSE || 00044 status == SamStatus::INVALID_SORT || status == SamStatus::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 SamStatus::operator!= | ( | const SamStatus::Status & | compStatus | ) | const |
Overload operator != to determine if the passed in type is not equal to this status's type.
Definition at line 172 of file SamStatus.cpp.
SamStatus & SamStatus::operator= | ( | SamStatus::Status | newStatus | ) |
Overload operator = to set the sam status type to the passed in status and to clear the message string.
Definition at line 157 of file SamStatus.cpp.
bool SamStatus::operator== | ( | const SamStatus::Status & | compStatus | ) | const |
Overload operator == to determine if the passed in type is equal to this status's type.
Definition at line 180 of file SamStatus.cpp.