JSBSim Flight Dynamics Model  1.0 (02 March 2017)
An Open Source Flight Dynamics and Control Software Library in C++
FGTable.h
1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2 
3  Header: FGTable.h
4  Author: Jon S. Berndt
5  Date started: 1/9/2001
6 
7  ------------- Copyright (C) 2001 Jon S. Berndt (jon@jsbsim.org) --------------
8 
9  This program is free software; you can redistribute it and/or modify it under
10  the terms of the GNU Lesser 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 Lesser General Public License for more
17  details.
18 
19  You should have received a copy of the GNU Lesser 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 Lesser General Public License can also be found on
24  the world wide web at http://www.gnu.org.
25 
26 HISTORY
27 --------------------------------------------------------------------------------
28 JSB 1/9/00 Created
29 
30 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
31 SENTRY
32 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
33 
34 #ifndef FGTABLE_H
35 #define FGTABLE_H
36 
37 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
38 INCLUDES
39 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
40 
41 #include <iosfwd>
42 #include <vector>
43 #include <string>
44 #include "FGParameter.h"
45 #include "input_output/FGPropertyManager.h"
46 
47 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
48 DEFINITIONS
49 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
50 
51 #define ID_TABLE "$Id: FGTable.h,v 1.15 2013/01/26 17:06:49 bcoconni Exp $"
52 
53 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
54 FORWARD DECLARATIONS
55 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
56 
57 namespace JSBSim {
58 
59 class Element;
60 
61 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
62 CLASS DOCUMENTATION
63 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
64 
239 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
240 CLASS DECLARATION
241 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
242 
243 class FGTable : public FGParameter
244 {
245 public:
247  ~FGTable();
248 
251  FGTable(const FGTable& table);
252 
254  FGTable (FGPropertyManager* propMan, Element* el);
255  FGTable (int );
256  FGTable (int, int);
257  double GetValue(void) const;
258  double GetValue(double key) const;
259  double GetValue(double rowKey, double colKey) const;
260  double GetValue(double rowKey, double colKey, double TableKey) const;
283  void operator<<(std::istream&);
284  FGTable& operator<<(const double n);
285  FGTable& operator<<(const int n);
286 
287  inline double GetElement(int r, int c) const {return Data[r][c];}
288 // inline double GetElement(int r, int c, int t);
289 
290  double operator()(unsigned int r, unsigned int c) const {return GetElement(r, c);}
291 // double operator()(unsigned int r, unsigned int c, unsigned int t) {GetElement(r, c, t);}
292 
293  void SetRowIndexProperty(FGPropertyNode *node) {lookupProperty[eRow] = node;}
294  void SetColumnIndexProperty(FGPropertyNode *node) {lookupProperty[eColumn] = node;}
295 
296  unsigned int GetNumRows() const {return nRows;}
297 
298  void Print(void);
299 
300  std::string GetName(void) const {return Name;}
301 
302 private:
303  enum type {tt1D, tt2D, tt3D} Type;
304  enum axis {eRow=0, eColumn, eTable};
305  bool internal;
306  FGPropertyNode_ptr lookupProperty[3];
307  double** Data;
308  std::vector <FGTable*> Tables;
309  unsigned int nRows, nCols, nTables, dimension;
310  int colCounter, rowCounter, tableCounter;
311  mutable int lastRowIndex, lastColumnIndex, lastTableIndex;
312  double** Allocate(void);
313  FGPropertyManager* const PropertyManager;
314  std::string Name;
315  void bind(void);
316 
317  unsigned int FindNumColumns(const std::string&);
318  void Debug(int from);
319 };
320 }
321 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
322 
323 #endif
324 
Class wrapper for property handling.
void operator<<(std::istream &)
Read the table in.
Definition: FGTable.cpp:544
Represents various types of parameters.
Definition: FGParameter.h:63
FGTable(const FGTable &table)
This is the very important copy constructor.
Definition: FGTable.cpp:85
~FGTable()
Destructor.
Definition: FGTable.cpp:371
Lookup table class.
Definition: FGTable.h:243