Line data Source code
1 : //# CalTableDesc2.cc: Implementation of CalTableDesc2.h
2 : //# Copyright (C) 1996,1997,1998,1999,2000,2001,2002,2003
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: casa-feedback@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/CalTableDesc2.h>
30 : #include <msvis/MSVis/MSCalEnums.h>
31 : #include <casacore/tables/Tables/ScaColDesc.h>
32 : #include <casacore/tables/Tables/ArrColDesc.h>
33 : #include <casacore/tables/Tables/SetupNewTab.h>
34 : #include <casacore/tables/Tables/TableRecord.h>
35 : #include <casacore/measures/TableMeasures/TableMeasRefDesc.h>
36 : #include <casacore/measures/TableMeasures/TableMeasValueDesc.h>
37 : #include <casacore/measures/TableMeasures/TableMeasDesc.h>
38 : #include <casacore/measures/TableMeasures/TableQuantumDesc.h>
39 : #include <casacore/measures/Measures/MEpoch.h>
40 : #include <casacore/measures/Measures/MFrequency.h>
41 : #include <casacore/measures/Measures/MDirection.h>
42 : #include <casacore/casa/Containers/Record.h>
43 : #include <casacore/casa/Arrays/IPosition.h>
44 :
45 : using namespace casacore;
46 : namespace casa { //# NAMESPACE CASA - BEGIN
47 :
48 : //----------------------------------------------------------------------------
49 : /*
50 : CalTableDesc2::CalTableDesc2() : itsCalMainDesc(defaultCalMain("",VisCalParType::COMPLEX)),
51 : itsCalHistoryDesc(defaultCalHistory()),
52 : itsCalDescDesc(defaultCalDesc())
53 : {
54 : // Default null constructor for calibration table description (v2.0)
55 : // Output to private data:
56 : // itsCalMainDesc TableDesc Table descriptor (cal_main)
57 : // itsCalHistoryDesc TableDesc Table descriptor (cal_history)
58 : // itsCalDescDesc TableDesc Table descriptor (cal_desc)
59 : //
60 : };
61 : */
62 : /*
63 : CalTableDesc2::CalTableDesc2 (const String& jonesType, const Int& parType) :
64 : itsCalMainDesc(defaultCalMain(jonesType, parType)),
65 : itsCalHistoryDesc(defaultCalHistory()), itsCalDescDesc(defaultCalDesc())
66 : {
67 : // Constructor for calibration table description (v2.0)
68 : // Inputs:
69 : // type const String& Cal table type (eg. "P Jones")
70 : // Output to private data:
71 : // itsCalMainDesc TableDesc Table descriptor (cal_main)
72 : // itsCalHistoryDesc TableDesc Table descriptor (cal_history)
73 : // itsCalDescDesc TableDesc Table descriptor (cal_desc)
74 : //
75 : parType_ = parType;
76 : };
77 : */
78 :
79 0 : CalTableDesc2::CalTableDesc2() : itsCalMainDesc(""),
80 0 : itsCalHistoryDesc(""),
81 0 : itsCalDescDesc("")
82 : {
83 : // Default null constructor for calibration table description (v2.0)
84 : // Output to private data:
85 : // itsCalMainDesc TableDesc Table descriptor (cal_main)
86 : // itsCalHistoryDesc TableDesc Table descriptor (cal_history)
87 : // itsCalDescDesc TableDesc Table descriptor (cal_desc)
88 : //
89 0 : };
90 : //----------------------------------------------------------------------------
91 :
92 0 : CalTableDesc2::CalTableDesc2 (const String& jonesType, const Int& parType) :
93 0 : itsCalMainDesc(defaultCalMain(jonesType, parType)),
94 0 : itsCalHistoryDesc(defaultCalHistory()),
95 0 : itsCalDescDesc(defaultCalDesc())
96 : {
97 : // Constructor for calibration table description (v2.0)
98 : // Inputs:
99 : // type const String& Cal table type (eg. "P Jones")
100 : // Output to private data:
101 : // itsCalMainDesc TableDesc Table descriptor (cal_main)
102 : // itsCalHistoryDesc TableDesc Table descriptor (cal_history)
103 : // itsCalDescDesc TableDesc Table descriptor (cal_desc)
104 : //
105 : // init(jonesType, parType);
106 0 : parType_ = parType;
107 0 : };
108 :
109 : //----------------------------------------------------------------------------
110 :
111 0 : void CalTableDesc2::init(const String& jonesType, const Int& parType)
112 : {
113 0 : itsCalMainDesc.add(defaultCalMain(jonesType, parType));
114 0 : itsCalHistoryDesc.add(defaultCalHistory());
115 0 : itsCalDescDesc.add(defaultCalDesc());
116 0 : };
117 :
118 : //----------------------------------------------------------------------------
119 :
120 0 : TableDesc CalTableDesc2::defaultCalHistory()
121 : {
122 : // Generate the default table descriptor for the Cal History sub-table
123 : // Output:
124 : // defaultCalHistory TableDesc Default Cal History descriptor
125 : //
126 0 : TableDesc td ("Cal History", "2.0", TableDesc::Scratch);
127 0 : td.comment() = "Calibration history sub-table";
128 0 : td.addColumn (ScalarColumnDesc <String> (MSC::fieldName (MSC::CAL_PARMS),
129 : ColumnDesc::Direct));
130 0 : td.addColumn (ScalarColumnDesc <String> (MSC::fieldName (MSC::CAL_TABLES),
131 : ColumnDesc::Direct));
132 0 : td.addColumn (ScalarColumnDesc <String> (MSC::fieldName (MSC::CAL_SELECT),
133 : ColumnDesc::Direct));
134 0 : td.addColumn (ScalarColumnDesc <String> (MSC::fieldName (MSC::CAL_NOTES),
135 : ColumnDesc::Direct));
136 0 : return td;
137 0 : };
138 :
139 : //----------------------------------------------------------------------------
140 :
141 0 : TableDesc CalTableDesc2::defaultCalDesc()
142 : {
143 : // Generate the default table descriptor for the Cal Desc sub-table
144 : // Output:
145 : // defaultCalDesc TableDesc Default Cal Desc descriptor
146 : //
147 0 : TableDesc td ("Cal Desc", "1.0", TableDesc::Scratch);
148 0 : td.comment() = "Calibration description sub-table";
149 0 : td.addColumn (ScalarColumnDesc <Int> (MSC::fieldName (MSC::NUM_SPW),
150 : ColumnDesc::Direct));
151 0 : td.addColumn (ArrayColumnDesc <Int> (MSC::fieldName (MSC::NUM_CHAN)));
152 0 : td.addColumn (ScalarColumnDesc <Int> (MSC::fieldName (MSC::NUM_RECEPTORS),
153 : ColumnDesc::Direct));
154 0 : td.addColumn (ScalarColumnDesc <Int> (MSC::fieldName (MSC::N_JONES),
155 : ColumnDesc::Direct));
156 : td.addColumn
157 0 : (ArrayColumnDesc <Int> (MSC::fieldName (MSC::SPECTRAL_WINDOW_ID)));
158 0 : td.addColumn (ArrayColumnDesc <Double> (MSC::fieldName (MSC::CHAN_FREQ)));
159 0 : td.addColumn (ScalarColumnDesc <Int> (MSC::fieldName (MSC::MEAS_FREQ_REF),
160 : ColumnDesc::Direct));
161 0 : td.addColumn (ArrayColumnDesc <Double> (MSC::fieldName (MSC::CHAN_WIDTH)));
162 0 : td.addColumn (ArrayColumnDesc <Int> (MSC::fieldName (MSC::CHAN_RANGE)));
163 0 : td.addColumn (ArrayColumnDesc <String>
164 0 : (MSC::fieldName (MSC::POLARIZATION_TYPE)));
165 0 : td.addColumn (ScalarColumnDesc <String> (MSC::fieldName (MSC::JONES_TYPE),
166 : ColumnDesc::Direct));
167 0 : td.addColumn (ScalarColumnDesc <String> (MSC::fieldName (MSC::MS_NAME),
168 : ColumnDesc::Direct));
169 :
170 : // Add TableMeasures information for Measures/Quanta columns
171 : //
172 : // CHAN_FREQ
173 0 : TableMeasValueDesc chanFreqMeasVal (td, MSC::fieldName(MSC::CHAN_FREQ));
174 0 : TableMeasRefDesc chanFreqMeasRef (td, MSC::fieldName (MSC::MEAS_FREQ_REF));
175 0 : TableMeasDesc<MFrequency> chanFreqMeasCol (chanFreqMeasVal, chanFreqMeasRef);
176 0 : chanFreqMeasCol.write (td);
177 :
178 : // CHAN_WIDTH
179 0 : TableQuantumDesc chanWidthQuantDesc (td, MSC::fieldName (MSC::CHAN_WIDTH),
180 0 : Unit ("Hz"));
181 0 : chanWidthQuantDesc.write (td);
182 :
183 0 : return td;
184 0 : };
185 :
186 : //----------------------------------------------------------------------------
187 :
188 0 : TableDesc CalTableDesc2::defaultCalMain (const String& jonesType, const Int& parType)
189 : {
190 : // Generate the default table descriptor for the Cal Main sub-table
191 : // Input:
192 : // type const String& Cal table type (eg. "P Jones")
193 : // Output:
194 : // defaultCalMain TableDesc Default Cal Main descriptor
195 : //
196 : // Set up table descriptor and add comment field
197 0 : TableDesc td (jonesType, "1.0", TableDesc::Scratch);
198 0 : td.comment() = jonesType + " calibration table";
199 :
200 : // Define keywords
201 0 : Record keyWordRec;
202 : // Cal_desc and cal_history indices
203 0 : keyWordRec.define (MSC::fieldName (MSC::CAL_DESC_ID), 0);
204 0 : keyWordRec.define (MSC::fieldName (MSC::CAL_HISTORY_ID), 0);
205 : // Add to table descriptor
206 0 : td.rwKeywordSet().assign (keyWordRec);
207 :
208 : // Cal Main columns (MS Main indices)
209 0 : td.addColumn (ScalarColumnDesc <Double> (MSC::fieldName (MSC::TIME),
210 : ColumnDesc::Direct));
211 : td.addColumn
212 0 : (ScalarColumnDesc <Double> (MSC::fieldName (MSC::TIME_EXTRA_PREC),
213 : ColumnDesc::Direct));
214 0 : td.addColumn (ScalarColumnDesc <Double> (MSC::fieldName (MSC::INTERVAL),
215 : ColumnDesc::Direct));
216 0 : td.addColumn (ScalarColumnDesc <Int> (MSC::fieldName (MSC::ANTENNA1),
217 : ColumnDesc::Direct));
218 0 : td.addColumn (ScalarColumnDesc <Int> (MSC::fieldName (MSC::FEED1),
219 : ColumnDesc::Direct));
220 0 : td.addColumn (ScalarColumnDesc <Int> (MSC::fieldName (MSC::FIELD_ID),
221 : ColumnDesc::Direct));
222 0 : td.addColumn (ScalarColumnDesc <Int> (MSC::fieldName (MSC::ARRAY_ID),
223 : ColumnDesc::Direct));
224 0 : td.addColumn (ScalarColumnDesc <Int> (MSC::fieldName (MSC::OBSERVATION_ID),
225 : ColumnDesc::Direct));
226 0 : td.addColumn (ScalarColumnDesc <Int> (MSC::fieldName (MSC::SCAN_NUMBER),
227 : ColumnDesc::Direct));
228 0 : td.addColumn (ScalarColumnDesc <Int> (MSC::fieldName (MSC::PROCESSOR_ID),
229 : ColumnDesc::Direct));
230 0 : td.addColumn (ScalarColumnDesc <Int> (MSC::fieldName (MSC::STATE_ID),
231 : ColumnDesc::Direct));
232 0 : td.addColumn (ScalarColumnDesc <Int> (MSC::fieldName (MSC::PHASE_ID),
233 : ColumnDesc::Direct));
234 0 : td.addColumn (ScalarColumnDesc <Int> (MSC::fieldName (MSC::PULSAR_BIN),
235 : ColumnDesc::Direct));
236 0 : td.addColumn (ScalarColumnDesc <Int> (MSC::fieldName (MSC::PULSAR_GATE_ID),
237 : ColumnDesc::Direct));
238 :
239 : // Secondary MS indices (from MS sub-tables)
240 0 : td.addColumn (ScalarColumnDesc <Int> (MSC::fieldName (MSC::FREQ_GROUP),
241 : ColumnDesc::Direct));
242 0 : td.addColumn (ScalarColumnDesc<String> (MSC::fieldName(MSC::FREQ_GROUP_NAME),
243 : ColumnDesc::Direct));
244 0 : td.addColumn (ScalarColumnDesc <String> (MSC::fieldName (MSC::FIELD_NAME),
245 : ColumnDesc::Direct));
246 0 : td.addColumn (ScalarColumnDesc <String> (MSC::fieldName (MSC::FIELD_CODE),
247 : ColumnDesc::Direct));
248 0 : td.addColumn (ScalarColumnDesc <String> (MSC::fieldName (MSC::SOURCE_NAME),
249 : ColumnDesc::Direct));
250 0 : td.addColumn (ScalarColumnDesc <String> (MSC::fieldName (MSC::SOURCE_CODE),
251 : ColumnDesc::Direct));
252 0 : td.addColumn (ScalarColumnDesc <Int> (MSC::fieldName(MSC::CALIBRATION_GROUP),
253 : ColumnDesc::Direct));
254 :
255 : // Gain values
256 0 : if (parType == VisCalEnum::COMPLEX)
257 0 : td.addColumn (ArrayColumnDesc <Complex> (MSC::fieldName (MSC::GAIN)));
258 : else
259 : // td.addColumn (ArrayColumnDesc <Float> (MSC::fieldName (MSC::SOLVE_PAR)));
260 0 : td.addColumn (ArrayColumnDesc <Float> (MSC::fieldName (MSC::GAIN)));
261 :
262 : // Reference frame for antenna-based corrections
263 0 : td.addColumn (ArrayColumnDesc <Int> (MSC::fieldName (MSC::REF_ANT)));
264 0 : td.addColumn (ArrayColumnDesc <Int> (MSC::fieldName (MSC::REF_FEED)));
265 0 : td.addColumn (ArrayColumnDesc <Int> (MSC::fieldName (MSC::REF_RECEPTOR)));
266 0 : td.addColumn (ArrayColumnDesc <Double> (MSC::fieldName(MSC::REF_FREQUENCY)));
267 0 : td.addColumn (ScalarColumnDesc <Int> (MSC::fieldName (MSC::MEAS_FREQ_REF),
268 : ColumnDesc::Direct));
269 0 : td.addColumn (ArrayColumnDesc <Double> (MSC::fieldName(MSC::REF_DIRECTION)));
270 0 : td.addColumn (ScalarColumnDesc <Int> (MSC::fieldName (MSC::MEAS_DIR_REF),
271 : ColumnDesc::Direct));
272 :
273 : // Pointers to Cal_Desc and Cal_History sub-tables
274 0 : td.addColumn (ScalarColumnDesc <Int> (MSC::fieldName (MSC::CAL_DESC_ID),
275 : ColumnDesc::Direct));
276 0 : td.addColumn (ScalarColumnDesc <Int> (MSC::fieldName (MSC::CAL_HISTORY_ID),
277 : ColumnDesc::Direct));
278 :
279 : // Add TableMeasures information for designated Measures/Quanta columns
280 : //
281 : // TIME
282 0 : TableMeasValueDesc timeMeasVal (td, MSC::fieldName (MSC::TIME));
283 0 : TableMeasRefDesc timeMeasRef (MEpoch::DEFAULT);
284 0 : TableMeasDesc<MEpoch> timeMeasCol (timeMeasVal, timeMeasRef);
285 0 : timeMeasCol.write (td);
286 :
287 : // TIME fix Unit
288 0 : TableQuantumDesc timeQuantDesc (td, MSC::fieldName (MSC::TIME),
289 0 : Unit ("s"));
290 0 : timeQuantDesc.write (td);
291 :
292 : // TIME_EXTRA_PREC
293 0 : TableQuantumDesc timeEPQuantDesc (td, MSC::fieldName (MSC::TIME_EXTRA_PREC),
294 0 : Unit ("s"));
295 0 : timeEPQuantDesc.write (td);
296 :
297 : // INTERVAL
298 0 : TableQuantumDesc intervalQuantDesc (td, MSC::fieldName(MSC::INTERVAL),
299 0 : Unit ("s"));
300 0 : intervalQuantDesc.write (td);
301 :
302 : // REF_FREQUENCY
303 0 : TableMeasValueDesc refFreqMeasVal (td, MSC::fieldName (MSC::REF_FREQUENCY));
304 0 : TableMeasRefDesc refFreqMeasRef (td, MSC::fieldName (MSC::MEAS_FREQ_REF));
305 0 : TableMeasDesc<MFrequency> refFreqMeasCol (refFreqMeasVal, refFreqMeasRef);
306 0 : refFreqMeasCol.write (td);
307 :
308 : // REF_DIRECTION
309 0 : TableMeasValueDesc refDirMeasVal (td, MSC::fieldName (MSC::REF_DIRECTION));
310 0 : TableMeasRefDesc refDirMeasRef (td, MSC::fieldName (MSC::MEAS_DIR_REF));
311 0 : TableMeasDesc<MDirection> refDirMeasCol (refDirMeasVal, refDirMeasRef);
312 0 : refDirMeasCol.write (td);
313 :
314 0 : return td;
315 0 : };
316 :
317 : //----------------------------------------------------------------------------
318 :
319 0 : TableDesc& CalTableDesc2::calMainDesc()
320 : {
321 : // Return the main calibration table descriptor
322 : // Output:
323 : // calMainDesc TableDesc Table descriptor (cal_main)
324 : //
325 0 : return itsCalMainDesc;
326 : };
327 :
328 : //----------------------------------------------------------------------------
329 :
330 0 : TableDesc CalTableDesc2::calHistoryDesc()
331 : {
332 : // Return the calibration history sub-table descriptor
333 : // Output:
334 : // calHistoryDesc TableDesc Table descriptor (cal_history)
335 : //
336 0 : return itsCalHistoryDesc;
337 : };
338 :
339 : //----------------------------------------------------------------------------
340 :
341 0 : TableDesc CalTableDesc2::calDescDesc()
342 : {
343 : // Return the calibration description sub-table descriptor
344 : // Output:
345 : // calDescDesc TableDesc Table descriptor (cal_desc)
346 : //
347 0 : return itsCalDescDesc;
348 : };
349 :
350 : //----------------------------------------------------------------------------
351 :
352 0 : TableDesc CalTableDesc2::defaultFitDesc()
353 : {
354 : // Generate the default table descriptor for fit parameters
355 : // Output:
356 : // defaultFitDesc TableDesc Table descriptor (fit parameters)
357 : //
358 0 : TableDesc td;
359 0 : td.addColumn (ScalarColumnDesc <Bool>
360 0 : (MSC::fieldName (MSC::TOTAL_SOLUTION_OK), ColumnDesc::Direct));
361 0 : td.addColumn (ScalarColumnDesc <Float> (MSC::fieldName (MSC::TOTAL_FIT),
362 : ColumnDesc::Direct));
363 0 : td.addColumn (ScalarColumnDesc <Float>
364 0 : (MSC::fieldName (MSC::TOTAL_FIT_WEIGHT), ColumnDesc::Direct));
365 0 : td.addColumn (ArrayColumnDesc <Bool> (MSC::fieldName (MSC::SOLUTION_OK)));
366 0 : td.addColumn (ArrayColumnDesc <Float> (MSC::fieldName (MSC::FIT)));
367 0 : td.addColumn (ArrayColumnDesc <Float> (MSC::fieldName (MSC::FIT_WEIGHT)));
368 0 : td.addColumn (ArrayColumnDesc <Bool> (MSC::fieldName (MSC::FLAG)));
369 0 : td.addColumn (ArrayColumnDesc <Float> (MSC::fieldName (MSC::SNR)));
370 :
371 0 : return td;
372 0 : };
373 :
374 : //----------------------------------------------------------------------------
375 :
376 0 : TableDesc CalTableDesc2::defaultPolyDesc()
377 : {
378 : // Generate the default table descriptor for general polynomial parameters
379 : // Output:
380 : // defaultPolyDesc TableDesc Table descriptor (poly parameters)
381 : //
382 0 : TableDesc td;
383 :
384 : // Additional parameters required for general polynomials
385 : // POLY_TYPE - polynomial type (e.g. Chebyshev or spline)
386 : // POLY_MODE - polynomial y-value (e.g. A&P)
387 : // SCALE_FACTOR - overall polynomial scale factor
388 : // VALID_DOMAIN - valid polynomial domain [x_0, x_1]
389 : // N_POLY_AMP - polynomial degree for amplitude
390 : // N_POLY_PHASE - polynomial degree for phase
391 : // POLY_COEFF_AMP - polynomial coefficients for amplitude
392 : // POLY_COEFF_PHASE - polynomial coefficients for phase
393 : // PHASE_UNITS - units for the phase polynomial
394 : //
395 0 : td.addColumn(ScalarColumnDesc<String>(MSC::fieldName(MSC::POLY_TYPE)));
396 0 : td.addColumn(ScalarColumnDesc<String>(MSC::fieldName(MSC::POLY_MODE)));
397 0 : td.addColumn(ScalarColumnDesc<Complex>(MSC::fieldName(MSC::SCALE_FACTOR)));
398 0 : td.addColumn(ArrayColumnDesc<Double>(MSC::fieldName(MSC::VALID_DOMAIN)));
399 0 : td.addColumn(ScalarColumnDesc<Int>(MSC::fieldName(MSC::N_POLY_AMP)));
400 0 : td.addColumn(ScalarColumnDesc<Int>(MSC::fieldName(MSC::N_POLY_PHASE)));
401 0 : td.addColumn(ArrayColumnDesc<Double>(MSC::fieldName(MSC::POLY_COEFF_AMP)));
402 0 : td.addColumn(ArrayColumnDesc<Double>(MSC::fieldName(MSC::POLY_COEFF_PHASE)));
403 0 : td.addColumn(ScalarColumnDesc<String>(MSC::fieldName(MSC::PHASE_UNITS)));
404 :
405 0 : return td;
406 0 : };
407 :
408 : //----------------------------------------------------------------------------
409 :
410 0 : TableDesc CalTableDesc2::defaultSplineDesc()
411 : {
412 : // Generate the default table descriptor for spline polynomial parameters
413 : // Output:
414 : // defaultSplineDesc TableDesc Table descriptor (spline parameters)
415 : //
416 0 : TableDesc td;
417 :
418 : // Additional parameters required for spline polynomials.
419 : // N_KNOTS_AMP - number of spline knots in amplitude
420 : // N_KNOTS_PHASE - number of spline knots in phase
421 : // SPLINE_KNOTS_AMP - spline knot positions for amplitude
422 : // SPLINE_KNOTS_PHASE - spline knot positions for phase
423 : //
424 0 : td.addColumn(ScalarColumnDesc<Int>(MSC::fieldName(MSC::N_KNOTS_AMP)));
425 0 : td.addColumn(ScalarColumnDesc<Int>(MSC::fieldName(MSC::N_KNOTS_PHASE)));
426 0 : td.addColumn(ArrayColumnDesc<Double>(MSC::fieldName(MSC::SPLINE_KNOTS_AMP)));
427 0 : td.addColumn(ArrayColumnDesc<Double>
428 0 : (MSC::fieldName(MSC::SPLINE_KNOTS_PHASE)));
429 :
430 0 : return td;
431 0 : };
432 :
433 : //----------------------------------------------------------------------------
434 :
435 0 : TableDesc CalTableDesc2::insertDesc (const TableDesc& tableDesc,
436 : const TableDesc& insert,
437 : const String& insertAfter)
438 : {
439 : // Insert one table descriptor into another after a specified
440 : // column name.
441 : // Input:
442 : // tableDesc const TableDesc& Input table descriptor
443 : // insert const TableDesc& Table descriptor to be inserted
444 : // insertAfter const String& Column name to insert after
445 : // Output:
446 : // insertDesc TableDesc Output table descriptor
447 : //
448 0 : TableDesc tdout;
449 : ColumnDesc* colDesc;
450 0 : Int ncol = tableDesc.ncolumn();
451 : Int jcol;
452 :
453 : // Loop over the number of columns in the input table descriptor
454 0 : for (jcol = 0; jcol < ncol; jcol++) {
455 0 : colDesc = new ColumnDesc (tableDesc.columnDesc (jcol));
456 :
457 : // Add column to output descriptor
458 0 : tdout.addColumn (*colDesc);
459 :
460 : // Insert second descriptor if appropriate
461 0 : if (colDesc->name() == insertAfter) {
462 0 : tdout.add (insert);
463 : };
464 0 : delete colDesc;
465 : };
466 :
467 0 : return tdout;
468 0 : };
469 :
470 : //----------------------------------------------------------------------------
471 :
472 0 : void CalTableDesc2::addDesc (const TableDesc& tableDesc, TableDesc& addTo)
473 : {
474 0 : addTo.add(tableDesc);
475 0 : }
476 :
477 : //----------------------------------------------------------------------------
478 :
479 :
480 : } //# NAMESPACE CASA - END
481 :
|