00001
#ifndef _gnExceptionCode_h_
00002
#define _gnExceptionCode_h_
00003
00004
#include "gn/gnDefs.h"
00005
#include <string>
00006
00007 class GNDLLEXPORT gnExceptionCode{
00008
public:
00009 gnExceptionCode(
uint32 code,
const char* name);
00010
boolean operator==(gnExceptionCode& gnec);
00011
boolean operator!=(gnExceptionCode& gnec);
00012 uint32 GetInt(){
return m_code; }
00013 string GetName(){
return m_name; }
00014
private:
00015 gnExceptionCode();
00016
00017 gnExceptionCode(
const gnExceptionCode& gnec);
00018 gnExceptionCode& operator=(gnExceptionCode& gnec);
00019 uint32 m_code;
00020 string m_name;
00021 };
00022
00023
inline
00024 gnExceptionCode::gnExceptionCode(
uint32 code,
const char* name) :
00025 m_code(code), m_name(name)
00026 {}
00027
00028
inline
00029 boolean gnExceptionCode::operator==(gnExceptionCode& gnec){
00030
return m_code == gnec.
m_code;
00031 }
00032
00033
inline
00034 boolean gnExceptionCode::operator!=(gnExceptionCode& gnec){
00035
return m_code != gnec.
m_code;
00036 }
00037
00038
GNDLLEXPORT
00039
uint32&
GetNewExceptionCode();
00040
00041
inline
00042 uint32&
GetNewExceptionCode(){
00043
00044
static uint32 new_code = 0;
00045
00046 new_code++;
00047
return new_code;
00048 };
00049
00050
00051
00052
00053
00054 #define CREATE_EXCEPTION(E_NAME) \
00055
inline \
00056
static gnExceptionCode& E_NAME(){ \
00057
static gnExceptionCode* m_excp = new gnExceptionCode(GetNewExceptionCode(), #E_NAME); \
00058
return *m_excp; \
00059
}
00060
00061
00062
00063
00067
CREATE_EXCEPTION(IndexOutOfBounds)
00071 CREATE_EXCEPTION(SeqIndexOutOfBounds)
00075 CREATE_EXCEPTION(FragmentIndexOutOfBounds)
00079 CREATE_EXCEPTION(ContigIndexOutOfBounds)
00083 CREATE_EXCEPTION(HeaderIndexOutOfBounds)
00087 CREATE_EXCEPTION(SpecIndexOutOfBounds)
00091 CREATE_EXCEPTION(FeatureIndexOutOfBounds)
00095 CREATE_EXCEPTION(FileNotOpened)
00099 CREATE_EXCEPTION(URLNotFound)
00103 CREATE_EXCEPTION(FileUnreadable)
00107 CREATE_EXCEPTION(IOStreamFailed)
00111 CREATE_EXCEPTION(NullPointer)
00112
00113
00114 #endif