Loading...
Searching...
No Matches
StatGenStatus Class Reference

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.

## Detailed Description

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.

## Member Enumeration Documentation

## Status

enum StatGenStatus::Status

Return value enum for StatGenFile methods.

Enumerator
SUCCESS | method completed successfully.
UNKNOWN | unknown result (default value should never be used)
NO_MORE_RECS | NO_MORE_RECS: failed to read a record since there are no more to read either in the file or section if section based reading.
FAIL_IO | method failed due to an I/O issue.
FAIL_ORDER | FAIL_ORDER: method failed because it was called out of order, like trying to read a file without opening it for read or trying to read a record before the header.
FAIL_PARSE | failed to parse a record/header - invalid format.
INVALID_SORT | record is invalid due to it not being sorted.
INVALID | invalid other than for sorting.
FAIL_MEM | fail a memory allocation.

Definition at line 31 of file StatGenStatus.h.

{ SUCCESS = 0, ///< method completed successfully.
UNKNOWN, ///< unknown result (default value should never be used)
/// NO_MORE_RECS: failed to read a record since there are no more to
/// read either in the file or section if section based reading.
NO_MORE_RECS,
FAIL_IO, ///< method failed due to an I/O issue.
/// FAIL_ORDER: method failed because it was called out of order,
/// like trying to read a file without opening it for read or trying
/// to read a record before the header.
FAIL_ORDER,
FAIL_PARSE, ///< failed to parse a record/header - invalid format.
INVALID_SORT, ///< record is invalid due to it not being sorted.
INVALID, ///< invalid other than for sorting.
FAIL_MEM ///< fail a memory allocation.
};
StatGenStatus::UNKNOWN
@ UNKNOWN
unknown result (default value should never be used)
Definition StatGenStatus.h:33
StatGenStatus::FAIL_MEM
@ FAIL_MEM
fail a memory allocation.
Definition StatGenStatus.h:45
StatGenStatus::NO_MORE_RECS
@ NO_MORE_RECS
NO_MORE_RECS: failed to read a record since there are no more to read either in the file or section i...
Definition StatGenStatus.h:36
StatGenStatus::SUCCESS
@ SUCCESS
method completed successfully.
Definition StatGenStatus.h:32
StatGenStatus::FAIL_IO
@ FAIL_IO
method failed due to an I/O issue.
Definition StatGenStatus.h:37
StatGenStatus::INVALID
@ INVALID
invalid other than for sorting.
Definition StatGenStatus.h:44
StatGenStatus::INVALID_SORT
@ INVALID_SORT
record is invalid due to it not being sorted.
Definition StatGenStatus.h:43
StatGenStatus::FAIL_PARSE
@ FAIL_PARSE
failed to parse a record/header - invalid format.
Definition StatGenStatus.h:42
StatGenStatus::FAIL_ORDER
@ FAIL_ORDER
FAIL_ORDER: method failed because it was called out of order, like trying to read a file without open...
Definition StatGenStatus.h:41

## Constructor & Destructor Documentation

## StatGenStatus()

StatGenStatus::StatGenStatus | ( | ErrorHandler::HandlingType | handleType = `ErrorHandler::EXCEPTION` | ) |

Constructor that takes in the handling type, defaulting it to exception.

Definition at line 55 of file StatGenStatus.cpp.

: myHandlingType(handleType)
{
reset();
}
StatGenStatus::reset
void reset()
Reset this status to a default state.
Definition StatGenStatus.cpp:69

References reset().

## ~StatGenStatus()

StatGenStatus::~StatGenStatus | ( |  | ) |

Destructor.

Definition at line 63 of file StatGenStatus.cpp.

{
}

## Member Function Documentation

## addError() [1/2]

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.

{
if(myType == StatGenStatus::SUCCESS)
{
myType = newStatus.myType;
}
else
{
myMessage += "\n";
}
myMessage += newStatus.myMessage;
if(newStatus != SUCCESS)
{
handleError(newStatus.myType, newStatus.myMessage.c_str());
}
}

References SUCCESS.

## addError() [2/2]

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.

{
if(myType == StatGenStatus::SUCCESS)
{
myType = newStatus;
}
else
{
myMessage += "\n";
}
myMessage += getStatusString(newStatus);
myMessage += ": ";
myMessage += newMessage;
if(newStatus != SUCCESS)
{
handleError(newStatus, newMessage);
}
}
StatGenStatus::getStatusString
static const char * getStatusString(StatGenStatus::Status statusEnum)
Return a string representation of the passed in status enum.
Definition StatGenStatus.cpp:33

