LCOV - code coverage report
Current view: top level - msvis/MSVis - VisBufferComponents2.cc (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 103 126 81.7 %
Date: 2024-12-11 20:54:31 Functions: 11 15 73.3 %

          Line data    Source code
       1             : /*
       2             :  * VisBufferComponents.cc
       3             :  *
       4             :  *  Created on: Aug 20, 2012
       5             :  *      Author: jjacobs
       6             :  */
       7             : 
       8             : #include <stdcasa/UtilJ.h>
       9             : #include <msvis/MSVis/VisBufferComponents2.h>
      10             : #include <map>
      11             : 
      12             : using namespace std;
      13             : 
      14             : using namespace casacore;
      15             : namespace casa {
      16             : 
      17             : namespace vi {
      18             : 
      19             : const VisBufferComponents2 VisBufferComponents2::all_p = initializeAll ();
      20             : 
      21             : VisBufferComponents2
      22      556574 : VisBufferComponents2::operator+ (const VisBufferComponents2 & other) const
      23             : {
      24      556574 :     VisBufferComponents2 result = * this;
      25             : 
      26      556574 :     result.set_p.insert (other.begin(), other.end());
      27             : 
      28      556574 :     return result;
      29           0 : }
      30             : 
      31             : VisBufferComponents2 &
      32           0 : VisBufferComponents2::operator+= (const VisBufferComponents2 & other)
      33             : {
      34           0 :     if (& other != this){
      35             : 
      36           0 :         set_p.insert (other.set_p.begin(), other.set_p.end());
      37             :     }
      38             : 
      39           0 :     return * this;
      40             : }
      41             : 
      42             : VisBufferComponents2 &
      43       93656 : VisBufferComponents2::operator+= (VisBufferComponent2 componentToAdd)
      44             : {
      45       93656 :     set_p.insert (componentToAdd);
      46             : 
      47       93656 :     return * this;
      48             : }
      49             : 
      50             : 
      51             : VisBufferComponents2
      52           0 : VisBufferComponents2::all ()
      53             : {
      54           0 :     return all_p;
      55             : }
      56             : 
      57             : VisBufferComponents2::const_iterator
      58      759549 : VisBufferComponents2::begin () const
      59             : {
      60      759549 :     return set_p.begin();
      61             : }
      62             : 
      63             : Bool
      64     6406986 : VisBufferComponents2::contains (VisBufferComponent2 component) const
      65             : {
      66     6406986 :     return utilj::containsKey (component, set_p);
      67             : }
      68             : 
      69             : Bool
      70       14691 : VisBufferComponents2::empty () const
      71             : {
      72       14691 :     return set_p.empty();
      73             : }
      74             : 
      75             : VisBufferComponents2::const_iterator
      76     1316123 : VisBufferComponents2::end () const
      77             : {
      78     1316123 :     return set_p.end();
      79             : }
      80             : 
      81             : VisBufferComponents2
      82           0 : VisBufferComponents2::exceptThese (std::initializer_list<VisBufferComponent2> components)
      83             : {
      84           0 :    VisBufferComponents2 result = all();
      85             : 
      86           0 :    for (auto component : components){
      87           0 :        result.set_p.erase (component);
      88             :    }
      89             : 
      90           0 :    return result;
      91           0 : }
      92             : 
      93             : VisBufferComponents2
      94          10 : VisBufferComponents2::initializeAll ()
      95             : {
      96             : 
      97          10 :     VisBufferComponents2 all;
      98             : 
      99             : //    VisBufferComponent2
     100             : //    writableComponents [] = {Corrected,
     101             : //                             CorrectedCube,
     102             : //                             Flag,
     103             : //                             FlagCube,
     104             : //                             FlagRow,
     105             : //                             Model,
     106             : //                             ModelCube,
     107             : //                             Observed,
     108             : //                             ObservedCube,
     109             : //                             Sigma,
     110             : //                             SigmaMat,
     111             : //                             Weight,
     112             : //                             WeightMat,
     113             : //                             Unknown};
     114             : 
     115         680 :     for (Int i = 0; i < static_cast<int> (VisBufferComponent2::N_VisBufferComponents2); i++){
     116             : 
     117         670 :         all.set_p.insert (static_cast<VisBufferComponent2> (i));
     118             :     }
     119             : 
     120          10 :     return all;
     121           0 : }
     122             : 
     123             : 
     124             : String
     125        2002 : VisBufferComponents2::name (VisBufferComponent2 id)
     126             : {
     127             :    // This method is called only occasionally for debugging so at this time a
     128             :    // brute-force implmentation is acceptable.
     129             : 
     130        2002 :     map<VisBufferComponent2,String> names;
     131             : 
     132        2002 :     names [VisBufferComponent2::AllBeamOffsetsZero] = "AllBeamOffsetsZero";
     133        2002 :     names [VisBufferComponent2::AntennaMounts] = "AntennaMounts";
     134        2002 :     names [VisBufferComponent2::Antenna1] = "Antenna1";
     135        2002 :     names [VisBufferComponent2::Antenna2] = "Antenna2";
     136        2002 :     names [VisBufferComponent2::ArrayId] = "ArrayId";
     137        2002 :     names [VisBufferComponent2::BeamOffsets] = "BeamOffsets";
     138        2002 :     names [VisBufferComponent2::CorrType] = "CorrType";
     139        2002 :     names [VisBufferComponent2::DataDescriptionIds] = "DataDescriptionIds";
     140        2002 :     names [VisBufferComponent2::Direction1] = "Direction1";
     141        2002 :     names [VisBufferComponent2::Direction2] = "Direction2";
     142        2002 :     names [VisBufferComponent2::Exposure] = "Exposure";
     143        2002 :     names [VisBufferComponent2::Feed1] = "Feed1";
     144        2002 :     names [VisBufferComponent2::FeedPa1] = "FeedPa1";
     145        2002 :     names [VisBufferComponent2::Feed2] = "Feed2";
     146        2002 :     names [VisBufferComponent2::FeedPa2] = "FeedPa2";
     147        2002 :     names [VisBufferComponent2::FieldId] = "FieldId";
     148             :     //names [VisBufferComponent2::Flag] = "Flag";
     149        2002 :     names [VisBufferComponent2::FlagCategory] = "FlagCategory";
     150        2002 :     names [VisBufferComponent2::FlagCube] = "FlagCube";
     151        2002 :     names [VisBufferComponent2::FlagCubes] = "FlagCubes";
     152        2002 :     names [VisBufferComponent2::FlagRow] = "FlagRow";
     153        2002 :     names [VisBufferComponent2::FloatData] = "FloatData";
     154        2002 :     names [VisBufferComponent2::Frequencies] = "Frequencies";
     155        2002 :     names [VisBufferComponent2::ImagingWeight] = "ImagingWeight";
     156        2002 :     names [VisBufferComponent2::JonesC] = "JonesC";
     157        2002 :     names [VisBufferComponent2::NAntennas] = "NAntennas";
     158        2002 :     names [VisBufferComponent2::NChannels] = "NChannels";
     159        2002 :     names [VisBufferComponent2::NCorrelations] = "NCorrelations";
     160        2002 :     names [VisBufferComponent2::NRows] = "NRows";
     161        2002 :     names [VisBufferComponent2::NShapes] = "NShapes";
     162        2002 :     names [VisBufferComponent2::NRowsPerShape] = "NRowsPerShape";
     163        2002 :     names [VisBufferComponent2::NChannelsPerShape] = "NChannelsPerShape";
     164        2002 :     names [VisBufferComponent2::NCorrelationsPerShape] = "NCorrelationsPerShape";
     165        2002 :     names [VisBufferComponent2::ObservationId] = "ObservationId";
     166        2002 :     names [VisBufferComponent2::PhaseCenter] = "PhaseCenter";
     167        2002 :     names [VisBufferComponent2::PolFrame] = "PolFrame";
     168        2002 :     names [VisBufferComponent2::PolarizationId] = "PolarizationId";
     169        2002 :     names [VisBufferComponent2::ProcessorId] = "ProcessorId";
     170        2002 :     names [VisBufferComponent2::ReceptorAngles] = "ReceptorAngles";
     171        2002 :     names [VisBufferComponent2::RowIds] = "RowIds";
     172        2002 :     names [VisBufferComponent2::Scan] = "Scan";
     173        2002 :     names [VisBufferComponent2::Sigma] = "Sigma";
     174        2002 :     names [VisBufferComponent2::Sigmas] = "Sigmas";
     175        2002 :     names [VisBufferComponent2::SpectralWindows] = "SpectralWindows";
     176        2002 :     names [VisBufferComponent2::StateId] = "StateId";
     177        2002 :     names [VisBufferComponent2::Time] = "Time";
     178        2002 :     names [VisBufferComponent2::TimeCentroid] = "TimeCentroid";
     179        2002 :     names [VisBufferComponent2::TimeInterval] = "TimeInterval";
     180        2002 :     names [VisBufferComponent2::Weight] = "Weight";
     181        2002 :     names [VisBufferComponent2::Weights] = "Weights";
     182        2002 :     names [VisBufferComponent2::WeightScaled] = "WeightScaled";
     183        2002 :     names [VisBufferComponent2::WeightSpectrum] = "WeightSpectrum";
     184        2002 :     names [VisBufferComponent2::WeightSpectra] = "WeightSpectra";
     185        2002 :     names [VisBufferComponent2::SigmaSpectrum] = "SigmaSpectrum";
     186        2002 :     names [VisBufferComponent2::SigmaSpectra] = "SigmaSpectra";
     187        2002 :     names [VisBufferComponent2::WeightSpectrumScaled] = "WeightSpectrumScaled";
     188        2002 :     names [VisBufferComponent2::Uvw] = "Uvw";
     189        2002 :     names [VisBufferComponent2::VisibilityCorrected] = "VisibilityCorrected";
     190        2002 :     names [VisBufferComponent2::VisibilityModel] = "VisibilityModel";
     191        2002 :     names [VisBufferComponent2::VisibilityObserved] = "VisibilityObserved";
     192        2002 :     names [VisBufferComponent2::VisibilityCubeCorrected] = "VisibilityCubeCorrected";
     193        2002 :     names [VisBufferComponent2::VisibilityCubeModel] = "VisibilityCubeModel";
     194        2002 :     names [VisBufferComponent2::VisibilityCubeObserved] = "VisibilityCubeObserved";
     195        2002 :     names [VisBufferComponent2::VisibilityCubeFloat] = "VisibilityCubeFloat";
     196        2002 :     names [VisBufferComponent2::VisibilityCubesCorrected] = "VisibilityCubesCorrected";
     197        2002 :     names [VisBufferComponent2::VisibilityCubesModel] = "VisibilityCubesModel";
     198        2002 :     names [VisBufferComponent2::VisibilityCubesObserved] = "VisibilityCubesObserved";
     199        2002 :     names [VisBufferComponent2::VisibilityCubesFloat] = "VisibilityCubesFloat";
     200             : 
     201        2002 :     assert (names.size() == static_cast<int> (VisBufferComponent2::N_VisBufferComponents2));
     202             : 
     203        4004 :     return names [id];
     204        2002 : }
     205             : 
     206             : VisBufferComponents2
     207       12530 : VisBufferComponents2::none ()
     208             : {
     209       12530 :     return VisBufferComponents2 ();
     210             : }
     211             : 
     212             : VisBufferComponents2
     213      556574 : VisBufferComponents2::singleton (VisBufferComponent2 component)
     214             : {
     215      556574 :     VisBufferComponents2 result;
     216      556574 :     result.set_p.insert (component);
     217             : 
     218      556574 :     return result;
     219           0 : }
     220             : 
     221             : VisBufferComponents2
     222       61887 : VisBufferComponents2::these (std::initializer_list<VisBufferComponent2> components)
     223             : {
     224       61887 :    VisBufferComponents2 result;
     225             : 
     226     1263999 :    for (auto component : components){
     227     1202112 :        result.set_p.insert (component);
     228             :    }
     229             : 
     230       61887 :    return result;
     231           0 : }
     232             : 
     233             : 
     234             : String
     235           0 : VisBufferComponents2::toString () const
     236             : {
     237           0 :     String result = "{";
     238             : 
     239           0 :     for (const_iterator i = begin(); i != end(); i++){
     240           0 :         result += name (*i) + ",";
     241             :     }
     242             : 
     243           0 :     * result.rbegin() = '}'; // replace last "," with "}"
     244             : 
     245           0 :     return result;
     246           0 : }
     247             : 
     248             : 
     249             : } // end namespace vi
     250             : 
     251             : using namespace casacore;
     252             : } // end namespace casa

Generated by: LCOV version 1.16