casacore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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>
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
A Vector of integers, for indexing into Array&lt;T&gt; objects.
Definition: IPosition.h:118
int Int
Definition: aipstype.h:50
Create a new table - define shapes, data managers, etc.
Definition: SetupNewTab.h:340
Enums for the MeasurementSet ANTENNA table.
Main interface class to a read/write table.
Definition: Table.h:157
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...
Enums for the MeasurementSet STATE table.
Definition: MSStateEnums.h:60
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 SPECTRAL_WINDOW table.
An implementation class for the MeasurementSet to share code.
Definition: MSTableImpl.h:82
Enums for the MeasurementSet DOPPLER table.
static SetupNewTable & setupCompression(SetupNewTable &)
Setup the compression data managers if needed.
Enums for the MeasurementSet FIELD table.
Definition: MSFieldEnums.h:60
Enums for the MeasurementSet WEATHER table.
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 Bool validate(const TableDesc &tabDesc, const TableDesc &requiredTD)
tableDesc convenience functions
LatticeExprNode ndim(const LatticeExprNode &expr)
1-argument function to get the dimensionality of a lattice.
static MSTableMaps initMaps(MSMainEnums *)
Define the initialization function for each MS table type.
Enums for the MeasurementSet DATA_DESCRIPTION table.
Enums for the MeasurementSet FLAG_CMD table.
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
Enums for the MeasurementSet POINTING table.
static void addColumnCompression(TableDesc &, const String &colName, Bool autoScale, const String &type)
Add the compress option for the given column to the TableDesc.
Enums for the MeasurementSet SOURCE table.
Definition: MSSourceEnums.h:60
Enums for the MeasurementSet FREQ_OFFSET table.
TableExprNode shape(const TableExprNode &array)
Function operating on any scalar or array resulting in a Double array containing the shape...
Definition: ExprNode.h:1987
A hierarchical collection of named fields of various types.
Definition: TableRecord.h:185
simple 1-D array
Definition: Allocator.h:210
A struct holding the maps used in MSTable.
Definition: MSTable.h:51
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.
Enums for the MeasurementSet PROCESSER table.
Enums for the MeasurementSet FEED table.
Definition: MSFeedEnums.h:60
Enums for the MeasurementSet HISTORY table.
String: the storage and methods of handling collections of characters.
Definition: String.h:225
Enums for the MeasurementSet SYSCAL table.
Definition: MSSysCalEnums.h:60
Define the structure of a Casacore table.
Definition: TableDesc.h:190
Enums for the MeasurementSet POLARIZATION table.
Definition: MSPolEnums.h:60
Enums for the MeasurementSet main table.
Definition: MSMainEnums.h:62
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 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.
Enums for the MeasurementSet OBSERVATION table.
Definition: MSObsEnums.h:60