Go to the documentation of this file.00001 
00060 #ifndef __DIAGNOSTICS_H_
00061 #define __DIAGNOSTICS_H_
00062 
00063 #include <chrono>
00064 #include <deque>
00065 
00075 class ErrorcodeReport                                           
00076 {       
00077         public:
00078         bool Code_Exists;                                               
00079         int ErrorCode;                                                  
00080         std::string Errorcode_Namespace;                
00081         
00083         ErrorcodeReport():
00084                 Code_Exists(false), ErrorCode(0), Errorcode_Namespace("") {};                   
00085 };
00086 
00094 class DiagnosticStatus 
00095 {       
00096         public:
00097         short Level;                                                    
00098         std::string Message;                                    
00099         std::string Recommendation;                             
00100         ErrorcodeReport Errorcode_Report;               
00101 
00102         std::chrono::time_point<std::chrono::system_clock> Time;        
00103         
00105         DiagnosticStatus():
00106                 Level(0), Message(""), Recommendation(""), Time(std::chrono::system_clock::now()) {};
00107 };
00108 
00116 class Diagnosics
00117 {
00118 
00119         
00120 
00121 
00122 
00123 
00124 public:
00125 
00127         Diagnosics()
00128         {       
00129                 m_StatusQueLength = 5;          
00130 
00131                 
00132                 m_StatusList = new std::deque<DiagnosticStatus>[m_StatusQueLength];
00133                 
00134                 
00135                 m_Default_Ok_Value = 0; 
00136 
00137                 
00138                 
00139         }
00140 
00142         ~Diagnosics()
00143         {
00144                 delete m_StatusList; 
00145         };
00146         
00147         
00148 
00149 
00150 
00152         
00156         void ReportStatus(short Level, std::string Message)
00157         {       
00158                 DiagnosticStatus NewStatus; 
00159                 
00160                 NewStatus.Level = Level; 
00161                 NewStatus.Time = std::chrono::system_clock::now();              
00162                 NewStatus.Message = Message;
00163                 
00164                 m_StatusList->push_front(NewStatus); 
00165                 m_StatusList->pop_back();
00166         }
00167         
00171         void ReportStatus(short Level, std::string Message, std::string Recommendation)
00172         {
00173                 DiagnosticStatus NewStatus; 
00174                 
00175                 NewStatus.Level = Level; 
00176                 NewStatus.Time = std::chrono::system_clock::now();              
00177                 NewStatus.Message = Message;
00178                 NewStatus.Message = Recommendation;
00179                 
00180                 m_StatusList->push_front(NewStatus); 
00181                 m_StatusList->pop_back();
00182         }
00183 
00187         void ReportStatus(short Level, int Errorcode, std::string Errorcode_Namespace, std::string Recommendation)
00188         {
00189                 DiagnosticStatus NewStatus; 
00190                 
00191                 NewStatus.Level = Level; 
00192                 NewStatus.Time = std::chrono::system_clock::now(); 
00193                 
00194                 
00195 
00196                 NewStatus.Message = Recommendation;
00197 
00198                 m_StatusList->push_front(NewStatus); 
00199                 m_StatusList->pop_back();
00200         }
00201         
00205         void ReportStatus(int Errorcode, std::string Errorcode_Namespace)
00206         {
00207                 DiagnosticStatus NewStatus; 
00208                 
00209                 
00210 
00211                 NewStatus.Time = std::chrono::system_clock::now(); 
00212 
00213                 m_StatusList->push_front(NewStatus); 
00214                 m_StatusList->pop_back();
00215         }
00216 
00217         
00219 
00225         void ReadActualStatus(short* Level, std::string* Message, std::string* Recommendation)
00226         {
00227                 DiagnosticStatus ActualStatus = m_StatusList->at(0);
00228                 
00229                 
00230                 Message->clear();
00231                 Recommendation->clear(); 
00232                 
00233                 
00234                 Level = (short*) ActualStatus.Level;    
00235                 Message->append(ActualStatus.Message);
00236                 Recommendation->append(ActualStatus.Recommendation);
00237         }
00238 
00242         int ReadActualStatusLevel()
00243         {       
00244                 DiagnosticStatus ActualStatus = m_StatusList->at(0);
00245                 return ActualStatus.Level; 
00246         }
00247 
00251         std::string ReadActualStatusMessage()
00252         {
00253                 DiagnosticStatus ActualStatus = m_StatusList->at(0);
00254                 return ActualStatus.Message;
00255         }
00256 
00260         std::string ReadActualStatusRecommendation()
00261         {
00262                 DiagnosticStatus ActualStatus = m_StatusList->at(0);
00263                 return ActualStatus.Recommendation;
00264         }
00265 
00266         
00267 
00268 
00269  
00271         
00275         int GetActualStatusQueLength()
00276         {
00277                 return m_StatusQueLength; 
00278         }
00279 
00283         void SetMaxStatusQueLength(int StatusQueLength)
00284         {
00285                 m_StatusQueLength = StatusQueLength;    
00286         }
00287 
00291         int GetMaxStatusQueLength()
00292         {
00293                 return m_StatusQueLength;
00294         }
00295 
00296 
00298         
00302         int GetDefaultOKValue()
00303         {
00304                 return m_Default_Ok_Value = 0;
00305         }
00306 
00310         void SetDefaultOKValue(int Default_Ok_Value)
00311         {
00312                 m_Default_Ok_Value = Default_Ok_Value;
00313         }
00314 
00315 private:
00316         
00317         std::deque<DiagnosticStatus> *m_StatusList;     
00318 
00319         int m_StatusQueLength;                                          
00320         int m_Default_Ok_Value;                                         
00321                                                                                                 
00322         
00323 };
00324 
00325 #endif