JSBSim Flight Dynamics Model  1.2.0 (05 Nov 2023)
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 JSBSIM_API FGTable : public FGParameter, public FGJSBBase
234 {
235 public:
237  ~FGTable();
238 
241  FGTable(const FGTable& table);
243  /* MSVC issues an error C2280 if not defined : it is needed by
244  std::unique_ptr<FGTable>.
245  See StackOverflow: https://stackoverflow.com/questions/31264984/c-compiler-error-c2280-attempting-to-reference-a-deleted-function-in-visual */
247 
249  FGTable (std::shared_ptr<FGPropertyManager> propMan, Element* el,
250  const std::string& prefix="");
251  FGTable (int);
252  FGTable (int, int);
253 
255  double GetValue(void) const;
259  double GetValue(double key) const;
264  double GetValue(double rowKey, double colKey) const;
270  double GetValue(double rowKey, double colKey, double TableKey) const;
271 
272  double GetMinValue(void) const;
273  double GetMinValue(double colKey) const;
274  double GetMinValue(double colKey, double TableKey) const;
275 
298  void operator<<(std::istream&);
299  FGTable& operator<<(const double x);
300 
301  double GetElement(unsigned int r, unsigned int c) const;
302  double operator()(unsigned int r, unsigned int c) const
303  { return GetElement(r, c); }
304 
305  void SetRowIndexProperty(FGPropertyNode *node)
306  { lookupProperty[eRow] = new FGPropertyValue(node); }
307  void SetColumnIndexProperty(FGPropertyNode *node)
308  { lookupProperty[eColumn] = new FGPropertyValue(node); }
309 
310  unsigned int GetNumRows() const {return nRows;}
311 
312  void Print(void);
313 
314  std::string GetName(void) const {return Name;}
315 
316 private:
317  enum type {tt1D, tt2D, tt3D} Type;
318  enum axis {eRow=0, eColumn, eTable};
319  bool internal = false;
320  std::shared_ptr<FGPropertyManager> PropertyManager; // Property root used to do late binding.
321  FGPropertyValue_ptr lookupProperty[3];
322  std::vector<double> Data;
323  std::vector<std::unique_ptr<FGTable>> Tables;
324  unsigned int nRows, nCols;
325  std::string Name;
326  void bind(Element* el, const std::string& Prefix);
327  void missingData(Element *el, unsigned int expected_size, size_t actual_size);
328  void Debug(int from);
329 };
330 }
331 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
332 
333 #endif
JSBSim Base class.
Definition: FGJSBBase.h:118
Represents various types of parameters.
Definition: FGParameter.h:61
Class wrapper for property handling.
Represents a property value which can use late binding.
Lookup table class.
Definition: FGTable.h:234
FGTable & operator=(const FGTable &)
Copy assignment constructor.