1
0
Fork 0
flightgear/src/FDM/JSBSim/FGTable.h

112 lines
3.6 KiB
C
Raw Normal View History

2001-03-30 03:08:44 +00:00
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Header: FGTable.h
Author: Jon S. Berndt
Date started: 1/9/2001
------------- Copyright (C) 2001 Jon S. Berndt (jsb@hal-pc.org) --------------
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
details.
You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place - Suite 330, Boston, MA 02111-1307, USA.
Further information about the GNU General Public License can also be found on
the world wide web at http://www.gnu.org.
HISTORY
--------------------------------------------------------------------------------
JSB 1/9/00 Created
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SENTRY
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#ifndef FGTABLE_H
#define FGTABLE_H
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#include "FGConfigFile.h"
#include "FGJSBBase.h"
2001-03-30 03:08:44 +00:00
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#define ID_TABLE "$Id$"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
2003-06-03 08:46:15 +00:00
namespace JSBSim {
2001-03-30 03:08:44 +00:00
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CLASS DOCUMENTATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
/** Lookup table class.
Models a lookup table for use in FGCoefficient, FGPropeller, etc.
@author Jon S. Berndt
@version $Id$
@see FGCoefficient
@see FGPropeller
*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CLASS DECLARATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
class FGTable : public FGJSBBase
{
2001-03-30 03:08:44 +00:00
public:
~FGTable();
FGTable(int nRows);
FGTable(int nRows, int nCols);
2001-11-20 22:34:24 +00:00
double GetValue(double key);
double GetValue(double rowKey, double colKey);
2001-03-30 03:08:44 +00:00
/** Read the table in.
Data in the config file should be in matrix format with the row
independents as the first column and the column independents in
the first row. The implication of this layout is that there should
be no value in the upper left corner of the matrix e.g:
<pre>
0 10 20 30 ...
-5 1 2 3 4 ...
...
</pre>
*/
void operator<<(FGConfigFile&);
FGTable& operator<<(const double n);
2001-11-20 22:34:24 +00:00
FGTable& operator<<(const int n);
inline double GetElement(int r, int c) {return Data[r][c];}
2001-03-30 03:08:44 +00:00
void Print(void);
2002-04-16 13:15:29 +00:00
2001-03-30 03:08:44 +00:00
private:
enum type {tt1D, tt2D} Type;
2001-11-20 22:34:24 +00:00
double** Data;
2001-03-30 03:08:44 +00:00
int nRows, nCols;
int colCounter;
int rowCounter;
int lastRowIndex, lastColumnIndex;
2001-11-20 22:34:24 +00:00
double** Allocate(void);
2001-12-13 04:48:34 +00:00
void Debug(int from);
2001-03-30 03:08:44 +00:00
};
}
2001-03-30 03:08:44 +00:00
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#endif