]> git.mxchange.org Git - flightgear.git/blob - src/FDM/UIUCModel/uiuc_menu_mass.cpp
Harald JOHNSEN:
[flightgear.git] / src / FDM / UIUCModel / uiuc_menu_mass.cpp
1 /**********************************************************************
2                                                                        
3  FILENAME:     uiuc_menu_mass.cpp
4
5 ----------------------------------------------------------------------
6
7  DESCRIPTION:  reads input data for specified aircraft and creates 
8                approporiate data storage space
9
10 ----------------------------------------------------------------------
11
12  STATUS:       alpha version
13
14 ----------------------------------------------------------------------
15
16  REFERENCES:   based on "menu reader" format of Michael Selig
17
18 ----------------------------------------------------------------------
19
20  HISTORY:      04/04/2003   initial release
21                06/30/2003   (RD) replaced istrstream with istringstream
22                             to get rid of the annoying warning about
23                             using the strstream header
24
25 ----------------------------------------------------------------------
26
27  AUTHOR(S):    Robert Deters      <rdeters@uiuc.edu>
28                Michael Selig      <m-selig@uiuc.edu>
29
30 ----------------------------------------------------------------------
31
32  VARIABLES:
33
34 ----------------------------------------------------------------------
35
36  INPUTS:       n/a
37
38 ----------------------------------------------------------------------
39
40  OUTPUTS:      n/a
41
42 ----------------------------------------------------------------------
43
44  CALLED BY:    uiuc_menu()
45
46 ----------------------------------------------------------------------
47
48  CALLS TO:     check_float() if needed
49                d_2_to_3() if needed
50                d_1_to_2() if needed
51                i_1_to_2() if needed
52                d_1_to_1() if needed
53
54  ----------------------------------------------------------------------
55
56  COPYRIGHT:    (C) 2003 by Michael Selig
57
58  This program is free software; you can redistribute it and/or
59  modify it under the terms of the GNU General Public License
60  as published by the Free Software Foundation.
61
62  This program is distributed in the hope that it will be useful,
63  but WITHOUT ANY WARRANTY; without even the implied warranty of
64  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
65  GNU General Public License for more details.
66
67  You should have received a copy of the GNU General Public License
68  along with this program; if not, write to the Free Software
69  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
70  USA or view http://www.gnu.org/copyleft/gpl.html.
71
72 **********************************************************************/
73
74 #include <simgear/compiler.h>
75
76 #if defined( __MWERKS__ )
77 // -dw- optimizer chokes (big-time) trying to optimize humongous
78 // loop/switch statements
79 #pragma optimization_level 0
80 #endif
81
82 #include <cstdlib>
83 #include <string>
84 #include STL_IOSTREAM
85
86 #include "uiuc_menu_mass.h"
87
88 SG_USING_STD(cerr);
89 SG_USING_STD(cout);
90 SG_USING_STD(endl);
91
92 #ifndef _MSC_VER
93 SG_USING_STD(exit);
94 #endif
95
96 void parse_mass( const string& linetoken2, const string& linetoken3,
97                  const string& linetoken4, const string& linetoken5, 
98                  const string& linetoken6, const string& linetoken7, 
99                  const string& linetoken8, const string& linetoken9,
100                  const string& linetoken10, const string& aircraft_directory,
101                  LIST command_line ) {
102     double token_value;
103     istringstream token3(linetoken3.c_str());
104     istringstream token4(linetoken4.c_str());
105     istringstream token5(linetoken5.c_str());
106     istringstream token6(linetoken6.c_str());
107     istringstream token7(linetoken7.c_str());
108     istringstream token8(linetoken8.c_str());
109     istringstream token9(linetoken9.c_str());
110     istringstream token10(linetoken10.c_str());
111
112     switch(mass_map[linetoken2])
113       {
114       case Weight_flag:
115         {
116           if (check_float(linetoken3))
117             token3 >> token_value;
118           else
119             uiuc_warnings_errors(1, *command_line);
120           
121           Weight = token_value;
122           Mass = Weight * INVG;
123           massParts -> storeCommands (*command_line);
124           break;
125         }
126       case Mass_flag:
127         {
128           if (check_float(linetoken3))
129             token3 >> token_value;
130           else
131             uiuc_warnings_errors(1, *command_line);
132           
133           Mass = token_value;
134           massParts -> storeCommands (*command_line);
135           break;
136         }
137       case I_xx_flag:
138         {
139           if (check_float(linetoken3))
140             token3 >> token_value;
141           else
142             uiuc_warnings_errors(1, *command_line);
143           
144           I_xx = token_value;
145           massParts -> storeCommands (*command_line);
146           break;
147         }
148       case I_yy_flag:
149         {
150           if (check_float(linetoken3))
151             token3 >> token_value;
152           else
153             uiuc_warnings_errors(1, *command_line);
154           
155           I_yy = token_value;
156           massParts -> storeCommands (*command_line);
157           break;
158         }
159       case I_zz_flag:
160         {
161           if (check_float(linetoken3))
162             token3 >> token_value;
163           else
164             uiuc_warnings_errors(1, *command_line);
165           
166           I_zz = token_value;
167           massParts -> storeCommands (*command_line);
168           break;
169         }
170       case I_xz_flag:
171         {
172           if (check_float(linetoken3))
173             token3 >> token_value;
174           else
175             uiuc_warnings_errors(1, *command_line);
176           
177           I_xz = token_value;
178           massParts -> storeCommands (*command_line);
179           break;
180         }
181       case Mass_appMass_ratio_flag:
182         {
183           if (check_float(linetoken3))
184             token3 >> token_value;
185           else
186             uiuc_warnings_errors(1, *command_line);
187           
188           Mass_appMass_ratio = token_value;
189           massParts -> storeCommands (*command_line);
190           break;
191         }
192       case I_xx_appMass_ratio_flag:
193         {
194           if (check_float(linetoken3))
195             token3 >> token_value;
196           else
197             uiuc_warnings_errors(1, *command_line);
198           
199           I_xx_appMass_ratio = token_value;
200           massParts -> storeCommands (*command_line);
201           break;
202         }
203       case I_yy_appMass_ratio_flag:
204         {
205           if (check_float(linetoken3))
206             token3 >> token_value;
207           else
208             uiuc_warnings_errors(1, *command_line);
209           
210           I_yy_appMass_ratio = token_value;
211           massParts -> storeCommands (*command_line);
212           break;
213         }
214       case I_zz_appMass_ratio_flag:
215         {
216           if (check_float(linetoken3))
217             token3 >> token_value;
218           else
219             uiuc_warnings_errors(1, *command_line);
220           
221           I_zz_appMass_ratio = token_value;
222           massParts -> storeCommands (*command_line);
223           break;
224         }
225       case Mass_appMass_flag:
226         {
227           if (check_float(linetoken3))
228             token3 >> token_value;
229           else
230             uiuc_warnings_errors(1, *command_line);
231           
232           Mass_appMass = token_value;
233           massParts -> storeCommands (*command_line);
234           break;
235         }
236       case I_xx_appMass_flag:
237         {
238           if (check_float(linetoken3))
239             token3 >> token_value;
240           else
241             uiuc_warnings_errors(1, *command_line);
242           
243           I_xx_appMass = token_value;
244           massParts -> storeCommands (*command_line);
245           break;
246         }
247       case I_yy_appMass_flag:
248         {
249           if (check_float(linetoken3))
250             token3 >> token_value;
251           else
252             uiuc_warnings_errors(1, *command_line);
253           
254           I_yy_appMass = token_value;
255           massParts -> storeCommands (*command_line);
256           break;
257         }
258       case I_zz_appMass_flag:
259         {
260           if (check_float(linetoken3))
261             token3 >> token_value;
262           else
263             uiuc_warnings_errors(1, *command_line);
264           
265           I_zz_appMass = token_value;
266           massParts -> storeCommands (*command_line);
267           break;
268         }
269       default:
270         {
271           if (ignore_unknown_keywords) {
272             // do nothing
273           } else {
274             // print error message
275             uiuc_warnings_errors(2, *command_line);
276           }
277           break;
278         }
279       };
280 }