casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
SDObservationHandler.h
Go to the documentation of this file.
00001 //# SDObservationFiller.h: fills the OBSERVATION table for the SDFITS filler
00002 //# Copyright (C) 2000
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: SDObservationHandler.h 18700 2005-05-23 07:45:13Z cvsmgr $
00028 
00029 #ifndef MS_SDOBSERVATIONHANDLER_H
00030 #define MS_SDOBSERVATIONHANDLER_H
00031 
00032 #include <casa/Containers/RecordField.h>
00033 #include <tables/Tables/ScalarColumn.h>
00034 
00035 namespace casa { //# NAMESPACE CASA - BEGIN
00036 
00037 //# Forward Declarations
00038 class ColumnsIndex;
00039 class MeasurementSet;
00040 class MSObservation;
00041 class MSObservationColumns;
00042 class Record;
00043 class String;
00044 
00045 template <class T> class Vector;
00046 
00047 // <summary>
00048 // </summary>
00049 
00050 // <use visibility=local>   or   <use visibility=export>
00051 
00052 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
00053 // </reviewed>
00054 
00055 // <prerequisite>
00056 //   <li> SomeClass
00057 //   <li> SomeOtherClass
00058 //   <li> some concept
00059 // </prerequisite>
00060 //
00061 // <etymology>
00062 // </etymology>
00063 //
00064 // <synopsis>
00065 // </synopsis>
00066 //
00067 // <example>
00068 // </example>
00069 //
00070 // <motivation>
00071 // </motivation>
00072 //
00073 // <templating arg=T>
00074 //    <li>
00075 //    <li>
00076 // </templating>
00077 //
00078 // <thrown>
00079 //    <li>
00080 //    <li>
00081 // </thrown>
00082 //
00083 // <todo asof="yyyy/mm/dd">
00084 //   <li> add this feature
00085 //   <li> fix this bug
00086 //   <li> start discussion of this possible extension
00087 // </todo>
00088 
00089 class SDObservationHandler
00090 {
00091 public:
00092     // default ctor is not attached to a MS and hence is useless until attached
00093     SDObservationHandler();
00094 
00095     // attach this to a MS, mark the appropriate columns as handled given
00096     // the indicated row
00097     SDObservationHandler(MeasurementSet &ms, Vector<Bool> &handledCols, const Record &row);
00098 
00099     // copy ctor
00100     SDObservationHandler(const SDObservationHandler &other);
00101 
00102     ~SDObservationHandler() {clearAll();}
00103 
00104     // assignment operator, uses copy semantics
00105     SDObservationHandler &operator=(const SDObservationHandler &other);
00106 
00107     // attach to a MS, mark the appropriate columns as handled given the row
00108     void attach(MeasurementSet &ms, Vector<Bool> &handledCols, const Record &row);
00109 
00110     // reset internals given indicated row, use the same MS 
00111     void resetRow(const Record &row);
00112     
00113     // fill - a new row is added only when necessary
00114     void fill(const Record &row, const String &telescopeName, const Vector<Double> &timeRange);
00115 
00116     // get the current observation ID
00117     Int observationId() {return rownr_p;}
00118 
00119     // update the time range
00120     void updateTimeRange(const Vector<Double> &timeRange);
00121 private:
00122     ColumnsIndex *index_p;
00123     RecordFieldPtr<String> telescopeKey_p, observerKey_p, projectKey_p, ns_obsidKey_p;
00124     RecordFieldPtr<Double> releaseDateKey_p;
00125     RecordFieldPtr<Bool> flagRowKey_p;
00126 
00127     MSObservation *msObs_p;
00128     MSObservationColumns *msObsCols_p;
00129 
00130     Int rownr_p;
00131 
00132     ScalarColumn<String> nsObsIdCol_p;
00133 
00134     // pointers to fields in record, only used if attached
00135     RORecordFieldPtr<String> observer_p, projid_p, obsid_p;
00136     RORecordFieldPtr<Double> releaseDate_p;
00137     RORecordFieldPtr<Bool> flagRow_p;
00138     RORecordFieldPtr<Array<Double> > timeRange_p;
00139 
00140     // cleanup everything
00141     void clearAll();
00142 
00143     // cleanup things which depend on the row description being fixed
00144     void clearRow();
00145 
00146     // initialize everything
00147     void initAll(MeasurementSet &ms, Vector<Bool> &handledCols, const Record &row);
00148 
00149     // initialize the things which depend on the row
00150     void initRow(Vector<Bool> &handledCols, const Record &row);
00151 
00152     // initialize the index
00153     void makeIndex();
00154 };
00155 
00156 
00157 } //# NAMESPACE CASA - END
00158 
00159 #endif
00160 
00161