casa
$Rev:20696$
|
00001 //# GBTMSTypeStateFiller.h: used to fill the GBT_type_[MASTER]STATE 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_GBTMSTYPESTATEFILLER_H 00030 #define NRAO_GBTMSTYPESTATEFILLER_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_[MASTER]STATE table (e.g. GBT_DCR_STATE) 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 STATE 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 STATEs 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. There is a master state table associated with 00077 // each scan because only one backend can control (be master of) the 00078 // switching states. That state table is stored in as 00079 // GBT_type_MASTERSTATE when available. 00080 // </motivation> 00081 // 00082 // <todo asof="yyyy/mm/dd"> 00083 // <li> the GBTMSType*Filler classes need to share a base class. 00084 // </todo> 00085 00086 class GBTMSTypeStateFiller 00087 { 00088 public: 00089 // open an already existing table - type is extracted from the tableName 00090 // using everything before the last "_[MASTER]STATE" to the previous "_" 00091 GBTMSTypeStateFiller(const String &tableName); 00092 00093 // create a new, empty table attached to the given table using the 00094 // indicate typeState. Make this a MASTERSTATE table if requested. 00095 GBTMSTypeStateFiller(Table &attachTable, const String &type, 00096 Bool masterState = False); 00097 00098 ~GBTMSTypeStateFiller(); 00099 00100 // Fill the indicated table to this table. 00101 // Each column in other maps to a column in the 00102 // this table. The type 00103 // of the columns must match that in the existing table. 00104 // Columns not already in this table will result in new 00105 // columns. If there are only scalar columns, then new rows 00106 // will only be added if this row does not already exist in the table. 00107 // If there are any non-scalar columns, a new row is always added. 00108 void fill(const Table &other); 00109 00110 // how many rows in this table 00111 uInt nrow() { return tab_p->nrow(); } 00112 00113 // what is the type of this GBT_type_STATE table 00114 const String &type() {return type_p;} 00115 00116 // how many states were recently filled 00117 uInt nstates() {return stateIds().nelements();} 00118 00119 // what are the most recent stateIds filled 00120 const Vector<Int> stateIds() { return stateIds_p;} 00121 00122 // return the stateId for a particular row in the table which was 00123 // most recently used in a call to fill 00124 Int stateId(Int whichState) {return stateIds()(whichState);} 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> stateIds_p; 00134 00135 String type_p; 00136 00137 Bool typesDiffer_p; 00138 00139 void updateTableRow(); 00140 void updateIndex(const Vector<String> &colNames); 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, const Vector<String> &fieldNames); 00147 00148 // Undefined and unavailable 00149 GBTMSTypeStateFiller(); 00150 GBTMSTypeStateFiller(const GBTMSTypeStateFiller &other); 00151 GBTMSTypeStateFiller &operator=(const GBTMSTypeStateFiller &other); 00152 }; 00153 00154 00155 #endif 00156 00157