casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
GBTSimpleTable.h
Go to the documentation of this file.
00001 //# GBTSimpleTable.h: a GBTSimpleTable is used to concatenate simple GBT tables
00002 //# Copyright (C) 1999,2000,2001
00003 //# Associated Universities, Inc. Washington DC, USA.
00004 //#
00005 //# This library is free software; you can redistribute it and/or modify it
00006 //# under the terms of the GNU Library General Public License as published by
00007 //# the Free Software Foundation; either version 2 of the License, or (at your
00008 //# option) any later version.
00009 //#
00010 //# This library is distributed in the hope that it will be useful, but WITHOUT
00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00013 //# License for more details.
00014 //#
00015 //# You should have received a copy of the GNU Library General Public License
00016 //# along with this library; if not, write to the Free Software Foundation,
00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00018 //#
00019 //# Correspondence concerning AIPS++ should be addressed as follows:
00020 //#        Internet email: aips2-request@nrao.edu.
00021 //#        Postal address: AIPS++ Project Office
00022 //#                        National Radio Astronomy Observatory
00023 //#                        520 Edgemont Road
00024 //#                        Charlottesville, VA 22903-2475 USA
00025 //#
00026 //#
00027 //# $Id$
00028 
00029 #ifndef NRAO_GBTSIMPLETABLE_H
00030 #define NRAO_GBTSIMPLETABLE_H
00031 
00032 
00033 #include <casa/aips.h>
00034 #include <casa/BasicSL/String.h>
00035 #include <tables/Tables/Table.h>
00036 #include <tables/Tables/ScalarColumn.h>
00037 
00038 //# Forward Declarations
00039 namespace casa { //# NAMESPACE CASA - BEGIN
00040 class TableRow;
00041 class RecordInterface;
00042 } //# NAMESPACE CASA - END
00043 
00044 #include <casa/namespace.h>
00045 
00046 // <summary>
00047 // Used to concatenate simple GBT tables.
00048 // </summary>
00049 
00050 // <use visibility=local>
00051 
00052 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
00053 // </reviewed>
00054 
00055 // <prerequisite>
00056 //   <li> <linkto class=GBTBackendFiller>GBTBackendFiller</linkto>
00057 // </prerequisite>
00058 //
00059 // <etymology>
00060 // This contains a Table to which other Tables can be appended.
00061 // Its quite simple and it it used by the GBTBackendFillers.
00062 // </etymology>
00063 //
00064 // <synopsis>
00065 // </synopsis>
00066 //
00067 // <example>
00068 // </example>
00069 //
00070 // <motivation>
00071 // The GBT backend FITS files generally have ancilliar tables such
00072 // as PHASE and RECEIVER.  In the resulting MS, these are just
00073 // appended to the end of a subtable.  This class contains those
00074 // subtables and does the appending.
00075 //
00076 // With MS 2, this is somewhat more complicated and hence this class
00077 // probably needs a better name.
00078 // </motivation>
00079 //
00080 // <todo asof="yyyy/mm/dd">
00081 //   <li> Is there a mechanism in the Table system which essentially
00082 //        already does this? 
00083 // </todo>
00084 
00085 class GBTSimpleTable
00086 {
00087 public:
00088     // open an already existing table, use the optional index column
00089     GBTSimpleTable(const String &tableName,
00090                    const String &indexColumn=String(""));
00091 
00092     // create a new, empty table attached to the given table at the
00093     // given keyword name, supply an optional index column
00094     GBTSimpleTable(Table &attachTable, 
00095                    const String &attachKeywordName,
00096                    const String &tableName,
00097                    const String &indexColumn=String(""));
00098 
00099     ~GBTSimpleTable();
00100 
00101     // append the given table to the end of this table
00102     // adding columns as required, any columns with the
00103     // same name must have the same type and dimensionality
00104     void add(const Table &other);
00105 
00106     // append this record to the end of this table.
00107     // Each field in the record maps to a column in the
00108     // the table.  There must be no subrecords.  The types
00109     // of the fields must match that in the existing table.
00110     // Fields not already in the table will result in new
00111     // columns for that table
00112     void add(const RecordInterface &other, Bool nextIndex=True);
00113 
00114     // how many rows in this table
00115     uInt nrow() { return tab_p->nrow(); }
00116 
00117     // the current value of the index, returns -1 if this table isn't 
00118     // indexed
00119     const Int index() { return index_p;}
00120 
00121     // return a const reference to the underlying table being filled
00122     const Table &table() {return *tab_p;}
00123 
00124     // flush this table
00125     void flush() {tab_p->flush();}
00126 private:
00127     Table *tab_p;
00128     TableRow *tabRow_p;
00129 
00130     Int index_p;
00131     ScalarColumn<Int> indexCol_p;
00132 
00133     void updateTableRow();
00134 
00135     // this checks the record and adds columns as required
00136     void checkRecord(const RecordInterface &other);
00137 
00138     void attachIndexCol(const String &indexColumn);
00139 
00140     void setIndex(Int rownr, Bool nextIndex=True);
00141 
00142     // Undefined and unavailable
00143     GBTSimpleTable();
00144     GBTSimpleTable(const GBTSimpleTable &other);
00145     GBTSimpleTable &operator=(const GBTSimpleTable &other);
00146 };
00147 
00148 
00149 #endif
00150 
00151