casa
$Rev:20696$
|
00001 //# GBTMSTypeRecFiller.h: used to fill the GBT_type_SAMPLER table 00002 //# Copyright (C) 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_GBTMSTYPERECFILLER_H 00030 #define NRAO_GBTMSTYPERECFILLER_H 00031 00032 00033 #include <casa/aips.h> 00034 #include <casa/Arrays/Vector.h> 00035 #include <tables/Tables/Table.h> 00036 #include <casa/BasicSL/String.h> 00037 00038 //# Forward Declarations 00039 namespace casa { //# NAMESPACE CASA - BEGIN 00040 class ColumnsIndex; 00041 class TableRow; 00042 class Record; 00043 } //# NAMESPACE CASA - END 00044 00045 #include <casa/namespace.h> 00046 00047 // <summary> 00048 // Used to fill the GBT_type_SAMPLER table (e.g. GBT_DCR_SAMPLER) 00049 // </summary> 00050 00051 // <use visibility=local> 00052 00053 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos=""> 00054 // </reviewed> 00055 00056 // <prerequisite> 00057 // <li> <linkto class=GBTBackendFiller>GBTBackendFiller</linkto> 00058 // </prerequisite> 00059 // 00060 // <etymology> 00061 // The PROCESSOR 00062 // </etymology> 00063 // 00064 // <synopsis> 00065 // </synopsis> 00066 // 00067 // <example> 00068 // </example> 00069 // 00070 // <motivation> 00071 // Several GBT backends have a SAMPLER table associated with each scan. 00072 // These tables are often very much the same from scan to scan and 00073 // there are a limited number of different samplers which a user will 00074 // typically choose. Hence it makes sense to have these be simply 00075 // indexed by row number and to re-use rows in the filled MS table 00076 // when possible. 00077 // </motivation> 00078 // 00079 // <todo asof="yyyy/mm/dd"> 00080 // <li> the GBTMSType*Filler classes need to share a base class. 00081 // </todo> 00082 00083 class GBTMSTypeSampFiller 00084 { 00085 public: 00086 // open an already existing table - type is extracted from the tableName 00087 // using everything before the last "_SAMPLER" to the previous "_" 00088 GBTMSTypeSampFiller(const String &tableName); 00089 00090 // create a new, empty table attached to the given table using the 00091 // indicate typeSamp. 00092 GBTMSTypeSampFiller(Table &attachTable, const String &type); 00093 00094 ~GBTMSTypeSampFiller(); 00095 00096 // Fill the indicated table to this table. 00097 // Each column in other maps to a column in the 00098 // this table. The type 00099 // of the columns must match that in the existing table. 00100 // Columns not already in this table will result in new 00101 // columns. If there are only scalar columns, then new rows 00102 // will only be added if this row does not already exist in the table. 00103 // If there are any non-scalar columns, a new row is always added. 00104 void fill(const Table &other); 00105 00106 // how many rows in this table 00107 uInt nrow() { return tab_p->nrow(); } 00108 00109 // what is the type of this GBT_type_SAMPLER table 00110 const String &type() {return type_p;} 00111 00112 // how many samplers were recently filled 00113 uInt nsamplers() {return samplerIds().nelements();} 00114 00115 // what are the most recent sampler Ids filled 00116 const Vector<Int> samplerIds() { return sampIds_p;} 00117 00118 // return the sampler Id for a particular row in the table which was 00119 // most recently used in a call to fill 00120 Int samplerId(Int whichSamp) {return samplerIds()(whichSamp);} 00121 00122 // mark the column of the given name as handled - there is no check to see if 00123 // that column exists 00124 void handleColumn(const String &colname); 00125 00126 // flush this table 00127 void flush() { tab_p->flush();} 00128 private: 00129 Table *tab_p; 00130 TableRow *tabRow_p; 00131 00132 ColumnsIndex *index_p; 00133 Vector<Int> sampIds_p; 00134 00135 Vector<String> handledCols_p; 00136 00137 String type_p; 00138 00139 void updateTableRow(); 00140 void updateIndex(); 00141 00142 // we fill on a row by row basis 00143 void fillRow(const Record &row); 00144 00145 // this checks the record and adds columns as required 00146 void checkRecord(const Record &row); 00147 00148 // Undefined and unavailable 00149 GBTMSTypeSampFiller(); 00150 GBTMSTypeSampFiller(const GBTMSTypeSampFiller &other); 00151 GBTMSTypeSampFiller &operator=(const GBTMSTypeSampFiller &other); 00152 }; 00153 00154 00155 #endif 00156 00157