OpenVSP API Documentation 3.42.2
 
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#ifdef SWIG
15%feature("autodoc", 1);
16%feature("doxygen:ignore:forcpponly", range="end");
17%feature("doxygen:ignore:beginPythonOnly", range="end:endPythonOnly", contents="parse");
18#endif
19
20#include "APIDefines.h"
21#include "MessageMgr.h"
22
23#include <string>
24#include <stack>
25#include <vector>
26
27using std::string;
28using std::stack;
29using std::vector;
30
31class Vehicle;
32
33namespace vsp
34{
35
36
37//======================== Error Object ================================//
44class ErrorObj
45{
46public:
47 ErrorObj();
48 ErrorObj( ERROR_CODE err_code, const string & err_str );
49 ErrorObj( const ErrorObj& from );
50 ~ErrorObj() {}
51
75
77
78 {
79 return m_ErrorCode;
80 }
81
107
109
110 {
111 return m_ErrorString;
112 }
113
114 ERROR_CODE m_ErrorCode;
115 string m_ErrorString;
116
117 void NoError()
118 {
119 m_ErrorCode = VSP_OK;
120 m_ErrorString = "No Error";
121 }
122};
123
124
125//======================== Error Mgr ================================//
126class ErrorMgrSingleton : public MessageBase
127{
128public:
129
170
171 bool GetErrorLastCallFlag(); // Did the last call have an error?
172
217
218 int GetNumTotalErrors(); // Total number of errors on stack
219
264
265 ErrorObj PopLastError(); // Pop last error off stack
266
310
311 ErrorObj GetLastError(); // Get last error but leave on stack
312
313 bool PopErrorAndPrint( FILE* stream ); // Check for error, pop and print to stream
314
347
348 void SilenceErrors() { m_PrintErrors = false; };
349
382
383 void PrintOnErrors() { m_PrintErrors = true; };
384
385
386 void AddError( ERROR_CODE code, const string & desc );
387 void NoError();
388
389 virtual void MessageCallback( const MessageBase* from, const MessageData& data );
390
391 static ErrorMgrSingleton& getInstance()
392 {
393 static ErrorMgrSingleton instance;
394 return instance;
395 }
396
397private:
398
399 bool m_PrintErrors;
400 bool m_ErrorLastCallFlag;
401 stack< ErrorObj > m_ErrorStack;
402
403 ErrorMgrSingleton();
404 ~ErrorMgrSingleton();
405 ErrorMgrSingleton( ErrorMgrSingleton const& copy ); // Not Implemented
406 ErrorMgrSingleton& operator=( ErrorMgrSingleton const& copy ); // Not Implemented
407};
408
409#define ErrorMgr ErrorMgrSingleton::getInstance()
410
411}
412
413#endif // !defined(APIERRORMGR__INCLUDED_)
414
string GetErrorString()
ERROR_CODE GetErrorCode()
Definition APIErrorMgr.h:76
ERROR_CODE
Definition APIDefines.h:476
@ VSP_OK
Definition APIDefines.h:476