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 #include <casacore/casa/OS/Mutex.h>
42 
43 namespace casacore { //# NAMESPACE CASACORE - BEGIN
44 
45 //# Forward declarations
46 class SetupNewTable;
47 
48 // <summary>
49 // An implementation class for the MeasurementSet to share code.
50 // </summary>
51 
52 // <use visibility=local>
53 
54 // <reviewed reviewer="Bob Garwood" date="1997/02/01" tests="" demos="">
55 
56 // <prerequisite>
57 // <li> <linkto class=MeasurementSet:description">MeasurementSet</linkto>
58 // </prerequisite>
59 //
60 // <etymology>
61 // The MSTableImpl implements non-templated static functions shared by
62 // all MSTable objects.
63 // </etymology>
64 //
65 // <synopsis>
66 // MSTableImpl is only for internal use by the MeasurementSet base class
67 // MSTable.
68 // </synopsis>
69 //
70 // <example>
71 // </example>
72 //
73 //
74 // <motivation>
75 // The reasons for existance for this class are: sharing of code between
76 // the various MeasurementSet Tables and avoiding duplicate code in the
77 // instantiations of MSTable
78 // </motivation>
79 //
80 // <todo asof="1996/2/22">
81 // </todo>
82 
84 {
85 public:
86  // Convert a name to a ColEnum,
87  static Int mapType(const SimpleOrderedMap<Int,String>& map,
88  const String &name);
89 
90  // add a column to a TableDesc
91  // An exception is thrown for an invalid data type. This indicates a
92  // programming error in this class when this occurs.
93  // If option!=0 shape is used to set the shape of the column and
94  // option defines the type of column (ColumnDesc::Fixed/Direct).
95  // If option==0, shape is ignored and ndim is used to specify the
96  // array dimension if any.
97  // If refCol is not empty, a column with variable reference will be
98  // created, note that refCol should already exist in td.
99  // <thrown>
100  // <li> AipsError
101  // </thrown>
102  static void addColumnToDesc(TableDesc &td, const String& colName,
103  Int colDType, const String& colComment,
104  const String& colUnit,
105  const String& colMeasure,
106  Int ndim, const IPosition & shape,
107  Int option, const String& refCol);
108 
109  // add a keyword to a TableDesc
110  // An exception is thrown for an invalid data type. This indicates a
111  // missing data type in the code..
112  // <thrown>
113  // <li> AipsError
114  // </thrown>
115  static void addKeyToDesc(TableDesc& td, const String& keyName,
116  Int keyDType, const String& keyComment);
117 
118  // add a MeasureColumn for the specified Measure, with default reference
119  static void addMeasColumn(TableDesc &td, const String& colName,
120  const String& colMeasure, const String& refCol);
121 
122  // Add the compress option for the given column to the TableDesc.
123  static void addColumnCompression (TableDesc&, const String& colName,
124  Bool autoScale, const String& type);
125 
126  // Setup the compression data managers if needed.
128 
129  // Define an entry in the column maps
130  static void colMapDef(SimpleOrderedMap<Int,String>& colMap,
131  SimpleOrderedMap<Int,Int>& colDTypeMap,
132  SimpleOrderedMap<Int,String>& colCommentMap,
133  SimpleOrderedMap<Int,String>& colUnitMap,
134  SimpleOrderedMap<Int,String>& colMeasureTypeMap,
135  Int col,
136  const String& colName,
137  Int colType,
138  const String& colComment,
139  const String& colUnit,
140  const String& colMeasureType);
141 
142  // Define an entry in the keyword maps
143  static void keyMapDef(SimpleOrderedMap<Int,String>& keyMap,
144  SimpleOrderedMap<Int,Int>& keyDTypeMap,
145  SimpleOrderedMap<Int,String>& keyCommentMap,
146  Int key,
147  const String& keyName,
148  Int keyType,
149  const String& keyComment);
150 
151  // tableDesc convenience functions
152  // <group>
153 
154  // check that a TableDesc is valid
155  static Bool validate(const TableDesc& tabDesc,
156  const TableDesc& requiredTD);
157 
158  // check that the keyword set is valid
159  static Bool validate(const TableRecord& tabRec,
160  const TableDesc& requiredTD);
161 
162  // </group>
163 
164  // Return a table that references all columns in this table except for
165  // those given in writableColumns, those are empty and writable.
166  static Table referenceCopy(const Table& tab, const String& newTableName,
167  const Block<String>& writableColumns);
168  // Initialize all MeasurementSet static mappings
169  static void init();
170 
171 private:
174 };
175 
176 
177 } //# NAMESPACE CASACORE - END
178 
179 #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:149
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:83
static SetupNewTable & setupCompression(SetupNewTable &)
Setup the compression data managers if needed.
static Bool initialized_p
Definition: MSTableImpl.h:173
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:2151
A hierarchical collection of named fields of various types.
Definition: TableRecord.h:182
Wrapper around a pthreads mutex.
Definition: Mutex.h:49
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.
static Mutex initialized_mutex
Definition: MSTableImpl.h:172
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.