casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
FITSTimedTable.h
Go to the documentation of this file.
00001 //# FITSTimedTable.h: A Table with a time column
00002 //# Copyright (C) 1995,1996,1997
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: FITSTimedTable.h 18093 2004-11-30 17:51:10Z ddebonis $
00028 
00029 #ifndef FITS_FITSTIMEDTABLE_H
00030 #define FITS_FITSTIMEDTABLE_H
00031 
00032 #include <casa/aips.h>
00033 #include <fits/FITS/FITSTable.h>
00034 #include <casa/Containers/Record.h>
00035 #include <casa/Containers/RecordField.h>
00036 
00037 namespace casa { //# NAMESPACE CASA - BEGIN
00038 
00039 // <summary>
00040 // </summary>
00041 
00042 // <use visibility=export>
00043 
00044 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
00045 // </reviewed>
00046 
00047 // <prerequisite>
00048 //   <li> 
00049 // </prerequisite>
00050 //
00051 // <etymology>
00052 // </etymology>
00053 //
00054 // <synopsis>
00055 // FITSTimedTable is used to look at FITS tables which have a time column. In
00056 // particular, it peeks ahead, and knows the time of the currentRow and of the
00057 // nextRow.
00058 //
00059 // It is constructed with a pointer to any FITSTabular. Presently, no memory 
00060 // management is imposed to ensure that the pointer remains valid.
00061 // </synopsis>
00062 //
00063 // <example>
00064 // </example>
00065 //
00066 // <motivation>
00067 // </motivation>
00068 //
00069 // <todo asof="1995/06/01">
00070 //   <li> 
00071 // </todo>
00072 
00073 class FITSTimedTable :  public FITSTabular
00074 {
00075 public:
00076     // This is not connected to any data, isValid always returns True,
00077     // keywords and description return the default versions
00078     // hasChanged returns False, name returns an empty string
00079     // pastEnd returns False and next does nothing.
00080     // setTime does nothing, currentRow returns an empty record
00081     // and currentTime returns 0.0
00082     // and ok returns True and nextTime returns 0.0
00083     FITSTimedTable();
00084     // Note, originalTable cannot be destructed, reopened, ...,during the
00085     // lifetime of this object.
00086     FITSTimedTable(FITSTabular *originalTable, uInt whichColumnIsTime=0);
00087     ~FITSTimedTable();
00088 
00089     virtual Bool isValid() const;
00090     virtual const TableRecord &keywords() const;
00091     virtual const RecordDesc &description() const;
00092     virtual const Record &units() const;
00093     virtual const Record &displayFormats() const;
00094     virtual const Record &nulls() const;
00095 
00096     virtual Bool hasChanged() const { return hasChanged_p;}
00097     virtual void resetChangedFlag() { hasChanged_p = False; }
00098     virtual const String &name() const { return table_p->name(); }
00099     virtual Bool pastEnd() const;
00100     virtual Bool pastEnd();
00101     virtual void next();
00102     // interpolate to the desired time which must be >= the currentTime()
00103     // This uses a linear interpolation between adjacent floating point values.
00104     // Non-floating point values are NOT interpolated but have the value of the
00105     // most recent actual row.  On the last row of the table, not interpolation
00106     // is done.
00107     virtual void setTime(Double time);
00108     virtual const Record &currentRow() const;
00109     virtual Record &currentRow();
00110 
00111     // What is the time of the current row?
00112     Double currentTime() const;
00113 
00114     // this is True if the last setTime() finished as expected
00115     // It is False only if the requested time is before the current time
00116     // and the timed table as just been opened
00117     Bool ok() const { return ok_p;}
00118 
00119     // What will the time of the next row be? Returns a very large number if
00120     // it is past the end of the table.
00121     Double nextTime();
00122 private:
00123     Bool atStart_p;
00124     Bool ok_p;
00125     Bool hasChanged_p;
00126     Bool changePending_p;
00127     FITSTabular *table_p;
00128     Record *row_now_p;
00129     Record *row_next_p;
00130     RORecordFieldPtr<Double> time_now_p;
00131     RORecordFieldPtr<Double> time_next_p;
00132     RecordDesc rowDesc_p;
00133     Int how_past_end_p;
00134     uInt timeColumn_p;
00135     TableRecord dummyKeywords;
00136     Record dummyUnits;
00137     Record dummyDisps;
00138     Record dummyNulls;
00139 
00140     void initNowRecord(const RecordDesc& desc);
00141     void initNextRecord(const RecordDesc& desc);
00142 };
00143 
00144 } //# NAMESPACE CASA - END
00145 
00146 #endif