casa
$Rev:20696$
|
00001 //# TableMeasOffseDesc.h: Definition of an Offset measure in a Table. 00002 //# Copyright (C) 1997,1999,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 //# $Id: TableMeasOffsetDesc.h 18093 2004-11-30 17:51:10Z ddebonis $ 00027 00028 #ifndef MEASURES_TABLEMEASOFFSETDESC_H 00029 #define MEASURES_TABLEMEASOFFSETDESC_H 00030 00031 //# Includes 00032 #include <casa/BasicSL/String.h> 00033 #include <measures/Measures/MeasureHolder.h> 00034 00035 namespace casa { //# NAMESPACE CASA - BEGIN 00036 00037 //# Forward Declarations 00038 class TableMeasDescBase; 00039 class Measure; 00040 class Table; 00041 class TableDesc; 00042 class TableRecord; 00043 class String; 00044 00045 00046 // <summary> 00047 // Definition of a Measure Offset in a Table. 00048 // </summary> 00049 00050 // <use visibility=export> 00051 00052 // <reviewed reviewer="Bob Garwood" date="1999/12/23" tests="tTableMeasures.cc"> 00053 // </reviewed> 00054 00055 // <prerequisite> 00056 //# Classes you should understand before using this one. 00057 // <li> <linkto module=Measures>Measures</linkto> 00058 // <li> <linkto module=Tables>Tables</linkto> 00059 // <li> <linkto class=TableMeasDesc>TableMeasDesc</linkto> 00060 // </prerequisite> 00061 00062 // <synopsis> 00063 // This class assists in the definition of the offset component of a 00064 // TableMeasDesc 00065 // in the TableMeasures system. Four possibilities exist for specifying the 00066 // handling of measure offsets in a Measure column. These are: 00067 // 00068 // <ul> 00069 // <li> an offset is not used 00070 // <li> all measures in the column have the same offset 00071 // <li> a unique (and probably different) offset is stored for each row 00072 // <li> a unique offset is stored in each array element per (Array)column 00073 // row 00074 // </ul> 00075 // 00076 // Note that this last option is only relevant when using ArrayMeasColumns. 00077 // 00078 // Examples of each of these follow. 00079 // </synopsis> 00080 00081 // <example> 00082 //<ol> 00083 // <li>Specifying a single fixed offset. Note that a Measure offset is itself 00084 // a measure 00085 // <srcblock> 00086 // // create an MEpoch to use as the offset in an MEpoch column 00087 // MEpoch offset(MVEpoch(MVTime(1996, 5, 17, (8+18./60.)/24.)), MEpoch::UTC); 00088 // TableMeasOffsetDesc offsetDesc(offset); 00089 // </srcblock> 00090 // 00091 // <li>Storing an offset per row needs an offset column. Measure offsets are 00092 // Measures so a Measure column is needed: 00093 // <srcblock> 00094 // // Need a column for the offsets. This is to be a Measure column, 00095 // // so the rules for creating a Measure column apply. 00096 // ArrayColumnDesc<Double> cdOffset("OffsetCol", "Variable Offset col"); 00097 // ... 00098 // // add the column to the table 00099 // td.addColumn(cdOffset); 00100 // ... 00101 // // Create the Measure column to be used as the measure offset column 00102 // TableMeasValueDesc valDesc(td, "OffsetCol"); 00103 // TableMeasDesc<MEpoch> offset(valDesc); 00104 // // Create the offset descriptor 00105 // TableMeasOffsetDesc offsetDesc(offset); 00106 // 00107 // </srcblock> 00108 // 00109 // <li>Storing an offset per array element per row requires one change in the 00110 // constructor used in the previous example: 00111 // <srcblock> 00112 // ... 00113 // // set up column and TableMeasDesc as before 00114 // ... 00115 // // Setting the asArray parameter to True in the constructor specifies 00116 // // per element offset storage 00117 // TableMeasOffsetDesc offsetDesc(offset, True); 00118 // </srcblock> 00119 // </ol> 00120 // 00121 // For an example of the use of the TableMeasOffsetDesc class in the context 00122 // of a full TableMeasDesc declaration see class 00123 // <linkto class="TableMeasDesc">TableMeasDesc</linkto>. 00124 // </example> 00125 00126 // <motivation> 00127 // Creating the required keyword for the definition of a Measure 00128 // in a Table is somewhat complicated. This class assists in that 00129 // process. 00130 // </motivation> 00131 // 00132 // <thrown> 00133 // <li>AipsError during reconstruction of non-variable offset if a 00134 // component of the offset measure is missing in the column keywords or 00135 // is corrupt in some way. 00136 // <li>AipsError if getOffset() called on a variable offset object. 00137 // <li>AipsError during a reconstruct if the column doesn't have a Unit. 00138 // </thrown> 00139 // 00140 //# <todo asof="$DATE:$"> 00141 //# A List of bugs, limitations, extensions or planned refinements. 00142 //# </todo> 00143 00144 class TableMeasOffsetDesc 00145 { 00146 public: 00147 // Constructor which defines a constant (non-variable) offset. All 00148 // measures in the columns will have the same offset. 00149 TableMeasOffsetDesc (const Measure& offset); 00150 00151 // Constructor for defining a variable offset. If asArray is True then 00152 // the offset is stored per array element. The default is for the 00153 // offset to be stored (and hence variable) per row. 00154 TableMeasOffsetDesc (const TableMeasDescBase& offsetColumn, 00155 Bool asArray=False); 00156 00157 // Copy constructor (copy semantics). 00158 TableMeasOffsetDesc (const TableMeasOffsetDesc& that); 00159 00160 ~TableMeasOffsetDesc(); 00161 00162 // Assignment operator (copy semantics). 00163 TableMeasOffsetDesc& operator= (const TableMeasOffsetDesc& that); 00164 00165 // Reconstructs the TableMeasOffsetDesc from the measInfo TableRecord. 00166 static TableMeasOffsetDesc* reconstruct (const TableRecord& measInfo, 00167 const String& prefix, 00168 const Table& tab); 00169 00170 // Get the (non-variable) measure offset for this column. If it doesn't 00171 // exist (thus if the offset is variable), an exception is thrown. 00172 const Measure& getOffset() const; 00173 00174 // Returns True if the offset varies per row. 00175 Bool isVariable() const 00176 { return (itsTMDesc != 0); } 00177 00178 // Returns True if the offset varies per array element. 00179 Bool isArray() const 00180 { return (isVariable() && itsVarPerArr); } 00181 00182 // Gets the name of the column which stores the variable offset. 00183 // "" is returned if the offset is not variable. 00184 const String& columnName() const 00185 { return itsVarColName; } 00186 00187 // Reset the offset. 00188 // It overwrites the value used when defining the TableMeasDesc. 00189 // It is only possible if it was defined as fixed for the entire column. 00190 void resetOffset (const Measure& offset); 00191 00192 // Write the information into the record. 00193 // <group> 00194 void write (TableDesc&, TableRecord& measInfo, const String& prefix); 00195 void write (Table&, TableRecord& measInfo, const String& prefix); 00196 // </group> 00197 00198 private: 00199 TableMeasDescBase* itsTMDesc; //# Stores variable offset if applicable 00200 MeasureHolder itsMeasure; //# The offset if non-variable. 00201 String itsVarColName; //# "" if offset non-variable. 00202 Bool itsVarPerArr; //# Is variable per array element. 00203 00204 00205 // Constructor which uses the measInfo TableRecord. 00206 TableMeasOffsetDesc (const TableRecord& measInfo, const String& prefix, 00207 const Table&); 00208 00209 // Write the actual keywords. 00210 void writeKeys (TableRecord& measInfo, const String& prefix); 00211 }; 00212 00213 00214 00215 } //# NAMESPACE CASA - END 00216 00217 #endif