Line data Source code
1 : //# CTEnums.cc: Implementation of CTEnums.h
2 : //# Copyright (C) 2011
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 : //# $Id$
27 : //----------------------------------------------------------------------------
28 :
29 : #include <synthesis/CalTables/CTEnums.h>
30 :
31 : using namespace casacore;
32 : namespace casa { //# NAMESPACE CASA - BEGIN
33 :
34 : //----------------------------------------------------------------------------
35 :
36 : // Static data initialization
37 : std::map <Int, String> CTEnums::theirFieldMap;
38 : std::map <Int, DataType> CTEnums::theirTypeMap;
39 :
40 : //----------------------------------------------------------------------------
41 :
42 1 : void CTEnums::initMaps ()
43 : {
44 : // Initialize the static map containing the field names.
45 : // Skip this step if already initialized.
46 : //
47 1 : if ( theirFieldMap.size( ) == 0 ) {
48 18 : theirFieldMap = {
49 : {ANTENNA1, "ANTENNA1"},
50 : {ANTENNA2, "ANTENNA2"},
51 : {SCAN_NUMBER, "SCAN_NUMBER"},
52 : {TIME, "TIME"},
53 : {TIME_EXTRA_PREC, "TIME_EXTRA_PREC"},
54 : {INTERVAL, "INTERVAL"},
55 : {ARRAY_ID, "ARRAY_ID"},
56 : {FIELD_ID, "FIELD_ID"},
57 : {OBSERVATION_ID, "OBSERVATION_ID"},
58 : {SPECTRAL_WINDOW_ID, "SPECTRAL_WINDOW_ID"},
59 :
60 : {CPARAM, "CPARAM"},
61 : {FPARAM, "FPARAM"},
62 : {PARAMERR, "PARAMERR"},
63 : {FLAG, "FLAG"},
64 : {SNR, "SNR"},
65 : {WEIGHT, "WEIGHT"}
66 17 : };
67 :
68 : };
69 :
70 : // Initialize the static map containing the basic field data types
71 : // Skip this step if already initialized.
72 : //
73 1 : if ( theirTypeMap.size( ) == 0 ) {
74 1 : theirTypeMap = {
75 : {ANTENNA1, TpInt},
76 : {ANTENNA2, TpInt},
77 : {SCAN_NUMBER, TpInt},
78 : {TIME, TpDouble},
79 : {TIME_EXTRA_PREC, TpDouble},
80 : {INTERVAL, TpDouble},
81 : {ARRAY_ID, TpInt},
82 : {FIELD_ID, TpInt},
83 : {OBSERVATION_ID, TpInt},
84 : {SPECTRAL_WINDOW_ID, TpInt},
85 :
86 : {CPARAM, TpComplex},
87 : {FPARAM, TpFloat},
88 : {PARAMERR, TpFloat},
89 : {FLAG, TpBool},
90 : {SNR, TpFloat},
91 : {WEIGHT, TpFloat}
92 1 : };
93 :
94 : }
95 :
96 1 : };
97 :
98 : //----------------------------------------------------------------------------
99 :
100 4251884 : String CTEnums::fieldName (Int enumField)
101 : {
102 : // Static function to look up the field name:
103 : // Inputs:
104 : // enumField Int Field enumeration.
105 : // Outputs:
106 : // fieldName String Field name.
107 : // Exceptions:
108 : // Exception if invalid field enumeration.
109 : //
110 : // Initialize map if empty
111 4251884 : if ( theirFieldMap.size( ) == 0 ) initMaps();
112 :
113 : // Return the column name
114 4251884 : return theirFieldMap[enumField];
115 : };
116 :
117 : //----------------------------------------------------------------------------
118 :
119 0 : Block<String> CTEnums::fieldNames (const Vector<Int>& enumFields)
120 : {
121 : // Static function to look up a set of field names:
122 : // Inputs:
123 : // enumFields const Vector<Int>& Field enumerations.
124 : // Outputs:
125 : // fieldNames Block<String> Field names.
126 : // Exceptions:
127 : // Exception if invalid field enumeration.
128 : //
129 : // Return the column names
130 0 : uInt nFields = enumFields.nelements();
131 0 : Block<String> names(nFields);
132 0 : for (uInt i=0; i < nFields; i++) {
133 0 : names[i] = fieldName (enumFields(i));
134 : };
135 0 : return names;
136 : };
137 :
138 : //----------------------------------------------------------------------------
139 :
140 0 : DataType CTEnums::basicType (Int enumField)
141 : {
142 : // Static function to look up the basic field data type:
143 : // Inputs:
144 : // enumField Int Field enumeration.
145 : // Outputs:
146 : // basicType DataType Basic data type
147 : // Exceptions:
148 : // Exception if invalid field enumeration.
149 : //
150 : // Initialize map if empty
151 0 : if ( theirTypeMap.size( ) == 0 ) initMaps();
152 :
153 : // Return the column name
154 0 : return theirTypeMap[enumField];
155 : };
156 :
157 : //----------------------------------------------------------------------------
158 :
159 :
160 :
161 :
162 :
163 :
164 :
165 : } //# NAMESPACE CASA - END
166 :
|