casa
$Rev:20696$
|
00001 //# GBTMSSourceFiller.h: GBTMSSourceFiller fills the MSSource table for GBT fillers 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_GBTMSSOURCEFILLER_H 00030 #define NRAO_GBTMSSOURCEFILLER_H 00031 00032 #include <casa/aips.h> 00033 #include <casa/Arrays/Vector.h> 00034 #include <casa/Containers/RecordField.h> 00035 #include <tables/Tables/ScalarColumn.h> 00036 #include <casa/BasicSL/Constants.h> 00037 #include <ms/MeasurementSets/MSSource.h> 00038 00039 //# Forward Declarations 00040 namespace casa { //# NAMESPACE CASA - BEGIN 00041 class String; 00042 class MSSource; 00043 class MSSourceColumns; 00044 class Table; 00045 class ColumnsIndex; 00046 } //# NAMESPACE CASA - END 00047 00048 #include <casa/namespace.h> 00049 00050 // <summary> 00051 // GBTMSSourceFiller fills the MSSource table for GBT fillers 00052 // </summary> 00053 00054 // <use visibility=local> 00055 00056 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos=""> 00057 // </reviewed> 00058 00059 // <prerequisite> 00060 // <li> MeasurementSets 00061 // <li> GBT FITS files 00062 // </prerequisite> 00063 // 00064 // <etymology> 00065 // This class puts GBT data (fills) into the MSSource table. 00066 // </etymology> 00067 // 00068 // <synopsis> 00069 // This class puts the appropriate values for the GBT in an MSSource 00070 // table (which has been previously created as part of a MeasurementSet). 00071 // On each fill() any necessary additions to the MSSource are made. 00072 // This filler keeps returns a unique ID for each set of source information. 00073 // Existing information is kept for later indexing. The spectral window ID 00074 // is used in addition to the source ID to set this information into the 00075 // appropriate row of the MSSource table. 00076 // 00077 // The sourceId is available to be used by 00078 // other GBTMS*Fillers as other subtables are filled in turn. 00079 // 00080 // </synopsis> 00081 // 00082 // <example> 00083 // </example> 00084 // 00085 // <motivation> 00086 // Writing a filler is a daunting task. There are various dependencies 00087 // between the subtables. It helps to encapsulate the knowlege and 00088 // task of filling a specific subtable to separate classes. 00089 // </motivation> 00090 // 00091 //#! <thrown> 00092 //#! A list of exceptions thrown if errors are discovered in the function. 00093 //#! This tag will appear in the body of the header file, preceding the 00094 //#! declaration of each function which throws an exception. 00095 //#! </thrown> 00096 00097 class GBTMSSourceFiller 00098 { 00099 public: 00100 00101 // The default ctor. No MSSource table has been attached yet. 00102 // Calling fill on such a filler will throw an exception. 00103 // It is present so that this object can be instantiated before 00104 // an MSSource has been created. 00105 GBTMSSourceFiller(); 00106 00107 // A filler attached to an MSSource table 00108 GBTMSSourceFiller(MSSource &msSource); 00109 00110 ~GBTMSSourceFiller(); 00111 00112 // attach it to an MSSource 00113 void attach(MSSource &msSource); 00114 00115 // fill given the indicated source information and spectral window ID 00116 void fill(const Vector<Int> &spectralWindowIds, 00117 const String &name, Double restFrequency = 0.0, 00118 Double sysvel = 0.0, const String &code="", 00119 Double time = 0.0, Double interval=-1, 00120 Int calibrationGroup=-1, 00121 const Vector<Double> &direction=Vector<Double>(2,0.0), 00122 const Vector<Double> &position=Vector<Double>(3,0.0)); 00123 00124 // What is the most recently filled source ID. Returns -1 if none have been filled. 00125 Int sourceId() const {return sourceId_p;} 00126 00127 // flush the underlying MS subtable 00128 void flush() {msSource_p->flush();} 00129 00130 private: 00131 MSSource *msSource_p; 00132 MSSourceColumns *msSourceCols_p; 00133 00134 // The current Id 00135 Int sourceId_p; 00136 00137 // the table holding the cache, it is temporary 00138 Table *theCache_p; 00139 00140 // the columns in the cache 00141 ScalarColumn<Int> calGroupCol_p; 00142 ScalarColumn<String> codeCol_p, nameCol_p; 00143 ScalarColumn<Double> timeCol_p, intervalCol_p, restFreqCol_p, sysvelCol_p; 00144 // the vector cols are stored in the cache as scalar columns so that they can be indexed 00145 ScalarColumn<Double> dirCol0_p, dirCol1_p, posCol0_p, posCol1_p, posCol2_p; 00146 00147 // The ColumnsIndex for the cache 00148 ColumnsIndex *cacheIndx_p; 00149 // ColumnsIndex for the MSSource table 00150 ColumnsIndex *sourceIndx_p; 00151 00152 // The pointers to the fields in the index key 00153 RecordFieldPtr<Int> calGroupKey_p; 00154 RecordFieldPtr<String> codeKey_p, nameKey_p; 00155 RecordFieldPtr<Double> timeKey_p, intervalKey_p, restFreqKey_p, sysvelKey_p; 00156 RecordFieldPtr<Double> dirKey0_p, dirKey1_p, posKey0_p, posKey1_p, posKey2_p; 00157 00158 RecordFieldPtr<Int> sourceIdKey_p, spWinIdKey_p; 00159 00160 // initialize the above for the first time 00161 void init(MSSource &msSource); 00162 00163 // clean things up 00164 void cleanup(); 00165 00166 // undefined and unavailable 00167 GBTMSSourceFiller(const GBTMSSourceFiller &other); 00168 void operator=(const GBTMSSourceFiller &other); 00169 }; 00170 00171 #endif 00172 00173