casa
$Rev:20696$
|
00001 //# MSTableImpl.h: Helper class to implement common functions for MS Tables 00002 //# Copyright (C) 1996,2000,2001,2002 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: MSTableImpl.h 20299 2008-04-03 05:56:44Z gervandiepen $ 00028 00029 #ifndef MS_MSTABLEIMPL_H 00030 #define MS_MSTABLEIMPL_H 00031 00032 //# Includes 00033 #include <casa/aips.h> 00034 #include <casa/Utilities/DataType.h> 00035 #include <tables/Tables/Table.h> 00036 #include <casa/Containers/SimOrdMap.h> 00037 #include <casa/BasicSL/String.h> 00038 #include <tables/Tables/TableDesc.h> 00039 #include <casa/Utilities/Fallible.h> 00040 #include <casa/Arrays/Vector.h> 00041 00042 namespace casa { //# NAMESPACE CASA - BEGIN 00043 00044 //# Forward declarations 00045 class SetupNewTable; 00046 00047 // <summary> 00048 // An implementation class for the MeasurementSet to share code. 00049 // </summary> 00050 00051 // <use visibility=local> 00052 00053 // <reviewed reviewer="Bob Garwood" date="1997/02/01" tests="" demos=""> 00054 00055 // <prerequisite> 00056 // <li> <linkto class=MeasurementSet:description">MeasurementSet</linkto> 00057 // </prerequisite> 00058 // 00059 // <etymology> 00060 // The MSTableImpl implements non-templated static functions shared by 00061 // all MSTable objects. 00062 // </etymology> 00063 // 00064 // <synopsis> 00065 // MSTableImpl is only for internal use by the MeasurementSet base class 00066 // MSTable. 00067 // </synopsis> 00068 // 00069 // <example> 00070 // </example> 00071 // 00072 // 00073 // <motivation> 00074 // The reasons for existance for this class are: sharing of code between 00075 // the various MeasurementSet Tables and avoiding duplicate code in the 00076 // instantiations of MSTable 00077 // </motivation> 00078 // 00079 // <todo asof="1996/2/22"> 00080 // </todo> 00081 00082 class MSTableImpl 00083 { 00084 public: 00085 // Convert a name to a ColEnum, 00086 static Int mapType(const SimpleOrderedMap<Int,String>& map, 00087 const String &name); 00088 00089 // add a column to a TableDesc 00090 // An exception is thrown for an invalid data type. This indicates a 00091 // programming error in this class when this occurs. 00092 // If option!=0 shape is used to set the shape of the column and 00093 // option defines the type of column (ColumnDesc::Fixed/Direct). 00094 // If option==0, shape is ignored and ndim is used to specify the 00095 // array dimension if any. 00096 // If refCol is not empty, a column with variable reference will be 00097 // created, note that refCol should already exist in td. 00098 // <thrown> 00099 // <li> AipsError 00100 // </thrown> 00101 static void addColumnToDesc(TableDesc &td, const String& colName, 00102 Int colDType, const String& colComment, 00103 const String& colUnit, 00104 const String& colMeasure, 00105 Int ndim, const IPosition & shape, 00106 Int option, const String& refCol); 00107 00108 // add a keyword to a TableDesc 00109 // An exception is thrown for an invalid data type. This indicates a 00110 // missing data type in the code.. 00111 // <thrown> 00112 // <li> AipsError 00113 // </thrown> 00114 static void addKeyToDesc(TableDesc& td, const String& keyName, 00115 Int keyDType, const String& keyComment); 00116 00117 // add a MeasureColumn for the specified Measure, with default reference 00118 static void addMeasColumn(TableDesc &td, const String& colName, 00119 const String& colMeasure, const String& refCol); 00120 00121 // Add the compress option for the given column to the TableDesc. 00122 static void addColumnCompression (TableDesc&, const String& colName, 00123 Bool autoScale, const String& type); 00124 00125 // Setup the compression data managers if needed. 00126 static SetupNewTable& setupCompression (SetupNewTable&); 00127 00128 // Define an entry in the column maps 00129 static void colMapDef(SimpleOrderedMap<Int,String>& colMap, 00130 SimpleOrderedMap<Int,Int>& colDTypeMap, 00131 SimpleOrderedMap<Int,String>& colCommentMap, 00132 SimpleOrderedMap<Int,String>& colUnitMap, 00133 SimpleOrderedMap<Int,String>& colMeasureTypeMap, 00134 Int col, 00135 const String& colName, 00136 Int colType, 00137 const String& colComment, 00138 const String& colUnit, 00139 const String& colMeasureType); 00140 00141 // Define an entry in the keyword maps 00142 static void keyMapDef(SimpleOrderedMap<Int,String>& keyMap, 00143 SimpleOrderedMap<Int,Int>& keyDTypeMap, 00144 SimpleOrderedMap<Int,String>& keyCommentMap, 00145 Int key, 00146 const String& keyName, 00147 Int keyType, 00148 const String& keyComment); 00149 00150 // tableDesc convenience functions 00151 // <group> 00152 00153 // check that a TableDesc is valid 00154 static Bool validate(const TableDesc& tabDesc, 00155 const TableDesc& requiredTD); 00156 00157 // check that the keyword set is valid 00158 static Bool validate(const TableRecord& tabRec, 00159 const TableDesc& requiredTD); 00160 00161 // </group> 00162 00163 // Return a table that references all columns in this table except for 00164 // those given in writableColumns, those are empty and writable. 00165 static Table referenceCopy(const Table& tab, const String& newTableName, 00166 const Block<String>& writableColumns); 00167 // Initialize all MeasurementSet static mappings 00168 static void init(); 00169 00170 private: 00171 static Bool initialized_p; 00172 }; 00173 00174 00175 } //# NAMESPACE CASA - END 00176 00177 #endif