casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
SDFieldHandler.h
Go to the documentation of this file.
00001 //# SDFieldFiller.h: fills the FIELD table for the SDFITS filler
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: SDFieldHandler.h 18700 2005-05-23 07:45:13Z cvsmgr $
00028 
00029 #ifndef MS_SDFIELDHANDLER_H
00030 #define MS_SDFIELDHANDLER_H
00031 
00032 #include <casa/aips.h>
00033 #include <casa/Containers/RecordField.h>
00034 
00035 namespace casa { //# NAMESPACE CASA - BEGIN
00036 
00037 //# Forward Declarations
00038 class MeasurementSet;
00039 class MSField;
00040 class MSFieldColumns;
00041 class String;
00042 class Record;
00043 class ColumnsIndex;
00044 
00045 template <class T> class Vector;
00046 template <class T> class Matrix;
00047 
00048 // <summary>
00049 // </summary>
00050 
00051 // <use visibility=local>   or   <use visibility=export>
00052 
00053 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
00054 // </reviewed>
00055 
00056 // <prerequisite>
00057 //   <li> SomeClass
00058 //   <li> SomeOtherClass
00059 //   <li> some concept
00060 // </prerequisite>
00061 //
00062 // <etymology>
00063 // </etymology>
00064 //
00065 // <synopsis>
00066 // </synopsis>
00067 //
00068 // <example>
00069 // </example>
00070 //
00071 // <motivation>
00072 // </motivation>
00073 //
00074 // <templating arg=T>
00075 //    <li>
00076 //    <li>
00077 // </templating>
00078 //
00079 // <thrown>
00080 //    <li>
00081 //    <li>
00082 // </thrown>
00083 //
00084 // <todo asof="yyyy/mm/dd">
00085 //   <li> add this feature
00086 //   <li> fix this bug
00087 //   <li> start discussion of this possible extension
00088 // </todo>
00089 
00090 class SDFieldHandler
00091 {
00092 public:
00093     // default ctor is not attached to a MS and hence is useless until attached
00094     SDFieldHandler();
00095 
00096     // attach this to a MS - no columns are explicitly handled here
00097     SDFieldHandler(MeasurementSet &ms, Vector<Bool> &handledCols, const Record &row);
00098 
00099     // copy ctor
00100     SDFieldHandler(const SDFieldHandler &other);
00101 
00102     ~SDFieldHandler() {clearAll();}
00103 
00104     // assignment operator, uses copy semantics
00105     SDFieldHandler &operator=(const SDFieldHandler &other);
00106 
00107     // attach to a MS, the handledCols and row arguments are ignored here
00108     void attach(MeasurementSet &ms, Vector<Bool> &handledCols, const Record &row);
00109 
00110     // reset internals given indicated row, use the same MS; just resets the id pointer
00111     void resetRow(const Record &row);
00112     
00113     // fill - a new row is added at each call unless the data is from a previous MS fill
00114     // in which case an existing MAIN_FIELD_ID is used to see if that existing row might
00115     // be reused
00116     void fill(const Record &row, const String &name, Int directionRefType,
00117               const Matrix<Double> &directionPoly, Double time, Int sourceId);
00118 
00119     // get the current field ID
00120     Int fieldId() {return rownr_p;}
00121 private:
00122     MSField *msField_p;
00123     MSFieldColumns *msFieldCols_p;
00124 
00125     Int rownr_p;
00126 
00127     // fields which might be present if the data is originally from a MS
00128     RORecordFieldPtr<Int> fieldIdField_p;
00129     RORecordFieldPtr<String> codeField_p, nameField_p;
00130     RORecordFieldPtr<Double> timeField_p;
00131     RORecordFieldPtr<Array<Double> > delayDirField_p, delayDirRateField_p, 
00132         phaseDirField_p, phaseDirRateField_p, referenceDirField_p,
00133         referenceDirRateField_p;
00134     RORecordFieldPtr<Bool> flagRowField_p;
00135 
00136     ColumnsIndex *index_p;
00137     RecordFieldPtr<String> nameKey_p;
00138     RecordFieldPtr<Int> sourceIdKey_p;
00139     RecordFieldPtr<Double> timeKey_p;
00140 
00141     // cleanup everything
00142     void clearAll();
00143 
00144     void clearRow();
00145 
00146     // initialize everything
00147     void initAll(MeasurementSet &ms, Vector<Bool> &handledCols, const Record &row);
00148 
00149     // initialize things which depend on the row
00150     void initRow(Vector<Bool> &handledCols, const Record &row);
00151 };
00152 
00153 
00154 } //# NAMESPACE CASA - END
00155 
00156 #endif
00157 
00158