casacore
MSTableImpl.h
Go to the documentation of this file.
1 //# MSTableImpl.h: Helper class to implement common functions for MS Tables
2 //# Copyright (C) 1996,2000,2001,2002
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This library is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU Library General Public License as published by
7 //# the Free Software Foundation; either version 2 of the License, or (at your
8 //# option) any later version.
9 //#
10 //# This library is distributed in the hope that it will be useful, but WITHOUT
11 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 //# License for more details.
14 //#
15 //# You should have received a copy of the GNU Library General Public License
16 //# along with this library; if not, write to the Free Software Foundation,
17 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 //#
19 //# Correspondence concerning AIPS++ should be addressed as follows:
20 //# Internet email: aips2-request@nrao.edu.
21 //# Postal address: AIPS++ Project Office
22 //# National Radio Astronomy Observatory
23 //# 520 Edgemont Road
24 //# Charlottesville, VA 22903-2475 USA
25 //#
26 //#
27 //# $Id$
28 
29 #ifndef MS_MSTABLEIMPL_H
30 #define MS_MSTABLEIMPL_H
31 
32 //# Includes
33 #include <casacore/casa/aips.h>
34 #include <casacore/ms/MeasurementSets/MeasurementSet.h>
35 #include <casacore/casa/Utilities/DataType.h>
36 #include <casacore/tables/Tables/Table.h>
37 #include <casacore/casa/BasicSL/String.h>
38 #include <casacore/tables/Tables/TableDesc.h>
39 #include <casacore/casa/Arrays/Vector.h>
40 #include <map>
41 
42 namespace casacore { //# NAMESPACE CASACORE - BEGIN
43 
44 //# Forward declarations
45 class SetupNewTable;
46 
47 // <summary>
48 // An implementation class for the MeasurementSet to share code.
49 // </summary>
50 
51 // <use visibility=local>
52 
53 // <reviewed reviewer="Bob Garwood" date="1997/02/01" tests="" demos="">
54 
55 // <prerequisite>
56 // <li> <linkto class=MeasurementSet:description">MeasurementSet</linkto>
57 // </prerequisite>
58 //
59 // <etymology>
60 // The MSTableImpl implements non-templated static functions shared by
61 // all MSTable objects.
62 // </etymology>
63 //
64 // <synopsis>
65 // MSTableImpl is only for internal use by the MeasurementSet base class
66 // MSTable.
67 // </synopsis>
68 //
69 // <example>
70 // </example>
71 //
72 //
73 // <motivation>
74 // The reasons for existance for this class are: sharing of code between
75 // the various MeasurementSet Tables and avoiding duplicate code in the
76 // instantiations of MSTable
77 // </motivation>
78 //
79 // <todo asof="1996/2/22">
80 // </todo>
81 
83 {
84 public:
85  // add a column to a TableDesc
86  // An exception is thrown for an invalid data type. This indicates a
87  // programming error in this class when this occurs.
88  // If option!=0 shape is used to set the shape of the column and
89  // option defines the type of column (ColumnDesc::Fixed/Direct).
90  // If option==0, shape is ignored and ndim is used to specify the
91  // array dimension if any.
92  // If refCol is not empty, a column with variable reference will be
93  // created, note that refCol should already exist in td.
94  // <thrown>
95  // <li> AipsError
96  // </thrown>
97  static void addColumnToDesc(TableDesc &td, const String& colName,
98  Int colDType, const String& colComment,
99  const String& colUnit,
100  const String& colMeasure,
101  Int ndim, const IPosition & shape,
102  Int option, const String& refCol);
103 
104  // add a keyword to a TableDesc
105  // An exception is thrown for an invalid data type. This indicates a
106  // missing data type in the code..
107  // <thrown>
108  // <li> AipsError
109  // </thrown>
110  static void addKeyToDesc(TableDesc& td, const String& keyName,
111  Int keyDType, const String& keyComment);
112 
113  // add a MeasureColumn for the specified Measure, with default reference
114  static void addMeasColumn(TableDesc &td, const String& colName,
115  const String& colMeasure, const String& refCol);
116 
117  // Add the compress option for the given column to the TableDesc.
118  static void addColumnCompression (TableDesc&, const String& colName,
119  Bool autoScale, const String& type);
120 
121  // Setup the compression data managers if needed.
123 
124  // Define an entry in the column maps
125  static void colMapDef(std::map<Int,String>& colMap,
126  std::map<Int,Int>& colDTypeMap,
127  std::map<Int,String>& colCommentMap,
128  std::map<Int,String>& colUnitMap,
129  std::map<Int,String>& colMeasureTypeMap,
130  Int col,
131  const String& colName,
132  Int colType,
133  const String& colComment,
134  const String& colUnit,
135  const String& colMeasureType);
136 
137  // Define an entry in the keyword maps
138  static void keyMapDef(std::map<Int,String>& keyMap,
139  std::map<Int,Int>& keyDTypeMap,
140  std::map<Int,String>& keyCommentMap,
141  Int key,
142  const String& keyName,
143  Int keyType,
144  const String& keyComment);
145 
146  // tableDesc convenience functions
147  // <group>
148 
149  // check that a TableDesc is valid
150  static Bool validate(const TableDesc& tabDesc,
151  const TableDesc& requiredTD);
152 
153  // check that the keyword set is valid
154  static Bool validate(const TableRecord& tabRec,
155  const TableDesc& requiredTD);
156 
157  // </group>
158 
159  // Return a table that references all columns in this table except for
160  // those given in writableColumns, those are empty and writable.
161  static Table referenceCopy(const Table& tab, const String& newTableName,
162  const Block<String>& writableColumns);
163 
164  // Define the initialization function for each MS table type.
165  // <group>
184  // </group>
185 };
186 
187 
188 } //# NAMESPACE CASACORE - END
189 
190 #endif
simple 1-D array
Definition: Block.h:200
Enums for the MeasurementSet ANTENNA table.
Enums for the MeasurementSet DATA_DESCRIPTION table.
Enums for the MeasurementSet DOPPLER table.
Enums for the MeasurementSet FEED table.
Definition: MSFeedEnums.h:60
Enums for the MeasurementSet FIELD table.
Definition: MSFieldEnums.h:60
Enums for the MeasurementSet FLAG_CMD table.
Enums for the MeasurementSet FREQ_OFFSET table.
Enums for the MeasurementSet HISTORY table.
Enums for the MeasurementSet main table.
Definition: MSMainEnums.h:62
Enums for the MeasurementSet OBSERVATION table.
Definition: MSObsEnums.h:60
Enums for the MeasurementSet POINTING table.
Enums for the MeasurementSet POLARIZATION table.
Definition: MSPolEnums.h:60
Enums for the MeasurementSet PROCESSER table.
Enums for the MeasurementSet SOURCE table.
Definition: MSSourceEnums.h:60
Enums for the MeasurementSet SPECTRAL_WINDOW table.
Enums for the MeasurementSet STATE table.
Definition: MSStateEnums.h:60
Enums for the MeasurementSet SYSCAL table.
Definition: MSSysCalEnums.h:60
static MSTableMaps initMaps(MSSpectralWindowEnums *)
static void addColumnCompression(TableDesc &, const String &colName, Bool autoScale, const String &type)
Add the compress option for the given column to the TableDesc.
static Bool validate(const TableRecord &tabRec, const TableDesc &requiredTD)
check that the keyword set is valid
static MSTableMaps initMaps(MSWeatherEnums *)
static Table referenceCopy(const Table &tab, const String &newTableName, const Block< String > &writableColumns)
Return a table that references all columns in this table except for those given in writableColumns,...
static void addColumnToDesc(TableDesc &td, const String &colName, Int colDType, const String &colComment, const String &colUnit, const String &colMeasure, Int ndim, const IPosition &shape, Int option, const String &refCol)
add a column to a TableDesc An exception is thrown for an invalid data type.
static MSTableMaps initMaps(MSDopplerEnums *)
static MSTableMaps initMaps(MSObservationEnums *)
static MSTableMaps initMaps(MSProcessorEnums *)
static MSTableMaps initMaps(MSFlagCmdEnums *)
static Bool validate(const TableDesc &tabDesc, const TableDesc &requiredTD)
tableDesc convenience functions
static MSTableMaps initMaps(MSFeedEnums *)
static MSTableMaps initMaps(MSFreqOffsetEnums *)
static MSTableMaps initMaps(MSSysCalEnums *)
static MSTableMaps initMaps(MSMainEnums *)
Define the initialization function for each MS table type.
static MSTableMaps initMaps(MSPolarizationEnums *)
static void addKeyToDesc(TableDesc &td, const String &keyName, Int keyDType, const String &keyComment)
add a keyword to a TableDesc An exception is thrown for an invalid data type.
static SetupNewTable & setupCompression(SetupNewTable &)
Setup the compression data managers if needed.
static MSTableMaps initMaps(MSStateEnums *)
static MSTableMaps initMaps(MSHistoryEnums *)
static MSTableMaps initMaps(MSDataDescriptionEnums *)
static void colMapDef(std::map< Int, String > &colMap, std::map< Int, Int > &colDTypeMap, std::map< Int, String > &colCommentMap, std::map< Int, String > &colUnitMap, std::map< Int, String > &colMeasureTypeMap, Int col, const String &colName, Int colType, const String &colComment, const String &colUnit, const String &colMeasureType)
Define an entry in the column maps.
static MSTableMaps initMaps(MSAntennaEnums *)
static MSTableMaps initMaps(MSSourceEnums *)
static void addMeasColumn(TableDesc &td, const String &colName, const String &colMeasure, const String &refCol)
add a MeasureColumn for the specified Measure, with default reference
static MSTableMaps initMaps(MSFieldEnums *)
static MSTableMaps initMaps(MSPointingEnums *)
static void keyMapDef(std::map< Int, String > &keyMap, std::map< Int, Int > &keyDTypeMap, std::map< Int, String > &keyCommentMap, Int key, const String &keyName, Int keyType, const String &keyComment)
Define an entry in the keyword maps.
Enums for the MeasurementSet WEATHER table.
Create a new table - define shapes, data managers, etc.
Definition: SetupNewTab.h:341
String: the storage and methods of handling collections of characters.
Definition: String.h:225
this file contains all the compiler specific defines
Definition: mainpage.dox:28
LatticeExprNode ndim(const LatticeExprNode &expr)
1-argument function to get the dimensionality of a lattice.
TableExprNode shape(const TableExprNode &array)
Function operating on any scalar or array resulting in a Double array containing the shape.
Definition: ExprNode.h:1987
int Int
Definition: aipstype.h:50
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42