00001
00010 #ifndef _Q_ERR_HH_
00011 #define _Q_ERR_HH_
00012
00013 #include <iostream>
00014 #include <string>
00015 #include <map>
00016
00017 #include "QCuore.hh"
00018
00022 enum QError_ {
00023
00024
00025 QERR_SUCCESS,
00026 QERR_OUT_OF_RANGE,
00027 QERR_OVERFLOW ,
00028 QERR_UNDERFLOW ,
00029 QERR_SIZE_NOT_MATCH,
00030 QERR_FILE_NOT_FOUND,
00031 QERR_CANNOT_OPEN_FILE,
00032 QERR_UNDEFINED_NUMBER,
00033 QERR_TYPE_CONVERSION,
00034 QERR_GSL_ERROR,
00035
00036
00037
00038 QERR_UNDEFINED_LG,
00039 QERR_UNDEFINED_ID,
00040 QERR_UNDEFINED_TYPE,
00041 QERR_UNDEFINED_STATUS,
00042 QERR_UNDEFINED_PARAMETER,
00043 QERR_UNDEFINED_COMMAND,
00044 QERR_UNDEFINED_DEVICE,
00045 QERR_UNDEFINED_INTERFACE,
00046 QERR_UNDEFINED_TARGET,
00047
00048
00049 QERR_UNDEFINED_MODE,
00050 QERR_UNDEFINED_BASKET,
00051 QERR_UNDEFINED_CRATE,
00052 QERR_UNDEFINED_BOARD,
00053 QERR_UNDEFINED_CHANNEL,
00054
00055
00056 QERR_ELE_UNDEFINED_REGISTER,
00057 QERR_ELE_GENERIC_ERR,
00058 QERR_ELE_NO_ACKNOLDGEMENT,
00059 QERR_ELE_FE_WRITE,
00060 QERR_ELE_BACKPLANE_WRITE,
00061 QERR_ELE_BESSEL_WRITE,
00062 QERR_ELE_PULSER_ATT_WRITE,
00063 QERR_ELE_PULSER_STATUS_WRITE,
00064 QERR_ELE_FE_READ,
00065 QERR_ELE_BACKPLANE_READ,
00066 QERR_ELE_BESSEL_READ,
00067 QERR_ELE_PULSER_ATT_READ,
00068 QERR_ELE_PULSER_STATUS_READ,
00069
00070
00071 QERR_VME_OPEN,
00072 QERR_VME_WRITE,
00073 QERR_VME_READ,
00074
00075
00076 QERR_GPIB_GENERAL,
00077
00078
00079 QERR_NET_UNKNOWN_HOST,
00080 QERR_NET_CONNECTION_FAILED,
00081 QERR_NET_IO_FAILED,
00082 QERR_NET_WRITE_FAILED,
00083 QERR_NET_READ_FAILED,
00084 QERR_NET_PROTOCOL,
00085
00086
00087 QERR_SHMEM_INVALID_INDEX,
00088 QERR_SHMEM_INVALID_ID,
00089
00090
00091 QERR_DB_INCONSISTENCY,
00092 QERR_DB_CONN_FAILED,
00093 QERR_DB_QUERY_FAILED,
00094 QERR_DB_NULL_RESULT,
00095 QERR_DB_MAXLINES_EXCEEDED,
00096
00097
00098 QERR_UNKNOWN_ERR,
00099 QERR_NOT_IMPLEMENTED
00100 };
00101
00105 class QError {
00106
00107 public:
00109 QError();
00110
00112 QError(QError_ err);
00113
00115 QError(QError_ err, const std::string& descr);
00116
00118 QError(QError_ err, const std::string& file, const int line, const std::string& descr);
00119
00121 QError(const QError& err);
00122
00124 virtual ~QError() {};
00125
00127 const QError& operator = (const QError_ &e);
00128
00130 const QError& operator = (const QError &e);
00131
00133 void SetDescription(const std::string& descr) {fDescr = descr;}
00134
00136 void SetDescription(const std::string& file, const int line, const std::string& descr);
00137
00139 std::string GetDescription() const;
00140
00142 QError_ GetCode() const {return fErr;}
00143
00145 const std::string& ToString() const;
00146
00148 bool operator == (const QError_& e) const {return fErr == e;}
00149
00151 bool operator == (const QError& e) const {return fErr == e.fErr;}
00152
00154 bool operator != (const QError_& e) const {return fErr != e;}
00155
00157 bool operator != (const QError &e) const {return fErr != e.fErr;}
00158
00160 void Set(QError_ e=QERR_SUCCESS, const std::string &descr="");
00161
00162 void Set(QError_ e, const std::string& file, const int line, const std::string &descr = "");
00163
00164
00165 private:
00166
00168 QError_ fErr;
00169
00171 std::string fDescr;
00172
00174 std::string fFile;
00175
00177 int fLine;
00178
00180 static void Init();
00181
00183 static std::map<QError_, std::string> fMap;
00184
00186 friend std::ostream& operator<<(std::ostream &s , const QError &err);
00187
00188 };
00189
00191 std::ostream& operator<<(std::ostream &s , const QError &err);
00192
00193 #endif