JSBSim Flight Dynamics Model  1.1.11 (13 Feb 2022)
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
11  Software Foundation; either version 2 of the License, or (at your option) any
12  later 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
20  with this program; if not, write to the Free Software Foundation, Inc., 59
21  Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 
23  Further information about the GNU Lesser General Public License can also be
24  found on 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 "FGParameter.h"
42 #include "math/FGPropertyValue.h"
43 
44 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
45 FORWARD DECLARATIONS
46 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
47 
48 namespace JSBSim {
49 
50 class Element;
51 
52 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
53 CLASS DOCUMENTATION
54 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
55 
229 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
230 CLASS DECLARATION
231 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
232 
233 class FGTable : public FGParameter, public FGJSBBase
234 {
235 public:
237  ~FGTable();
238 
241  FGTable(const FGTable& table);
242 
244  FGTable (FGPropertyManager* propMan, Element* el, const std::string& prefix="");
245  FGTable (int );
246  FGTable (int, int);
247  double GetValue(void) const;
248  double GetValue(double key) const;
249  double GetValue(double rowKey, double colKey) const;
250  double GetValue(double rowKey, double colKey, double TableKey) const;
273  void operator<<(std::istream&);
274  FGTable& operator<<(const double n);
275  FGTable& operator<<(const int n);
276 
277  inline double GetElement(int r, int c) const {return Data[r][c];}
278 
279  double operator()(unsigned int r, unsigned int c) const
280  { return GetElement(r, c); }
281 
282  void SetRowIndexProperty(FGPropertyNode *node)
283  { lookupProperty[eRow] = new FGPropertyValue(node); }
284  void SetColumnIndexProperty(FGPropertyNode *node)
285  { lookupProperty[eColumn] = new FGPropertyValue(node); }
286 
287  unsigned int GetNumRows() const {return nRows;}
288 
289  void Print(void);
290 
291  std::string GetName(void) const {return Name;}
292 
293 private:
294  enum type {tt1D, tt2D, tt3D} Type;
295  enum axis {eRow=0, eColumn, eTable};
296  bool internal;
297  FGPropertyValue_ptr lookupProperty[3];
298  double** Data;
299  std::vector <FGTable*> Tables;
300  unsigned int nRows, nCols, nTables, dimension;
301  int colCounter, rowCounter, tableCounter;
302  mutable int lastRowIndex, lastColumnIndex, lastTableIndex;
303  double** Allocate(void);
304  FGPropertyManager* const PropertyManager;
305  std::string Name;
306  void bind(Element* el, const std::string& Prefix);
307  void Debug(int from);
308 };
309 }
310 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
311 
312 #endif
JSBSim::FGTable::operator<<
void operator<<(std::istream &)
Read the table in.
Definition: FGTable.cpp:573
JSBSim::FGTable
Lookup table class.
Definition: FGTable.h:233
JSBSim::FGPropertyNode
Class wrapper for property handling.
Definition: FGPropertyManager.h:70
JSBSim::FGParameter
Represents various types of parameters.
Definition: FGParameter.h:58
JSBSim::FGJSBBase
JSBSim Base class.
Definition: FGJSBBase.h:78
JSBSim::FGTable::FGTable
FGTable(const FGTable &table)
This is the very important copy constructor.
Definition: FGTable.cpp:82
JSBSim::FGPropertyValue
Represents a property value which can use late binding.
Definition: FGPropertyValue.h:59
JSBSim::FGTable::~FGTable
~FGTable()
Destructor.
Definition: FGTable.cpp:399
JSBSim::FGPropertyManager
Definition: FGPropertyManager.h:373
JSBSim::Element
Definition: FGXMLElement.h:143