00001 #pragma once
00002 #ifndef TRIGINTERFACES_ENUMS_H
00003 #define TRIGINTERFACES_ENUMS_H
00004
00005 #include <vector>
00006 #include <string>
00007 #include <stdint.h>
00008
00009 namespace HLT {
00010 struct Action {
00011 typedef enum {
00012 CONTINUE = 0,
00013 ABORT_CHAIN = 1,
00014 ABORT_EVENT = 2,
00015 ABORT_JOB = 3,
00016 UNSPECIFIED_ = -1
00017
00018 } Code;
00019 };
00020
00021 struct Reason {
00022 typedef enum {
00023 UNKNOWN=0,
00024 MISSING_FEATURE,
00025 GAUDI_EXCEPTION,
00026 EFORMAT_EXCEPTION,
00027 STD_EXCEPTION,
00028 UNKNOWN_EXCEPTION,
00029 NAV_ERROR,
00030 MISSING_ROD,
00031 CORRUPTED_ROD,
00032 TIMEOUT,
00033 BAD_JOB_SETUP,
00034
00035 USERDEF_1,
00036 USERDEF_2,
00037 USERDEF_3,
00038 USERDEF_4,
00039 LAST_ =0xf,
00040 UNSPECIFIED_ = -1
00041 } Code;
00042 };
00043
00044
00045
00046
00047 struct SteeringInternalReason {
00048 typedef enum {
00049 UNKNOWN=0,
00050 NO_LVL1_ITEMS,
00051 NO_LVL2_CHAINS,
00052 NO_LVL1_RESULT,
00053 WRONG_HLT_RESULT,
00054 NO_HLT_RESULT,
00055 ALGO_ERROR,
00056 TIMEOUT,
00057 BUSY,
00058 BAD_JOB_SETUP,
00059 LAST_,
00060 UNSPECIFIED_ = -1
00061 } Code;
00062 };
00063
00073 class ErrorCode {
00074 public:
00075 ErrorCode();
00076 ErrorCode(Action::Code a);
00077 ErrorCode(Action::Code a, Reason::Code r);
00078
00079
00080 ErrorCode(uint32_t c);
00081 ErrorCode(const ErrorCode c, Reason::Code r);
00082
00083 ErrorCode(Action::Code a, SteeringInternalReason::Code s);
00084 ErrorCode(const ErrorCode c, SteeringInternalReason::Code s);
00085
00086 ErrorCode(Action::Code a, Reason::Code r, SteeringInternalReason::Code s);
00087
00088
00089 bool operator==(const ErrorCode& ec) const;
00090 bool operator!=(const ErrorCode& ec) const;
00091
00092 bool operator<(const ErrorCode& ec) const;
00093 bool operator>(const ErrorCode& ec) const;
00094
00095
00096 operator uint32_t() const {return code;}
00097
00098
00099 Action::Code action() const;
00100 Reason::Code reason() const;
00101 SteeringInternalReason::Code steeringInternalReason() const;
00102
00103 std::string str();
00104
00105 uint32_t code;
00106 };
00107
00108 std::string strErrorCode(const ErrorCode code);
00109
00110
00111
00112
00113 static const ErrorCode OK(Action::CONTINUE);
00114 static const ErrorCode MISSING_FEATURE (Action::CONTINUE, Reason::MISSING_FEATURE);
00115 static const ErrorCode STOP_THIS_CHAIN_ (Action::CONTINUE, Reason::MISSING_FEATURE);
00116
00117 static const ErrorCode ERROR (Action::ABORT_CHAIN, Reason::UNKNOWN);
00118 static const ErrorCode INVALID_TE (Action::ABORT_CHAIN, Reason::UNKNOWN);
00119 static const ErrorCode TOOL_FAILURE (Action::ABORT_CHAIN, Reason::UNKNOWN);
00120 static const ErrorCode NUM_ERROR (Action::ABORT_CHAIN, Reason::UNKNOWN);
00121 static const ErrorCode SG_ERROR (Action::ABORT_CHAIN, Reason::NAV_ERROR);
00122 static const ErrorCode NAV_ERROR (Action::ABORT_CHAIN, Reason::NAV_ERROR);
00123 static const ErrorCode GAUDI_EXCEPTION (Action::ABORT_CHAIN, Reason::GAUDI_EXCEPTION);
00124 static const ErrorCode EFORMAT_EXCEPTION (Action::ABORT_CHAIN, Reason::EFORMAT_EXCEPTION);
00125 static const ErrorCode STD_EXCEPTION (Action::ABORT_CHAIN, Reason::STD_EXCEPTION);
00126 static const ErrorCode UNKNOWN_EXCEPTION (Action::ABORT_CHAIN, Reason::UNKNOWN_EXCEPTION);
00127 static const ErrorCode TIMEOUT (Action::ABORT_EVENT, Reason::TIMEOUT, SteeringInternalReason::TIMEOUT);
00128 static const ErrorCode STOP_EVENT_ (Action::ABORT_EVENT);
00129
00130 static const ErrorCode NO_LVL1_ITEMS (Action::ABORT_EVENT, SteeringInternalReason::NO_LVL1_ITEMS);
00131 static const ErrorCode NO_LVL2_CHAINS (Action::ABORT_EVENT, SteeringInternalReason::NO_LVL2_CHAINS);
00132 static const ErrorCode NO_LVL1_RESULT (Action::ABORT_EVENT, SteeringInternalReason::NO_LVL1_RESULT);
00133 static const ErrorCode WRONG_HLT_RESULT (Action::ABORT_EVENT, SteeringInternalReason::WRONG_HLT_RESULT);
00134 static const ErrorCode NO_HLT_RESULT (Action::ABORT_EVENT, SteeringInternalReason::NO_HLT_RESULT);
00135
00136 static const ErrorCode STOP_JOB_ (Action::ABORT_JOB);
00137 static const ErrorCode BAD_JOB_SETUP (Action::ABORT_JOB, Reason::BAD_JOB_SETUP);
00138 static const ErrorCode BAD_ALGO_CONFIG (Action::ABORT_JOB, Reason::BAD_JOB_SETUP);
00139 static const ErrorCode FATAL (Action::ABORT_JOB, Reason::UNKNOWN);
00140 static const ErrorCode LAST_ERROR (Action::ABORT_JOB, Reason::LAST_, SteeringInternalReason::LAST_);
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162 int getErrorCodePosFromStr(const std::string& ec);
00163
00164 void reportErrorCode(ErrorCode& e1, ErrorCode e2);
00165
00166 enum HLTLevel { L2 = 0, EF, HLT, UNKNOWN };
00167
00168 }
00169
00170
00171
00172
00173 inline HLT::ErrorCode::ErrorCode() { code = 0; }
00174 inline HLT::ErrorCode::ErrorCode(HLT::Action::Code a) { code = a << 4; }
00175 inline HLT::ErrorCode::ErrorCode(HLT::Action::Code a, HLT::Reason::Code r) { code = a << 4; code |= r; }
00176
00177
00178 inline HLT::ErrorCode::ErrorCode(uint32_t c) { code = c; }
00179 inline HLT::ErrorCode::ErrorCode(const HLT::ErrorCode c, HLT::Reason::Code r) { code = c.code; code &= 0x30; code |= r; }
00180
00181 inline HLT::ErrorCode::ErrorCode(HLT::Action::Code a, HLT::SteeringInternalReason::Code s) { code = a << 4; code |= s<<8; }
00182 inline HLT::ErrorCode::ErrorCode(const HLT::ErrorCode c, HLT::SteeringInternalReason::Code s) { code = c.code; code |= s<<8; }
00183
00184 inline HLT::ErrorCode::ErrorCode(HLT::Action::Code a, HLT::Reason::Code r, HLT::SteeringInternalReason::Code s) { code = a << 4; code |= r; code |= s<<8; }
00185
00186
00187 inline bool HLT::ErrorCode::operator==(const HLT::ErrorCode& ec) const { return uint32_t(*this) == uint32_t(ec); }
00188 inline bool HLT::ErrorCode::operator!=(const HLT::ErrorCode& ec) const { return !(*this == ec); }
00189
00190 inline bool HLT::ErrorCode::operator<(const HLT::ErrorCode& ec) const { return uint32_t(*this) < uint32_t(ec); }
00191 inline bool HLT::ErrorCode::operator>(const HLT::ErrorCode& ec) const { return !(*this<ec) && !(*this == ec); }
00192
00193
00194
00195
00196
00197 inline HLT::Action::Code HLT::ErrorCode::action() const { return HLT::Action::Code((code>>4)&0x3); }
00198 inline HLT::Reason::Code HLT::ErrorCode::reason() const { return HLT::Reason::Code(code&0xf); }
00199 inline HLT::SteeringInternalReason::Code HLT::ErrorCode::steeringInternalReason() const { return HLT::SteeringInternalReason::Code(code>>8); }
00200
00201
00202
00203 #endif