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/casa/Utilities/DataType.h>
35 #include <casacore/tables/Tables/Table.h>
36 #include <casacore/casa/Containers/SimOrdMap.h>
37 #include <casacore/casa/BasicSL/String.h>
38 #include <casacore/tables/Tables/TableDesc.h>
39 #include <casacore/casa/Utilities/Fallible.h>
40 #include <casacore/casa/Arrays/Vector.h>
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  // Convert a name to a ColEnum,
86  static Int mapType(const SimpleOrderedMap<Int,String>& map,
87  const String &name);
88 
89  // add a column to a TableDesc
90  // An exception is thrown for an invalid data type. This indicates a
91  // programming error in this class when this occurs.
92  // If option!=0 shape is used to set the shape of the column and
93  // option defines the type of column (ColumnDesc::Fixed/Direct).
94  // If option==0, shape is ignored and ndim is used to specify the
95  // array dimension if any.
96  // If refCol is not empty, a column with variable reference will be
97  // created, note that refCol should already exist in td.
98  // <thrown>
99  // <li> AipsError
100  // </thrown>
101  static void addColumnToDesc(TableDesc &td, const String& colName,
102  Int colDType, const String& colComment,
103  const String& colUnit,
104  const String& colMeasure,
105  Int ndim, const IPosition & shape,
106  Int option, const String& refCol);
107 
108  // add a keyword to a TableDesc
109  // An exception is thrown for an invalid data type. This indicates a
110  // missing data type in the code..
111  // <thrown>
112  // <li> AipsError
113  // </thrown>
114  static void addKeyToDesc(TableDesc& td, const String& keyName,
115  Int keyDType, const String& keyComment);
116 
117  // add a MeasureColumn for the specified Measure, with default reference
118  static void addMeasColumn(TableDesc &td, const String& colName,
119  const String& colMeasure, const String& refCol);
120 
121  // Add the compress option for the given column to the TableDesc.
122  static void addColumnCompression (TableDesc&, const String& colName,
123  Bool autoScale, const String& type);
124 
125  // Setup the compression data managers if needed.
127 
128  // Define an entry in the column maps
129  static void colMapDef(SimpleOrderedMap<Int,String>& colMap,
130  SimpleOrderedMap<Int,Int>& colDTypeMap,
131  SimpleOrderedMap<Int,String>& colCommentMap,
132  SimpleOrderedMap<Int,String>& colUnitMap,
133  SimpleOrderedMap<Int,String>& colMeasureTypeMap,
134  Int col,
135  const String& colName,
136  Int colType,
137  const String& colComment,
138  const String& colUnit,
139  const String& colMeasureType);
140 
141  // Define an entry in the keyword maps
142  static void keyMapDef(SimpleOrderedMap<Int,String>& keyMap,
143  SimpleOrderedMap<Int,Int>& keyDTypeMap,
144  SimpleOrderedMap<Int,String>& keyCommentMap,
145  Int key,
146  const String& keyName,
147  Int keyType,
148  const String& keyComment);
149 
150  // tableDesc convenience functions
151  // <group>
152 
153  // check that a TableDesc is valid
154  static Bool validate(const TableDesc& tabDesc,
155  const TableDesc& requiredTD);
156 
157  // check that the keyword set is valid
158  static Bool validate(const TableRecord& tabRec,
159  const TableDesc& requiredTD);
160 
161  // </group>
162 
163  // Return a table that references all columns in this table except for
164  // those given in writableColumns, those are empty and writable.
165  static Table referenceCopy(const Table& tab, const String& newTableName,
166  const Block<String>& writableColumns);
167  // Initialize all MeasurementSet static mappings
168  static void init();
169 };
170 
171 
172 } //# NAMESPACE CASACORE - END
173 
174 #endif
A Vector of integers, for indexing into Array<T> objects.
Definition: IPosition.h:119
int Int
Definition: aipstype.h:50
Create a new table - define shapes, data managers, etc.
Definition: SetupNewTab.h:346
Main interface class to a read/write table.
Definition: Table.h:153
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 Int mapType(const SimpleOrderedMap< Int, String > &map, const String &name)
Convert a name to a ColEnum,.
An implementation class for the MeasurementSet to share code.
Definition: MSTableImpl.h:82
static SetupNewTable & setupCompression(SetupNewTable &)
Setup the compression data managers if needed.
Simple map with keys ordered.
Definition: SimOrdMap.h:69
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 void keyMapDef(SimpleOrderedMap< Int, String > &keyMap, SimpleOrderedMap< Int, Int > &keyDTypeMap, SimpleOrderedMap< Int, String > &keyCommentMap, Int key, const String &keyName, Int keyType, const String &keyComment)
Define an entry in the keyword maps.
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
static void addColumnCompression(TableDesc &, const String &colName, Bool autoScale, const String &type)
Add the compress option for the given column to the TableDesc.
static void colMapDef(SimpleOrderedMap< Int, String > &colMap, SimpleOrderedMap< Int, Int > &colDTypeMap, SimpleOrderedMap< Int, String > &colCommentMap, SimpleOrderedMap< Int, String > &colUnitMap, SimpleOrderedMap< 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.
TableExprNode shape(const TableExprNode &array)
Function operating on any scalar or array resulting in a Double array containing the shape...
Definition: ExprNode.h:2163
A hierarchical collection of named fields of various types.
Definition: TableRecord.h:182
simple 1-D array
Definition: ArrayIO.h:47
String: the storage and methods of handling collections of characters.
Definition: String.h:223
Define the structure of a Casacore table.
Definition: TableDesc.h:186
static void init()
Initialize all MeasurementSet static mappings.
this file contains all the compiler specific defines
Definition: mainpage.dox:28
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.