libStatGen Software 1
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. More...
 
 ~StatGenStatus ()
 Destructor. More...
 
void reset ()
 Reset this status to a default state. More...
 
void setHandlingType (ErrorHandler::HandlingType handleType)
 Set how to handle the errors when they are set. More...
 
void setStatus (Status newStatus, const char *newMessage)
 Set the status with the specified status enum and message. More...
 
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. More...
 
void addError (StatGenStatus newStatus)
 Add the specified status to the status message, setting the status to newStatus if the current status is SUCCESS. More...
 
Status getStatus () const
 Return the enum for this status object. More...
 
const char * getStatusMessage () const
 Return the status message for this object. More...
 
StatGenStatusoperator= (Status newStatus)
 Overload operator = to set the StatGen status type to the passed in status and to clear the message string. More...
 
StatGenStatusoperator= (StatGenStatus newStatus)
 Overload operator = to copy the specified status object to this one. More...
 
bool operator!= (const StatGenStatus::Status &compStatus) const
 Overload operator != to determine if the passed in type is not equal to this status's type. More...
 
bool operator== (const StatGenStatus::Status &compStatus) const
 Overload operator == to determine if the passed in type is equal to this status's type. More...
 

Static Public Member Functions

static const char * getStatusString (StatGenStatus::Status statusEnum)
 Return a string representation of the passed in status enum. More...
 
static bool isContinuableStatus (StatGenStatus::Status status)
 Returns whether or not it is "safe" to keep processing the file after the specified status return. More...
 

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

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.

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

56 : myHandlingType(handleType)
57{
58 reset();
59}
void reset()
Reset this status to a default state.

References reset().

◆ ~StatGenStatus()

StatGenStatus::~StatGenStatus ( )

Destructor.

Definition at line 63 of file StatGenStatus.cpp.

64{
65}

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.

123{
124 if(myType == StatGenStatus::SUCCESS)
125 {
126 myType = newStatus.myType;
127 }
128 else
129 {
130 myMessage += "\n";
131 }
132 myMessage += newStatus.myMessage;
133
134 if(newStatus != SUCCESS)
135 {
136 handleError(newStatus.myType, newStatus.myMessage.c_str());
137 }
138}

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.

100{
101 if(myType == StatGenStatus::SUCCESS)
102 {
103 myType = newStatus;
104 }
105 else
106 {
107 myMessage += "\n";
108 }
109 myMessage += getStatusString(newStatus);
110 myMessage += ": ";
111 myMessage += newMessage;
112
113 if(newStatus != SUCCESS)
114 {
115 handleError(newStatus, newMessage);
116 }
117}
static const char * getStatusString(StatGenStatus::Status statusEnum)
Return a string representation of the passed in status enum.

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.

143{
144 return(myType);
145}

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.

150{
151 return(myMessage.c_str());
152}

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.

34{
35 return(enumStatusString[statusEnum]);
36}

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.

42{
43 if(status == StatGenStatus::SUCCESS || status == StatGenStatus::FAIL_PARSE ||
45 {
46 // The status is such that file processing can continue.
47 return(true);
48 }
49 // UNKNOWN, NO_MORE_RECS, FAIL_IO, FAIL_ORDER, FAIL_MEM
50 return(false);
51}

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.

183{
184 return(compStatus != myType);
185}

◆ 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.

172{
173 myType = newStatus.myType;
174 myMessage = newStatus.myMessage;
175 myHandlingType = newStatus.myHandlingType;
176 return(*this);
177}

◆ 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.

158{
159 myType = newStatus;
160 myMessage.clear();
161
162 if(newStatus != SUCCESS)
163 {
164 handleError(newStatus, "");
165 }
166 return(*this);
167}

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.

191{
192 return(compStatus == myType);
193}

◆ reset()

void StatGenStatus::reset ( )

Reset this status to a default state.

Definition at line 69 of file StatGenStatus.cpp.

70{
71 myType = UNKNOWN;
72 myMessage.clear();
73}

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.

77{
78 myHandlingType = handleType;
79}

◆ setStatus()

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

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