Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef __DIAGNOSTICS_H_
00019 #define __DIAGNOSTICS_H_
00020
00021 #include <chrono>
00022 #include <deque>
00023
00033 class ErrorcodeReport
00034 {
00035 public:
00036 bool Code_Exists;
00037 int ErrorCode;
00038 std::string Errorcode_Namespace;
00039
00041 ErrorcodeReport() : Code_Exists(false), ErrorCode(0), Errorcode_Namespace(""){};
00042 };
00043
00051 class DiagnosticStatus
00052 {
00053 public:
00054 short Level;
00055 std::string Message;
00056 std::string Recommendation;
00057 ErrorcodeReport Errorcode_Report;
00058
00059 std::chrono::time_point<std::chrono::system_clock> Time;
00060
00062 DiagnosticStatus() : Level(0), Message(""), Recommendation(""), Time(std::chrono::system_clock::now()){};
00063 };
00064
00072 class Diagnosics
00073 {
00074
00075
00076
00077
00078
00079 public:
00081 Diagnosics()
00082 {
00083 m_StatusQueLength = 5;
00084
00085
00086 m_StatusList = new std::deque<DiagnosticStatus>[m_StatusQueLength];
00087
00088
00089 m_Default_Ok_Value = 0;
00090
00091
00092 }
00093
00095 ~Diagnosics()
00096 {
00097 delete m_StatusList;
00098 };
00099
00100
00101
00102
00103
00105
00109 void ReportStatus(short Level, std::string Message)
00110 {
00111 DiagnosticStatus NewStatus;
00112
00113 NewStatus.Level = Level;
00114 NewStatus.Time = std::chrono::system_clock::now();
00115 NewStatus.Message = Message;
00116
00117 m_StatusList->push_front(NewStatus);
00118 m_StatusList->pop_back();
00119 }
00120
00124 void ReportStatus(short Level, std::string Message, std::string Recommendation)
00125 {
00126 DiagnosticStatus NewStatus;
00127
00128 NewStatus.Level = Level;
00129 NewStatus.Time = std::chrono::system_clock::now();
00130 NewStatus.Message = Message;
00131 NewStatus.Message = Recommendation;
00132
00133 m_StatusList->push_front(NewStatus);
00134 m_StatusList->pop_back();
00135 }
00136
00140 void ReportStatus(short Level, int Errorcode, std::string Errorcode_Namespace, std::string Recommendation)
00141 {
00142 DiagnosticStatus NewStatus;
00143
00144 NewStatus.Level = Level;
00145 NewStatus.Time = std::chrono::system_clock::now();
00146
00147
00148
00149 NewStatus.Message = Recommendation;
00150
00151 m_StatusList->push_front(NewStatus);
00152 m_StatusList->pop_back();
00153 }
00154
00158 void ReportStatus(int Errorcode, std::string Errorcode_Namespace)
00159 {
00160 DiagnosticStatus NewStatus;
00161
00162
00163
00164 NewStatus.Time = std::chrono::system_clock::now();
00165
00166 m_StatusList->push_front(NewStatus);
00167 m_StatusList->pop_back();
00168 }
00169
00171
00177 void ReadActualStatus(short* Level, std::string* Message, std::string* Recommendation)
00178 {
00179 DiagnosticStatus ActualStatus = m_StatusList->at(0);
00180
00181
00182 Message->clear();
00183 Recommendation->clear();
00184
00185
00186 Level = (short*)ActualStatus.Level;
00187 Message->append(ActualStatus.Message);
00188 Recommendation->append(ActualStatus.Recommendation);
00189 }
00190
00194 int ReadActualStatusLevel()
00195 {
00196 DiagnosticStatus ActualStatus = m_StatusList->at(0);
00197 return ActualStatus.Level;
00198 }
00199
00203 std::string ReadActualStatusMessage()
00204 {
00205 DiagnosticStatus ActualStatus = m_StatusList->at(0);
00206 return ActualStatus.Message;
00207 }
00208
00212 std::string ReadActualStatusRecommendation()
00213 {
00214 DiagnosticStatus ActualStatus = m_StatusList->at(0);
00215 return ActualStatus.Recommendation;
00216 }
00217
00218
00219
00220
00221
00223
00227 int GetActualStatusQueLength()
00228 {
00229 return m_StatusQueLength;
00230 }
00231
00235 void SetMaxStatusQueLength(int StatusQueLength)
00236 {
00237 m_StatusQueLength = StatusQueLength;
00238 }
00239
00243 int GetMaxStatusQueLength()
00244 {
00245 return m_StatusQueLength;
00246 }
00247
00249
00253 int GetDefaultOKValue()
00254 {
00255 return m_Default_Ok_Value = 0;
00256 }
00257
00261 void SetDefaultOKValue(int Default_Ok_Value)
00262 {
00263 m_Default_Ok_Value = Default_Ok_Value;
00264 }
00265
00266 private:
00267 std::deque<DiagnosticStatus>* m_StatusList;
00268
00269 int m_StatusQueLength;
00270 int m_Default_Ok_Value;
00271
00272 };
00273
00274 #endif