FlightGear next
FGTable.h
Go to the documentation of this file.
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
29
30%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
31SENTRY
32%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
33
34#ifndef FGTABLE_H
35#define FGTABLE_H
36
37/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
38INCLUDES
39%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
40
41#include "FGParameter.h"
43
44/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
45FORWARD DECLARATIONS
46%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
47
48namespace JSBSim {
49
50class Element;
51
52/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
53CLASS DOCUMENTATION
54%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
55
228
229/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
230CLASS DECLARATION
231%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
232
233class FGTable : public FGParameter, public FGJSBBase
234{
235public:
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;
272
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
283 { lookupProperty[eRow] = new FGPropertyValue(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
293private:
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
FGJSBBase()
Constructor for FGJSBBase.
Definition FGJSBBase.h:81
Represents various types of parameters.
Definition FGParameter.h:59
Class wrapper for property handling.
Represents a property value which can use late binding.
std::string GetName(void) const
Definition FGTable.h:291
double GetValue(void) const
Definition FGTable.cpp:422
double operator()(unsigned int r, unsigned int c) const
Definition FGTable.h:279
void operator<<(std::istream &)
Read the table in.
FGTable(const FGTable &table)
This is the very important copy constructor.
Definition FGTable.cpp:82
unsigned int GetNumRows() const
Definition FGTable.h:287
void SetColumnIndexProperty(FGPropertyNode *node)
Definition FGTable.h:284
void Print(void)
Definition FGTable.cpp:616
~FGTable()
Destructor.
Definition FGTable.cpp:399
void SetRowIndexProperty(FGPropertyNode *node)
Definition FGTable.h:282
double GetElement(int r, int c) const
Definition FGTable.h:277
SGSharedPtr< FGPropertyValue > FGPropertyValue_ptr