TableMeasDescBase.h

Go to the documentation of this file.
00001 //# TableMeasDescBase.h: Definition of a 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$
00027 
00028 #ifndef MEASURES_TABLEMEASDESCBASE_H
00029 #define MEASURES_TABLEMEASDESCBASE_H
00030 
00031 //# Includes
00032 #include <casacore/casa/aips.h>
00033 #include <casacore/measures/TableMeasures/TableMeasValueDesc.h>
00034 #include <casacore/measures/TableMeasures/TableMeasRefDesc.h>
00035 #include <casacore/measures/TableMeasures/TableMeasType.h>
00036 #include <casacore/casa/Quanta/Unit.h>
00037 #include <casacore/casa/Arrays/Vector.h>
00038 
00039 namespace casacore { //# NAMESPACE CASACORE - BEGIN
00040 
00041 //# Forward Declarations
00042 class String;
00043 class Table;
00044 class TableDesc;
00045 class TableRecord;
00046 class TableColumn;
00047 class Measure;
00048 template<class T> class Quantum;
00049 
00050 
00051 // <summary>
00052 // Definition of a Measure in a Table.
00053 // </summary>
00054 
00055 // <use visibility=local>
00056 
00057 // <reviewed reviewer="Bob Garwood" date="1999/12/23" tests="tTableMeasures.cc">
00058 // </reviewed>
00059 
00060 // <prerequisite>
00061 //# Classes you should understand before using this one.
00062 //   <li> <linkto module=Measures>Measures</linkto>
00063 //   <li> <linkto module=Tables>Tables</linkto>
00064 //   <li> <linkto class=TableMeasDesc>TableMeasDesc</linkto>
00065 // </prerequisite>
00066 
00067 // <synopsis>
00068 // Abstract base class for TableMeasDesc.
00069 // </synopsis>
00070 
00071 // <example>
00072 // See class <linkto class="TableMeasDesc">TableMeasDesc</linkto>.
00073 // </example>
00074 
00075 // <motivation>
00076 // Creating the required keyword for the definition of a Measure
00077 // in a Table is somewhat complicated. This class assists in that
00078 // process.
00079 // </motivation>
00080 //
00081 // <thrown>
00082 //    <li>AipsError during reconstruction if the column doesn't contain
00083 //        a MEASINFO record.
00084 //    <li>AipsError during reconstruction if the column has a MEASINFO
00085 //        but it Measure type is invalid.
00086 // </thrown>
00087 //
00088 
00089 //# <todo asof="$DATE:$">
00090 //# A List of bugs, limitations, extensions or planned refinements.
00091 //# </todo>
00092 
00093 class TableMeasDescBase
00094 {
00095 public:
00096   // Null constructor.
00097   TableMeasDescBase();
00098 
00099   // Constructor with value and reference descriptors.
00100   // Note that setMeasType is always called by the derived class.
00101   TableMeasDescBase (const TableMeasValueDesc&, const TableMeasRefDesc&);
00102 
00103   // Copy constructor.
00104   TableMeasDescBase (const TableMeasDescBase& that);
00105 
00106   virtual ~TableMeasDescBase();
00107 
00108   // Clone the object.
00109   virtual TableMeasDescBase* clone() const;
00110 
00111   // Assignment operator.
00112   TableMeasDescBase& operator= (const TableMeasDescBase& that);
00113 
00114   // Makes the descriptor persistent.
00115   // <group>
00116   void write (TableDesc&);
00117   void write (Table&);
00118   // </group>
00119 
00120   // Make the descriptor persistent if there was no refcode vector.
00121   // This is only needed for old tables without such vectors.
00122   void writeIfOld (const Table&);
00123 
00124   // Get the name of the underlying column.
00125   const String& columnName() const
00126     { return itsValue.columnName(); }
00127 
00128   // Return the reference code.
00129   uInt getRefCode() const
00130     { return itsRef.getRefCode(); }
00131 
00132   // Returns True if the reference varies per row.
00133   Bool isRefCodeVariable() const
00134     { return itsRef.isRefCodeVariable(); }
00135 
00136   // Returns the name of the ref code column when the ref code is variable.
00137   // The null string is returned if the ref code is not variable.
00138   const String& refColumnName() const
00139     { return itsRef.columnName(); }
00140 
00141   // Returns a reference to its measure reference descriptor.
00142   const TableMeasRefDesc& getRefDesc() const
00143     { return itsRef; }
00144 
00145   // Get the name of the offset column. Empty string is returned if no
00146   // offset.
00147   const String& offsetColumnName() const
00148     { return itsRef.offsetColumnName(); }
00149 
00150   // Returns True if an offset has been defined.
00151   Bool hasOffset() const
00152     { return itsRef.hasOffset(); }
00153 
00154   // Returns True if the offset is variable.
00155   Bool isOffsetVariable() const
00156     { return itsRef.isOffsetVariable(); }
00157 
00158   // Returns True if the offset is variable and is stored in an
00159   // ArrayMeasColumn, i.e., offsets are stored per element.
00160   Bool isOffsetArray() const
00161     { return itsRef.isOffsetArray(); }
00162 
00163   // Returns a reference to the offset.
00164   const Measure& getOffset() const
00165     { return itsRef.getOffset(); }
00166 
00167   // Returns the descriptors measure type as a String.
00168   const String& type() const
00169     { return itsMeasType.type(); }
00170 
00171   // Returns the reference code for this object given a string.  Throws
00172   // an exception if the refString is invalid for this object.
00173   uInt refCode (const String& refString) const
00174     { return itsMeasType.refCode(refString); }
00175 
00176   // Translates the refCode for the descriptors measure type.
00177   const String& refType (uInt refCode) const
00178     { return itsMeasType.refType(refCode); }
00179 
00180   // Return the Units of the Measure values
00181   const Vector<Unit>& getUnits() const
00182     { return itsUnits; }
00183 
00184   // Reset the refCode, offset, or units.
00185   // It overwrites the value used when defining the TableMeasDesc.
00186   // It is only possible if it was defined as fixed for the entire column.
00187   // <group>
00188   void resetRefCode (uInt refCode)
00189     { itsRef.resetRefCode (refCode); }
00190   void resetOffset (const Measure& offset)
00191     { itsRef.resetOffset (offset); }
00192   void resetUnits (const Vector<Unit>& units);
00193   // </group>
00194 
00195   // Reconstructs the object for the given table and column name.
00196   static TableMeasDescBase* reconstruct (const Table& tab,
00197                                          const String& columnName);
00198 
00199   // Does this column contain table measures?
00200   static Bool hasMeasures (const TableColumn& column);
00201 
00202 protected:
00203   // Set the initial reference codes and types in the table.
00204   void initTabRef (const MeasureHolder& measHolder);
00205 
00206   // Set the measure and possible units.
00207   void setMeasUnits (const Measure& meas,
00208                      const Vector<Quantum<Double> >& val,
00209                      const Vector<Unit>& units);
00210 
00211 private:
00212   TableMeasValueDesc itsValue;    //# The measure value column.
00213   TableMeasRefDesc   itsRef;      //# The reference.
00214   //# this gives access to the columns Measure type etc
00215   TableMeasType itsMeasType;
00216   Vector<Unit>  itsUnits;
00217 };
00218 
00219 
00220 
00221 } //# NAMESPACE CASACORE - END
00222 
00223 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1