]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/FGJSBBase.h
Provide a fix for the MSVC/Cygwin GDI build problem
[flightgear.git] / src / FDM / JSBSim / FGJSBBase.h
1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2
3  Header:       FGJSBBase.h
4  Author:       Jon S. Berndt
5  Date started: 07/01/01
6
7  ------------- Copyright (C) 2001  Jon S. Berndt (jsb@hal-pc.org) -------------
8
9  This program is free software; you can redistribute it and/or modify it under
10  the terms of the GNU General Public License as published by the Free Software
11  Foundation; either version 2 of the License, or (at your option) any later
12  version.
13
14  This program is distributed in the hope that it will be useful, but WITHOUT
15  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
17  details.
18
19  You should have received a copy of the GNU General Public License along with
20  this program; if not, write to the Free Software Foundation, Inc., 59 Temple
21  Place - Suite 330, Boston, MA  02111-1307, USA.
22
23  Further information about the GNU General Public License can also be found on
24  the world wide web at http://www.gnu.org.
25
26 HISTORY
27 --------------------------------------------------------------------------------
28 07/01/01  JSB  Created
29
30 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
31 SENTRY
32 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
33
34 #ifndef FGJSBBASE_H
35 #define FGJSBBASE_H
36
37 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
38 INCLUDES
39 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
40
41 #ifdef FGFS
42 #  include <simgear/compiler.h>
43 #  include <math.h>
44 #  include <queue>
45 #  include STL_STRING
46
47 SG_USING_STD(string);
48 SG_USING_STD(queue);
49
50 # ifndef M_PI
51 #  include <simgear/constants.h>
52 #  define M_PI SG_PI
53 # endif
54
55 #else
56
57 #  include <queue>
58 #  include <string>
59 #  if defined(sgi) && !defined(__GNUC__)
60 #    include <math.h>
61 #  else
62 #    include <cmath>
63 #  endif
64
65 using std::string;
66 using std::queue;
67
68 # ifndef M_PI
69 #  define M_PI 3.14159265358979323846
70 # endif
71
72 #endif
73
74 #if !defined(WIN32) || defined(__GNUC__)
75 using std::max;
76 #endif
77
78 #ifdef __FreeBSD__ // define gcvt on FreeBSD
79
80 #include <stdio.h>
81
82 static char *gcvt(double number, size_t ndigit, char *buf)
83 {
84      sprintf(buf, "%f", number);
85      return buf;
86 }
87 #endif
88
89 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
90 DEFINITIONS
91 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
92
93 #define ID_JSBBASE "$Id$"
94
95 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
96 FORWARD DECLARATIONS
97 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
98
99
100 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
101 COMMENTS, REFERENCES, and NOTES [use "class documentation" below for API docs]
102 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
103
104 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
105 CLASS DOCUMENTATION
106 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
107
108 /** JSBSim Base class.
109     @author Jon S. Berndt
110     @version $Id$
111 */
112
113 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
114 CLASS DECLARATION
115 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
116
117 namespace JSBSim {
118
119 class FGJSBBase {
120 public:
121   /// Constructor for FGJSBBase.
122   FGJSBBase();
123
124   /// Destructor for FGJSBBase.
125   virtual ~FGJSBBase() {};
126
127   /// JSBSim Message structure
128   typedef struct Msg {
129     unsigned int fdmId;
130     unsigned int messageId;
131     string text;
132     string subsystem;
133     enum mType {eText, eInteger, eDouble, eBool} type;
134     bool bVal;
135     int  iVal;
136     double dVal;
137   } Message;
138
139   ///@name JSBSim Enums.
140   //@{
141   /// Moments L, M, N
142   enum {eL     = 1, eM,     eN    };
143   /// Rates P, Q, R
144   enum {eP     = 1, eQ,     eR    };
145   /// Velocities U, V, W
146   enum {eU     = 1, eV,     eW    };
147   /// Positions X, Y, Z
148   enum {eX     = 1, eY,     eZ    };
149   /// Euler angles Phi, Theta, Psi
150   enum {ePhi   = 1, eTht,   ePsi  };
151   /// Stability axis forces, Drag, Side force, Lift
152   enum {eDrag  = 1, eSide,  eLift };
153   /// Local frame orientation Roll, Pitch, Yaw
154   enum {eRoll  = 1, ePitch, eYaw  };
155   /// Local frame position North, East, Down
156   enum {eNorth = 1, eEast,  eDown };
157   //@}
158   
159   ///@name JSBSim console output highlighting terms.
160   //@{
161   /// highlights text
162   static char highint[5];
163   /// low intensity text
164   static char halfint[5];
165   /// normal intensity text
166   static char normint[6];
167   /// resets text properties
168   static char reset[5];
169   /// underlines text
170   static char underon[5];
171   /// underline off
172   static char underoff[6];
173   /// blue text
174   static char fgblue[6];
175   /// cyan text
176   static char fgcyan[6];
177   /// red text
178   static char fgred[6];
179   /// green text
180   static char fggreen[6];
181   /// default text
182   static char fgdef[6];
183   //@}
184
185   ///@name JSBSim Messaging functions
186   //@{
187   /** Places a Message structure on the Message queue.
188       @param msg pointer to a Message structure
189       @return pointer to a Message structure */
190   Message* PutMessage(Message* msg);
191   /** Creates a message with the given text and places it on the queue.
192       @param text message text
193       @return pointer to a Message structure */
194   Message* PutMessage(string text);
195   /** Creates a message with the given text and boolean value and places it on the queue.
196       @param text message text
197       @param bVal boolean value associated with the message
198       @return pointer to a Message structure */
199   Message* PutMessage(string text, bool bVal);
200   /** Creates a message with the given text and integer value and places it on the queue.
201       @param text message text
202       @param iVal integer value associated with the message
203       @return pointer to a Message structure */
204   Message* PutMessage(string text, int iVal);
205   /** Creates a message with the given text and double value and places it on the queue.
206       @param text message text
207       @param dVal double value associated with the message
208       @return pointer to a Message structure */
209   Message* PutMessage(string text, double dVal);
210   /** Reads the message on the queue (but does not delete it).
211       @return pointer to a Message structure (or NULL if no mesage) */
212   Message* ReadMessage(void);
213   /** Reads the message on the queue and removes it from the queue.
214       @return pointer to a Message structure (or NULL if no mesage) */
215   Message* ProcessMessage(void);
216   //@}
217   string GetVersion(void) {return JSBSim_version;}
218   
219   void disableHighLighting(void);
220
221 protected:
222   static Message localMsg;
223   
224   static queue <Message*> Messages;
225
226   virtual void Debug(int from) {};
227
228   static short debug_lvl;
229   static unsigned int frame;
230   static unsigned int messageId;
231   
232   static const double radtodeg;
233   static const double degtorad;
234   static const double hptoftlbssec;
235   static const double psftoinhg;
236   static const double fpstokts;
237   static const double ktstofps;
238   static const double inchtoft;
239   static const double in3tom3;
240   static const double Reng;         // Specific Gas Constant,ft^2/(sec^2*R)
241   static const double SHRatio;
242   static const string needed_cfg_version;
243   static const string JSBSim_version;
244 };
245 }
246 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
247 #endif
248