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