casacore
BinTable.h
Go to the documentation of this file.
1 //# BinTable.h: The class BinaryTable converts a FITS binary table into a Casacore Table.
2 //# Copyright (C) 1995,1996,1999
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This library is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU Library General Public License as published by
7 //# the Free Software Foundation; either version 2 of the License, or (at your
8 //# option) any later version.
9 //#
10 //# This library is distributed in the hope that it will be useful, but WITHOUT
11 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 //# License for more details.
14 //#
15 //# You should have received a copy of the GNU Library General Public License
16 //# along with this library; if not, write to the Free Software Foundation,
17 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 //#
19 //# Correspondence concerning AIPS++ should be addressed as follows:
20 //# Internet email: aips2-request@nrao.edu.
21 //# Postal address: AIPS++ Project Office
22 //# National Radio Astronomy Observatory
23 //# 520 Edgemont Road
24 //# Charlottesville, VA 22903-2475 USA
25 //#
26 //# $Id$
27 
28 #ifndef FITS_BINTABLE_H
29 #define FITS_BINTABLE_H
30 
31 
32 //# Includes
33 
34 #include <casacore/casa/aips.h>
35 #include <casacore/fits/FITS/hdu.h>
36 #include <casacore/tables/Tables/Table.h>
37 #include <casacore/tables/Tables/TableRecord.h>
38 #include <map>
39 
40 namespace casacore { //# NAMESPACE CASACORE - BEGIN
41 
42 // <summary>
43 // BinaryTable is used to translate a FITS binary table to a Casacore Table.
44 // </summary>
45 
46 // <use visibility=export>
47 
48 // <reviewed reviewer="" date="" tests="tBinTable">
49 
50 // <prerequisite>
51 //# Classes you should understand before using this one.
52 // <li> FitsInput
53 // <li> HeaderDataUnit
54 // <li> BinaryTableExtension
55 // <li> Tables module
56 // </prerequisite>
57 //
58 // <etymology>
59 // BinaryTable inherits from the FITS BinaryTableExtension class and its
60 // primary use is to convert that class to a Casacore Table. This explains
61 // it's use but not its name. A better name should be found.
62 // </etymology>
63 //
64 // <synopsis>
65 // The class starts with an already existing FitsInput object, which should
66 // be set at a BinaryTableExtension HDU. Member functions provide a TableDesc
67 // appropriate for the FITS data (to help in constructing a Casacore Table
68 // compatible with the BinaryTableExtension), a Table containing the
69 // current row of FITS data and a Table containing the next row of FITS data
70 // (which can be used to step through the FitsInput, copying each row
71 // using the RowCopier class), and a Table containin the entire FITS binary
72 // table from the current row to the end of the table.
73 // </synopsis>
74 //
75 // <motivation>
76 // We need a way to get FITS data into Casacore Tables.
77 // </motivation>
78 //
79 // <example>
80 // open a FitsInput from a disk file, if the HDU is a BinaryTableExtension,
81 // then instantiate a BinTable object and get the entire table. A fair
82 // amount of error checking has been eliminated from this example.
83 // <srcblock>
84 // FitsInput infits("myFITSFile", FITS::Disk);
85 // switch (infits.hdutype()) {
86 // case FITS::BinaryTableHDU:
87 // BinaryTable bintab(infits);
88 // Table tab = bintable.fullTable("myTable");
89 // break;
90 // }
91 // </srcblock>
92 // There would obviously be other cases to the switch to deal with any
93 // other HDUs (e.g. skip them via infits.skip_hdu()). The Table destructor
94 // would write "myTable" to disk.
95 // </example>
96 //
97 //
98 // <todo asof="1995/04/10">
99 //# A List of bugs, limitations, extensions or planned refinements.
100 // <li> It would be nice to construct this directly from the BinaryTableExtension.
101 // <li> When random access FITS becomes available, this needs to be able to deal with that.
102 // <li> A corresponding class is needed for conversion from Casacore Tables to FITS.
103 // <li> Throw exceptions rather than send messages to cout : however the entire FITS
104 // module behaves this way, so it should all remain consistent.
105 // <li> The following types of columns are not dealt with very well or at all
106 // (Bit, Byte, 0-length columns).
107 // <li> No attempt use any TDIM columns or keywords to shape arrays.
108 // </todo>
109 
111 {
112 public:
113 
114  // The only constructor is from a FitsInput, you can also optionally
115  // provide a FITS error handler. If useMiriadSM is True, use
116  // the Miriad storage manager for all columns, otherwise AipsIO.
117  // If sdfits is True, all non-reserved and some reserved keyword
118  // are treated as if they were columns with constant values
119  // "virtual columns" in the sdfits convention.
122  Bool useMiriadSM = False, Bool sdfits = False);
123 
125 
126  // Get the full table, using the supplied arguments to construct the table.
127  // The table will contain all data from the current row to the end of the
128  // BinarTableExtension.If useMiriadSM is True, use the Miriad storage
129  // manager for all columns, otherwise AipsIO.
130  Table fullTable(const String& tabName,
132  Bool useMiriadSM = False);
133 
134  // This version of the fullTable return a Memory based table
135  // Its recommended if its being used as a temporary
136 
138 
139  // Get an appropriate TableDesc (this is the same TableDesc used to
140  // construct any Table objects returned by this class.
142 
143  // Return the Table keywords (this is the same TableRecord used
144  // in any Table objects returned by this class.
146 
147  // Get a Table with a single row, the current row of the FITS table.
148  // The returned Table is a Scratch table.
149  // The standard BinaryTableExtension manipulation functions are
150  // available to position the FITS input at the desired location.
151  const Table &thisRow();
152 
153  // Get a Table with a single row, the next row of the FITS table.
154  // The returned Table is a Scratch table.
155  // The FITS input is positioned to the next row and the values translated
156  // and returned in a Table object.
157  const Table &nextRow();
158 
159 
160 private:
161 
162  //# Data Members
163  // This is the Scratch table containing the current row
165  // The number of elements for each column of the BinaryTableExtension
167  // This is a map from column number to column name
168  std::map<Int, String> *colNames;
169 
171 
172  // These are used by any VADesc columns
174  void **vaptr_p;
176  char *theheap_p;
177 
178  // this is the function that fills each row in as needed
179  void fillRow();
180 };
181 
182 
183 } //# NAMESPACE CASACORE - END
184 
185 #endif
BINTABLE extension
Definition: hdu.h:1035
Table fullTable()
This version of the fullTable return a Memory based table Its recommended if its being used as a temp...
TableRecord kwSet
Definition: BinTable.h:170
TableRecord & getKeywords()
Return the Table keywords (this is the same TableRecord used in any Table objects returned by this cl...
FITS::ValueType * vatypes_p
These are used by any VADesc columns.
Definition: BinTable.h:173
Int * nelem
The number of elements for each column of the BinaryTableExtension.
Definition: BinTable.h:166
BinaryTable(FitsInput &, FITSErrorHandler errhandler=FITSError::defaultHandler, Bool useMiriadSM=False, Bool sdfits=False)
The only constructor is from a FitsInput, you can also optionally provide a FITS error handler.
const Table & nextRow()
Get a Table with a single row, the next row of the FITS table.
void fillRow()
this is the function that fills each row in as needed
const TableDesc & getDescriptor()
Get an appropriate TableDesc (this is the same TableDesc used to construct any Table objects returned...
Table * currRowTab
This is the Scratch table containing the current row.
Definition: BinTable.h:164
Table fullTable(const String &tabName, const Table::TableOption=Table::NewNoReplace, Bool useMiriadSM=False)
Get the full table, using the supplied arguments to construct the table.
const Table & thisRow()
Get a Table with a single row, the current row of the FITS table.
VADescFitsField * va_p
Definition: BinTable.h:175
std::map< Int, String > * colNames
This is a map from column number to column name.
Definition: BinTable.h:168
static void defaultHandler(const char *errMessage, ErrorLevel severity)
The default error handler.
ValueType
FITS I/O Error message types.
Definition: fits.h:167
helper class Note: Note that FitsField does not allocate space for the data; Space is external to Fi...
Definition: hdu.h:882
fixed-length sequential blocked FITS input
Definition: fitsio.h:156
String: the storage and methods of handling collections of characters.
Definition: String.h:225
TableOption
Define the possible options how a table can be opened.
Definition: Table.h:172
@ NewNoReplace
create table (may not exist)
Definition: Table.h:178
void(* FITSErrorHandler)(const char *errMessage, FITSError::ErrorLevel severity)
Define a typedef for the handler function signature for convenience.
Definition: FITSError.h:111
this file contains all the compiler specific defines
Definition: mainpage.dox:28
const Bool False
Definition: aipstype.h:44
int Int
Definition: aipstype.h:50
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42