OpenVSP API Documentation 3.41.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#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 ================================//
42{
43public:
44 ErrorObj();
45 ErrorObj( ERROR_CODE err_code, const string & err_str );
46 ErrorObj( const ErrorObj& from );
47 ~ErrorObj() {}
48
71
72 {
73 return m_ErrorCode;
74 }
100
101 {
102 return m_ErrorString;
103 }
104
105 ERROR_CODE m_ErrorCode;
106 string m_ErrorString;
107
108 void NoError()
109 {
110 m_ErrorCode = VSP_OK;
111 m_ErrorString = "No Error";
112 }
113};
114
115
116//======================== Error Mgr ================================//
117class ErrorMgrSingleton : public MessageBase
118{
119public:
120
162 bool GetErrorLastCallFlag(); // Did the last call have an error?
163
209 int GetNumTotalErrors(); // Total number of errors on stack
210
256 ErrorObj PopLastError(); // Pop last error off stack
257
302 ErrorObj GetLastError(); // Get last error but leave on stack
303
304 bool PopErrorAndPrint( FILE* stream ); // Check for error, pop and print to stream
305
339 void SilenceErrors() { m_PrintErrors = false; };
340
374 void PrintOnErrors() { m_PrintErrors = true; };
375
376
377 void AddError( ERROR_CODE code, const string & desc );
378 void NoError();
379
380 virtual void MessageCallback( const MessageBase* from, const MessageData& data );
381
382 static ErrorMgrSingleton& getInstance()
383 {
384 static ErrorMgrSingleton instance;
385 return instance;
386 }
387
388private:
389
390 bool m_PrintErrors;
391 bool m_ErrorLastCallFlag;
392 stack< ErrorObj > m_ErrorStack;
393
394 ErrorMgrSingleton();
395 ~ErrorMgrSingleton();
396 ErrorMgrSingleton( ErrorMgrSingleton const& copy ); // Not Implemented
397 ErrorMgrSingleton& operator=( ErrorMgrSingleton const& copy ); // Not Implemented
398};
399
400#define ErrorMgr ErrorMgrSingleton::getInstance()
401
402}
403
404#endif // !defined(APIERRORMGR__INCLUDED_)
405
string GetErrorString()
Definition APIErrorMgr.h:99
ERROR_CODE GetErrorCode()
Definition APIErrorMgr.h:70
ERROR_CODE
Definition APIDefines.h:445
@ VSP_OK
Definition APIDefines.h:445