OpenVSP API Documentation 3.40.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#ifdef SWIG
11%feature("autodoc", 1);
12%feature("doxygen:ignore:forcpponly", range="end");
13%feature("doxygen:ignore:beginPythonOnly", range="end:endPythonOnly", contents="parse");
14#endif
15
16#if !defined(APIERRORMGR__INCLUDED_)
17#define APIERRORMGR__INCLUDED_
18
19#include "APIDefines.h"
20#include "MessageMgr.h"
21
22#include <string>
23#include <stack>
24#include <vector>
25
26using std::string;
27using std::stack;
28using std::vector;
29
30class Vehicle;
31
32namespace vsp
33{
34
35
36//======================== Error Object ================================//
41{
42public:
43 ErrorObj();
44 ErrorObj( ERROR_CODE err_code, const string & err_str );
45 ErrorObj( const ErrorObj& from );
46 ~ErrorObj() {}
47
70
71 {
72 return m_ErrorCode;
73 }
99
100 {
101 return m_ErrorString;
102 }
103
104 ERROR_CODE m_ErrorCode;
105 string m_ErrorString;
106
107 void NoError()
108 {
109 m_ErrorCode = VSP_OK;
110 m_ErrorString = "No Error";
111 }
112};
113
114
115//======================== Error Mgr ================================//
116class ErrorMgrSingleton : public MessageBase
117{
118public:
119
161 bool GetErrorLastCallFlag(); // Did the last call have an error?
162
208 int GetNumTotalErrors(); // Total number of errors on stack
209
255 ErrorObj PopLastError(); // Pop last error off stack
256
301 ErrorObj GetLastError(); // Get last error but leave on stack
302
303 bool PopErrorAndPrint( FILE* stream ); // Check for error, pop and print to stream
304
338 void SilenceErrors() { m_PrintErrors = false; };
339
373 void PrintOnErrors() { m_PrintErrors = true; };
374
375
376 void AddError( ERROR_CODE code, const string & desc );
377 void NoError();
378
379 virtual void MessageCallback( const MessageBase* from, const MessageData& data );
380
381 static ErrorMgrSingleton& getInstance()
382 {
383 static ErrorMgrSingleton instance;
384 return instance;
385 }
386
387private:
388
389 bool m_PrintErrors;
390 bool m_ErrorLastCallFlag;
391 stack< ErrorObj > m_ErrorStack;
392
393 ErrorMgrSingleton();
394 ~ErrorMgrSingleton();
395 ErrorMgrSingleton( ErrorMgrSingleton const& copy ); // Not Implemented
396 ErrorMgrSingleton& operator=( ErrorMgrSingleton const& copy ); // Not Implemented
397};
398
399#define ErrorMgr ErrorMgrSingleton::getInstance()
400
401}
402
403#endif // !defined(APIERRORMGR__INCLUDED_)
404
string GetErrorString()
Definition APIErrorMgr.h:98
ERROR_CODE GetErrorCode()
Definition APIErrorMgr.h:69
ERROR_CODE
Definition APIDefines.h:445
@ VSP_OK
Definition APIDefines.h:445