TableMeasColumn.h

Go to the documentation of this file.
00001 //# TableMeasColumn.h: Access to Measure Columns in Tables
00002 //# Copyright (C) 1999,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 //# $Id$
00027 
00028 #ifndef MEASURES_TABLEMEASCOLUMN_H
00029 #define MEASURES_TABLEMEASCOLUMN_H
00030 
00031 //# Includes
00032 #include <casacore/casa/aips.h>
00033 #include <casacore/tables/Tables/TableColumn.h>
00034 #include <casacore/casa/Utilities/CountedPtr.h>
00035 
00036 namespace casacore { //# NAMESPACE CASACORE - BEGIN
00037 
00038 //# Forward Declarations
00039 class String;
00040 class Table;
00041 class TableMeasDescBase;
00042 
00043 
00044 // <summary>
00045 // Read only access to table scalar Measure columns.
00046 // </summary>
00047 
00048 // <use visibility=export>
00049 
00050 // <reviewed reviewer="Bob Garwood" date="1999/12/23" tests="tTableMeasures.cc">
00051 // </reviewed>
00052 
00053 // <prerequisite>
00054 //# Classes you should understand before using this one.
00055 //   <li> <linkto module=Measures>Measures</linkto>
00056 //   <li> <linkto module=Tables>Tables</linkto>
00057 //   <li> <linkto class=TableMeasDesc>TableMeasDesc</linkto>
00058 // </prerequisite>
00059 
00060 // <synopsis>
00061 // TableMeasColumn is the base class for the templated classes
00062 // <linkto class=ScalarMeasColumn>ScalarMeasColumn</linkto> and
00063 // <linkto class=ArrayMeasColumn>ArrayMeasColumn</linkto>
00064 // which give access to table columns containing
00065 // <linkto module=Measures>measures</linkto>.
00066 //
00067 // This base class offers some common functionality like getting
00068 // the column name and testing if a row of the column contains a value.
00069 // Its main function is <src>measDesc()</src>, which gives access
00070 // to the <linkto class=TableMeasDescBase>TableMeasDescBase</linkto>
00071 // object containing a description of the measure column.
00072 // </synopsis>
00073 
00074 // <example>
00075 // <srcblock>
00076 //     // Create the object for measure column Time1.
00077 //     TableMeasColumn timeCol(tab, "Time1");
00078 //      
00079 //     // print some details about the column
00080 //     if (timeCol.measDesc().isRefCodeVariable()) {
00081 //        cout << "The column has variable references." << endl;
00082 //     } else {
00083 //         cout << "The fixed MeasRef for the column is: "
00084 //              << timeCol.getMeasRef() << endl;
00085 //     }
00086 // </srcblock>
00087 // </example>
00088 
00089 // <motivation>
00090 // This class contains the common functionality for the templated
00091 // derived classes.
00092 // </motivation>
00093 
00094 //# <todo asof="$DATE:$">
00095 //# </todo>
00096 
00097 
00098 class TableMeasColumn
00099 {
00100 public:
00101   // The default constructor creates a null object.  Useful for creating
00102   // arrays of ScalarMeasColumn objects.  Attempting to use a null object
00103   // will produce a segmentation fault so care needs to be taken to
00104   // initialise the objects first by using attach().
00105   // An ScalarMeasColumn object can be tested if it is null by using the
00106   // isNull() member.
00107   TableMeasColumn();
00108 
00109   // Create the ScalarMeasColumn from the table and column Name.
00110   TableMeasColumn (const Table& tab, const String& columnName);
00111 
00112   // Copy constructor (copy semantics).
00113   TableMeasColumn (const TableMeasColumn& that);
00114 
00115   virtual ~TableMeasColumn();
00116 
00117   // Change the reference to another column.
00118   void reference (const TableMeasColumn& that);
00119 
00120   // Attach another column to the object.
00121   void attach (const Table& tab, const String& columnName);
00122 
00123   // Tests if a row contains a Measure (i.e., if the row has a defined
00124   // value).
00125   Bool isDefined (uInt rownr) const;
00126 
00127   // Get access to the TableMeasDescBase describing the column.
00128   // <group>
00129   const TableMeasDescBase& measDesc() const
00130     { return *itsDescPtr; }
00131   TableMeasDescBase& measDesc()
00132     { return *itsDescPtr; }
00133   // </group>
00134 
00135   // Test if the object is null.
00136   Bool isNull() const
00137     { return itsDescPtr.null(); }
00138 
00139   // Throw an exception if the object is null.
00140   void throwIfNull() const;
00141 
00142   // Get the name of the column.
00143   const String& columnName() const;
00144 
00145   // Get the Table object this column belongs to.
00146   Table table() const;
00147 
00148   // Is the column a scalar measures column?
00149   // It is if the underlying column is a scalar column or an array
00150   // column with a fixed 1-dimensional shape.
00151   // <br>Otherwise it is an array measures column.
00152   // <note role=caution>
00153   // It is not 100% determined if a measure column is an array or a scalar.
00154   // If the underlying table column is an array with a variable shape,
00155   // this function will see it as an array measure column. However,
00156   // it might be accessible as a scalar measure column.
00157   // </note>
00158   Bool isScalar() const;
00159 
00160 protected:
00161   //# The measure's value is represented by this many data components.
00162   uInt itsNvals;
00163   //# The Measure Column description.
00164   CountedPtr<TableMeasDescBase> itsDescPtr;
00165   //# The data column.
00166   TableColumn itsTabDataCol;
00167   //# Does the measure column have a variable reference or offset?
00168   Bool itsVarRefFlag;
00169   Bool itsVarOffFlag;
00170 
00171 private:
00172   // Assignment makes no sense in a readonly class.
00173   // Declaring this operator private makes it unusable.
00174   TableMeasColumn& operator= (const TableMeasColumn& that);
00175 };
00176 
00177 // For backwards compatibility:
00178 
00179 #define ROTableMeasColumn TableMeasColumn
00180 
00181 } //# NAMESPACE CASACORE - END
00182 
00183 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1