LCOV - code coverage report
Current view: top level - msvis/MSVis - VisBufferComponents2.cc (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 91 126 72.2 %
Date: 2024-10-12 00:35:29 Functions: 7 15 46.7 %

          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           0 : VisBufferComponents2::operator+ (const VisBufferComponents2 & other) const
      23             : {
      24           0 :     VisBufferComponents2 result = * this;
      25             : 
      26           0 :     result.set_p.insert (other.begin(), other.end());
      27             : 
      28           0 :     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         657 : VisBufferComponents2::operator+= (VisBufferComponent2 componentToAdd)
      44             : {
      45         657 :     set_p.insert (componentToAdd);
      46             : 
      47         657 :     return * this;
      48             : }
      49             : 
      50             : 
      51             : VisBufferComponents2
      52           0 : VisBufferComponents2::all ()
      53             : {
      54           0 :     return all_p;
      55             : }
      56             : 
      57             : VisBufferComponents2::const_iterator
      58           0 : VisBufferComponents2::begin () const
      59             : {
      60           0 :     return set_p.begin();
      61             : }
      62             : 
      63             : Bool
      64       65752 : VisBufferComponents2::contains (VisBufferComponent2 component) const
      65             : {
      66       65752 :     return utilj::containsKey (component, set_p);
      67             : }
      68             : 
      69             : Bool
      70          83 : VisBufferComponents2::empty () const
      71             : {
      72          83 :     return set_p.empty();
      73             : }
      74             : 
      75             : VisBufferComponents2::const_iterator
      76           0 : VisBufferComponents2::end () const
      77             : {
      78           0 :     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        1549 : 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        1549 :     map<VisBufferComponent2,String> names;
     131             : 
     132        1549 :     names [VisBufferComponent2::AllBeamOffsetsZero] = "AllBeamOffsetsZero";
     133        1549 :     names [VisBufferComponent2::AntennaMounts] = "AntennaMounts";
     134        1549 :     names [VisBufferComponent2::Antenna1] = "Antenna1";
     135        1549 :     names [VisBufferComponent2::Antenna2] = "Antenna2";
     136        1549 :     names [VisBufferComponent2::ArrayId] = "ArrayId";
     137        1549 :     names [VisBufferComponent2::BeamOffsets] = "BeamOffsets";
     138        1549 :     names [VisBufferComponent2::CorrType] = "CorrType";
     139        1549 :     names [VisBufferComponent2::DataDescriptionIds] = "DataDescriptionIds";
     140        1549 :     names [VisBufferComponent2::Direction1] = "Direction1";
     141        1549 :     names [VisBufferComponent2::Direction2] = "Direction2";
     142        1549 :     names [VisBufferComponent2::Exposure] = "Exposure";
     143        1549 :     names [VisBufferComponent2::Feed1] = "Feed1";
     144        1549 :     names [VisBufferComponent2::FeedPa1] = "FeedPa1";
     145        1549 :     names [VisBufferComponent2::Feed2] = "Feed2";
     146        1549 :     names [VisBufferComponent2::FeedPa2] = "FeedPa2";
     147        1549 :     names [VisBufferComponent2::FieldId] = "FieldId";
     148             :     //names [VisBufferComponent2::Flag] = "Flag";
     149        1549 :     names [VisBufferComponent2::FlagCategory] = "FlagCategory";
     150        1549 :     names [VisBufferComponent2::FlagCube] = "FlagCube";
     151        1549 :     names [VisBufferComponent2::FlagCubes] = "FlagCubes";
     152        1549 :     names [VisBufferComponent2::FlagRow] = "FlagRow";
     153        1549 :     names [VisBufferComponent2::FloatData] = "FloatData";
     154        1549 :     names [VisBufferComponent2::Frequencies] = "Frequencies";
     155        1549 :     names [VisBufferComponent2::ImagingWeight] = "ImagingWeight";
     156        1549 :     names [VisBufferComponent2::JonesC] = "JonesC";
     157        1549 :     names [VisBufferComponent2::NAntennas] = "NAntennas";
     158        1549 :     names [VisBufferComponent2::NChannels] = "NChannels";
     159        1549 :     names [VisBufferComponent2::NCorrelations] = "NCorrelations";
     160        1549 :     names [VisBufferComponent2::NRows] = "NRows";
     161        1549 :     names [VisBufferComponent2::NShapes] = "NShapes";
     162        1549 :     names [VisBufferComponent2::NRowsPerShape] = "NRowsPerShape";
     163        1549 :     names [VisBufferComponent2::NChannelsPerShape] = "NChannelsPerShape";
     164        1549 :     names [VisBufferComponent2::NCorrelationsPerShape] = "NCorrelationsPerShape";
     165        1549 :     names [VisBufferComponent2::ObservationId] = "ObservationId";
     166        1549 :     names [VisBufferComponent2::PhaseCenter] = "PhaseCenter";
     167        1549 :     names [VisBufferComponent2::PolFrame] = "PolFrame";
     168        1549 :     names [VisBufferComponent2::PolarizationId] = "PolarizationId";
     169        1549 :     names [VisBufferComponent2::ProcessorId] = "ProcessorId";
     170        1549 :     names [VisBufferComponent2::ReceptorAngles] = "ReceptorAngles";
     171        1549 :     names [VisBufferComponent2::RowIds] = "RowIds";
     172        1549 :     names [VisBufferComponent2::Scan] = "Scan";
     173        1549 :     names [VisBufferComponent2::Sigma] = "Sigma";
     174        1549 :     names [VisBufferComponent2::Sigmas] = "Sigmas";
     175        1549 :     names [VisBufferComponent2::SpectralWindows] = "SpectralWindows";
     176        1549 :     names [VisBufferComponent2::StateId] = "StateId";
     177        1549 :     names [VisBufferComponent2::Time] = "Time";
     178        1549 :     names [VisBufferComponent2::TimeCentroid] = "TimeCentroid";
     179        1549 :     names [VisBufferComponent2::TimeInterval] = "TimeInterval";
     180        1549 :     names [VisBufferComponent2::Weight] = "Weight";
     181        1549 :     names [VisBufferComponent2::Weights] = "Weights";
     182        1549 :     names [VisBufferComponent2::WeightScaled] = "WeightScaled";
     183        1549 :     names [VisBufferComponent2::WeightSpectrum] = "WeightSpectrum";
     184        1549 :     names [VisBufferComponent2::WeightSpectra] = "WeightSpectra";
     185        1549 :     names [VisBufferComponent2::SigmaSpectrum] = "SigmaSpectrum";
     186        1549 :     names [VisBufferComponent2::SigmaSpectra] = "SigmaSpectra";
     187        1549 :     names [VisBufferComponent2::WeightSpectrumScaled] = "WeightSpectrumScaled";
     188        1549 :     names [VisBufferComponent2::Uvw] = "Uvw";
     189        1549 :     names [VisBufferComponent2::VisibilityCorrected] = "VisibilityCorrected";
     190        1549 :     names [VisBufferComponent2::VisibilityModel] = "VisibilityModel";
     191        1549 :     names [VisBufferComponent2::VisibilityObserved] = "VisibilityObserved";
     192        1549 :     names [VisBufferComponent2::VisibilityCubeCorrected] = "VisibilityCubeCorrected";
     193        1549 :     names [VisBufferComponent2::VisibilityCubeModel] = "VisibilityCubeModel";
     194        1549 :     names [VisBufferComponent2::VisibilityCubeObserved] = "VisibilityCubeObserved";
     195        1549 :     names [VisBufferComponent2::VisibilityCubeFloat] = "VisibilityCubeFloat";
     196        1549 :     names [VisBufferComponent2::VisibilityCubesCorrected] = "VisibilityCubesCorrected";
     197        1549 :     names [VisBufferComponent2::VisibilityCubesModel] = "VisibilityCubesModel";
     198        1549 :     names [VisBufferComponent2::VisibilityCubesObserved] = "VisibilityCubesObserved";
     199        1549 :     names [VisBufferComponent2::VisibilityCubesFloat] = "VisibilityCubesFloat";
     200             : 
     201        1549 :     assert (names.size() == static_cast<int> (VisBufferComponent2::N_VisBufferComponents2));
     202             : 
     203        3098 :     return names [id];
     204        1549 : }
     205             : 
     206             : VisBufferComponents2
     207         123 : VisBufferComponents2::none ()
     208             : {
     209         123 :     return VisBufferComponents2 ();
     210             : }
     211             : 
     212             : VisBufferComponents2
     213           0 : VisBufferComponents2::singleton (VisBufferComponent2 component)
     214             : {
     215           0 :     VisBufferComponents2 result;
     216           0 :     result.set_p.insert (component);
     217             : 
     218           0 :     return result;
     219           0 : }
     220             : 
     221             : VisBufferComponents2
     222          83 : VisBufferComponents2::these (std::initializer_list<VisBufferComponent2> components)
     223             : {
     224          83 :    VisBufferComponents2 result;
     225             : 
     226        2075 :    for (auto component : components){
     227        1992 :        result.set_p.insert (component);
     228             :    }
     229             : 
     230          83 :    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