References getStatusString(), and SUCCESS.

## getStatus()

StatGenStatus::Status StatGenStatus::getStatus | ( |  | ) | const

Return the enum for this status object.

Definition at line 142 of file StatGenStatus.cpp.

{
return(myType);
}

Referenced by SamFile::GetStatus(), and SamRecord::writeRecordBuffer().

## getStatusMessage()

const char * StatGenStatus::getStatusMessage | ( |  | ) | const

Return the status message for this object.

Definition at line 149 of file StatGenStatus.cpp.

{
return(myMessage.c_str());
}

Referenced by SamFile::GetStatusMessage().

## getStatusString()

const char * StatGenStatus::getStatusString | ( | StatGenStatus::Status | statusEnum | ) |

static

Return a string representation of the passed in status enum.

Definition at line 33 of file StatGenStatus.cpp.

{
return(enumStatusString[statusEnum]);
}

Referenced by addError(), and setStatus().

## isContinuableStatus()

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.

{
if(status == StatGenStatus::SUCCESS || status == StatGenStatus::FAIL_PARSE ||
status == StatGenStatus::INVALID_SORT || status == StatGenStatus::INVALID)
{
// The status is such that file processing can continue.
return(true);
}
// UNKNOWN, NO_MORE_RECS, FAIL_IO, FAIL_ORDER, FAIL_MEM
return(false);
}

References FAIL_PARSE, INVALID, INVALID_SORT, and SUCCESS.

## operator!=()

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.

{
return(compStatus != myType);
}

## operator=() [1/2]

StatGenStatus & StatGenStatus::operator= | ( | StatGenStatus | newStatus | ) |

Overload operator = to copy the specified status object to this one.

Definition at line 171 of file StatGenStatus.cpp.

{
myType = newStatus.myType;
myMessage = newStatus.myMessage;
myHandlingType = newStatus.myHandlingType;
return(*this);
}

## operator=() [2/2]

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.

{
myType = newStatus;
myMessage.clear();
if(newStatus != SUCCESS)
{
handleError(newStatus, "");
}
return(*this);
}

References SUCCESS.

## operator==()

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.

{
return(compStatus == myType);
}

## reset()

void StatGenStatus::reset | ( |  | ) |

Reset this status to a default state.

Definition at line 69 of file StatGenStatus.cpp.

{
myType = UNKNOWN;
myMessage.clear();
}

References UNKNOWN.

Referenced by StatGenStatus().

## setHandlingType()

void StatGenStatus::setHandlingType | ( | ErrorHandler::HandlingType | handleType | ) |

Set how to handle the errors when they are set.

Definition at line 76 of file StatGenStatus.cpp.

{
myHandlingType = handleType;
}

## setStatus()

void StatGenStatus::setStatus | ( | Status | newStatus,
|  | const char * | newMessage
| ) |  |

Set the status with the specified status enum and message.

Definition at line 83 of file StatGenStatus.cpp.

{
myType = newStatus;
myMessage = getStatusString(newStatus);
myMessage += ": ";
myMessage += newMessage;
if(newStatus != SUCCESS)
{
handleError(newStatus, newMessage);
}
}

References getStatusString(), and SUCCESS.

Referenced by SamRecord::addIntTag(), SamRecord::addTag(), SamRecord::getNextSamTag(), SamFile::getNumMappedReadsFromIndex(), SamFile::getNumMappedReadsFromIndex(), SamFile::getNumUnMappedReadsFromIndex(), SamFile::getNumUnMappedReadsFromIndex(), SamRecord::getTagsString(), SamRecord::isValid(), SamFile::OpenForRead(), SamFile::OpenForWrite(), SamFile::ReadBamIndex(), SamFile::ReadBamIndex(), SamFile::ReadHeader(), SamFile::ReadRecord(), SamRecord::rmTag(), SamRecord::rmTags(), SamRecord::setBuffer(), SamRecord::setBufferFromFile(), SamRecord::setReadName(), SamFile::SetReadSection(), SamFile::SetReadSection(), SamFile::validateSortOrder(), SamFile::WriteHeader(), SamFile::WriteRecord(), and SamRecord::writeRecordBuffer().

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

- general/StatGenStatus.h
- general/StatGenStatus.cpp