JSBSim Flight Dynamics Model 1.3.1 (17 May 2026)
An Open Source Flight Dynamics and Control Software Library in C++
Loading...
Searching...
No Matches
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
26HISTORY
27--------------------------------------------------------------------------------
28JSB 1/9/00 Created
29ADM 2026/04/17 Added support for 4D and higher tables.
30
31%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
32SENTRY
33%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
34
35#ifndef FGTABLE_H
36#define FGTABLE_H
37
38/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
39INCLUDES
40%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
41
42#include <memory>
43#include <vector>
44
45#include "FGParameter.h"
46#include "math/FGPropertyValue.h"
47
48/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
49FORWARD DECLARATIONS
50%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
51
52namespace JSBSim {
53
54class Element;
55
56/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
57CLASS DOCUMENTATION
58%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
59
326/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
327CLASS DECLARATION
328%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
329
330class JSBSIM_API FGTable : public FGParameter, public FGJSBBase
331{
332public:
334 ~FGTable();
335
338 FGTable(const FGTable& table);
340 /* MSVC issues an error C2280 if not defined : it is needed by
341 std::unique_ptr<FGTable>.
342 See StackOverflow: https://stackoverflow.com/questions/31264984/c-compiler-error-c2280-attempting-to-reference-a-deleted-function-in-visual */
344
346 FGTable (std::shared_ptr<FGPropertyManager> propMan, Element* el,
347 const std::string& prefix="");
348 FGTable (int);
349 FGTable (int, int);
350
352 double GetValue(void) const;
356 double GetValue(double key) const;
361 double GetValue(double rowKey, double colKey) const;
367 double GetValue(double rowKey, double colKey, double TableKey) const;
368 double GetValue(double a1, double a2, double a3, double a4) const;
369 double GetValue(double a1, double a2, double a3, double a4, double a5) const;
370 double GetValue(double a1, double a2, double a3, double a4, double a5,
371 double a6) const;
372 double GetValue(const std::vector<double>& keys) const;
373
374 double GetMinValue(void) const;
375 double GetMinValue(double colKey) const;
376 double GetMinValue(double colKey, double TableKey) const;
377
400 void operator<<(std::istream&);
401 FGTable& operator<<(const double x);
402
403 double GetElement(unsigned int r, unsigned int c) const;
404 double operator()(unsigned int r, unsigned int c) const
405 { return GetElement(r, c); }
406
407 void SetRowIndexProperty(SGPropertyNode *node)
408 { SetLookupProperty(eRow, new FGPropertyValue(node)); }
409 void SetColumnIndexProperty(SGPropertyNode *node)
410 { SetLookupProperty(eColumn, new FGPropertyValue(node)); }
411
412 unsigned int GetNumRows() const {return nRows;}
413
414 void Print(void);
415
416 std::string GetName(void) const {return Name;}
417
418private:
419 enum type {tt1D, tt2D, ttND} Type;
420 enum axis {eRow=0, eColumn, eTable};
421 bool internal = false;
422 std::shared_ptr<FGPropertyManager> PropertyManager; // Property root used to do late binding.
423 std::vector<FGPropertyValue_ptr> lookupProperty;
424 mutable std::vector<double> lookupPropertyValues;
425 std::vector<double> Data;
426 std::vector<std::unique_ptr<FGTable>> Tables;
427 unsigned int nRows = 0u, nCols = 0u, nDims = 0u;
428 std::string Name;
429
430 void SetLookupProperty(unsigned int axis, FGPropertyValue_ptr node)
431 {
432 if (lookupProperty.size() <= axis) lookupProperty.resize(axis + 1u);
433 lookupProperty[axis] = node;
434 }
435
436 bool HasLookupProperty(unsigned int axis) const
437 {
438 return axis < lookupProperty.size() && lookupProperty[axis];
439 }
440
441 double GetValue(const double* keys) const;
442 void bind(Element* el, const std::string& Prefix);
443 void missingData(Element *el, unsigned int expected_size, size_t actual_size);
444 void Debug(int from);
445};
446}
447//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
448
449#endif
JSBSim Base class.
Definition FGJSBBase.h:118
Represents various types of parameters.
Definition FGParameter.h:61
Represents a property value which can use late binding.
Lookup table class.
Definition FGTable.h:331
FGTable & operator=(const FGTable &)
Copy assignment constructor.
A node in a property tree.
Definition props.hxx:747
Main namespace for the JSBSim Flight Dynamics Model.
Definition FGFDMExec.cpp:71
ostream & operator<<(ostream &os, const FGColumnVector3 &col)
Write vector to a stream.
Type
The possible types of an SGPropertyNode.
Definition props.hxx:153