LCOV - code coverage report
Current view: top level - synthesis/CalTables - CTEnums.cc (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 27 37 73.0 %
Date: 2024-12-11 20:54:31 Functions: 2 4 50.0 %

          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: 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/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           2 : void CTEnums::initMaps ()
      43             : {
      44             : // Initialize the static map containing the field names.
      45             : // Skip this step if already initialized.
      46             : //
      47           2 :   if ( theirFieldMap.size( ) == 0 ) {
      48          34 :       theirFieldMap = {
      49           2 :           {ANTENNA1, "ANTENNA1"},
      50           2 :           {ANTENNA2, "ANTENNA2"},
      51           2 :           {SCAN_NUMBER, "SCAN_NUMBER"},
      52           2 :           {TIME, "TIME"},
      53           2 :           {TIME_EXTRA_PREC, "TIME_EXTRA_PREC"},
      54           2 :           {INTERVAL, "INTERVAL"},
      55           2 :           {ARRAY_ID, "ARRAY_ID"},
      56           2 :           {FIELD_ID, "FIELD_ID"},
      57           2 :           {OBSERVATION_ID, "OBSERVATION_ID"},
      58           2 :           {SPECTRAL_WINDOW_ID, "SPECTRAL_WINDOW_ID"},
      59             : 
      60           2 :           {CPARAM, "CPARAM"},
      61           2 :           {FPARAM, "FPARAM"},
      62           2 :           {PARAMERR, "PARAMERR"},
      63           2 :           {FLAG, "FLAG"},
      64           2 :           {SNR, "SNR"},
      65           4 :           {WEIGHT, "WEIGHT"}
      66          34 :       };
      67             : 
      68             :   };
      69             : 
      70             : // Initialize the static map containing the basic field data types
      71             : // Skip this step if already initialized.
      72             : //
      73           2 :   if ( theirTypeMap.size( ) == 0 ) {
      74           2 :       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           2 :       };
      93             : 
      94             :   }
      95             : 
      96           2 : };
      97             : 
      98             : //----------------------------------------------------------------------------
      99             : 
     100     5032364 : 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     5032364 :   if ( theirFieldMap.size( ) == 0 ) initMaps();
     112             :   
     113             :   // Return the column name
     114     5032364 :   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           0 : };
     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             : 

Generated by: LCOV version 1.16