OpenVSP API Documentation 3.52.0
Loading...
Searching...
No Matches
APIErrorMgr.h
1//
2// This file is released under the terms of the NASA Open Source Agreement (NOSA)
3// version 1.3 as detailed in the LICENSE file which accompanies this software.
4//
5
6// API.h: interface for the Vehicle Class and Vehicle Mgr Singleton.
7// J.R Gloudemans
8//
10
11#if !defined(APIERRORMGR__INCLUDED_)
12#define APIERRORMGR__INCLUDED_
13
14#include "APIDefines.h"
15#include "MessageMgr.h"
16
17#include <string>
18#include <stack>
19#include <vector>
20
21using std::string;
22using std::stack;
23using std::vector;
24
25class Vehicle;
26
27namespace vsp
28{
29
30
31//======================== Error Object ================================//
38class ErrorObj
39{
40public:
46 ErrorObj();
51 ErrorObj( ERROR_CODE err_code, const string & err_str );
56 ErrorObj( const ErrorObj& from );
57 ~ErrorObj() {}
58
106
108
109 {
110 return m_ErrorCode;
111 }
112
152
154
155 {
156 return m_ErrorString;
157 }
158
159 ERROR_CODE m_ErrorCode;
160 string m_ErrorString;
161
166 void NoError()
167 {
168 m_ErrorCode = VSP_OK;
169 m_ErrorString = "No Error";
170 }
171};
172
173
174//======================== Error Mgr ================================//
184class ErrorMgrSingleton : public MessageBase
185{
186public:
187
226
227 bool GetErrorLastCallFlag(); // Did the last call have an error?
228
269
270 int GetNumTotalErrors(); // Total number of errors on stack
271
322
323 ErrorObj PopLastError(); // Pop last error off stack
324
376
377 ErrorObj GetLastError(); // Get last error but leave on stack
378
384 bool PopErrorAndPrint( FILE* stream );
385
426
427 void SilenceErrors() { m_PrintErrors = false; };
428
467
468 void PrintOnErrors() { m_PrintErrors = true; };
469
470
476 void AddError( ERROR_CODE code, const string & desc );
481 void NoError();
482
488 virtual void MessageCallback( const MessageBase* from, const MessageData& data );
489
514
515 static ErrorMgrSingleton& getInstance()
516 {
517 static ErrorMgrSingleton instance;
518 return instance;
519 }
520
521private:
522
523 bool m_PrintErrors;
524 bool m_ErrorLastCallFlag;
525 stack< ErrorObj > m_ErrorStack;
526
533 ErrorMgrSingleton( ErrorMgrSingleton const& copy ) = delete; // Not Implemented
534 ErrorMgrSingleton& operator=( ErrorMgrSingleton const& copy ) = delete; // Not Implemented
535};
536
537#define ErrorMgr ErrorMgrSingleton::getInstance()
538
539}
540
541#endif // !defined(APIERRORMGR__INCLUDED_)
542
static ErrorMgrSingleton & getInstance()
string GetErrorString()
ERROR_CODE GetErrorCode()
ERROR_CODE
Definition APIDefines.h:508
@ VSP_OK
Definition APIDefines.h:509