LCOV - code coverage report
Current view: top level - msvis/MSVis - VisBufferComponents2.cc (source / functions) Hit Total Coverage
Test: ctest_coverage.info Lines: 5 119 4.2 %
Date: 2023-11-02 14:27:30 Functions: 1 15 6.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             : }
      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           0 : VisBufferComponents2::operator+= (VisBufferComponent2 componentToAdd)
      44             : {
      45           0 :     set_p.insert (componentToAdd);
      46             : 
      47           0 :     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           0 : VisBufferComponents2::contains (VisBufferComponent2 component) const
      65             : {
      66           0 :     return utilj::containsKey (component, set_p);
      67             : }
      68             : 
      69             : Bool
      70           0 : VisBufferComponents2::empty () const
      71             : {
      72           0 :     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             : }
      92             : 
      93             : VisBufferComponents2
      94           6 : VisBufferComponents2::initializeAll ()
      95             : {
      96             : 
      97           6 :     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         408 :     for (Int i = 0; i < static_cast<int> (VisBufferComponent2::N_VisBufferComponents2); i++){
     116             : 
     117         402 :         all.set_p.insert (static_cast<VisBufferComponent2> (i));
     118             :     }
     119             : 
     120           6 :     return all;
     121             : }
     122             : 
     123             : 
     124             : String
     125           0 : 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           0 :     map<VisBufferComponent2,String> names;
     131             : 
     132           0 :     names [VisBufferComponent2::AllBeamOffsetsZero] = "AllBeamOffsetsZero";
     133           0 :     names [VisBufferComponent2::AntennaMounts] = "AntennaMounts";
     134           0 :     names [VisBufferComponent2::Antenna1] = "Antenna1";
     135           0 :     names [VisBufferComponent2::Antenna2] = "Antenna2";
     136           0 :     names [VisBufferComponent2::ArrayId] = "ArrayId";
     137           0 :     names [VisBufferComponent2::BeamOffsets] = "BeamOffsets";
     138           0 :     names [VisBufferComponent2::CorrType] = "CorrType";
     139           0 :     names [VisBufferComponent2::DataDescriptionIds] = "DataDescriptionIds";
     140           0 :     names [VisBufferComponent2::Direction1] = "Direction1";
     141           0 :     names [VisBufferComponent2::Direction2] = "Direction2";
     142           0 :     names [VisBufferComponent2::Exposure] = "Exposure";
     143           0 :     names [VisBufferComponent2::Feed1] = "Feed1";
     144           0 :     names [VisBufferComponent2::FeedPa1] = "FeedPa1";
     145           0 :     names [VisBufferComponent2::Feed2] = "Feed2";
     146           0 :     names [VisBufferComponent2::FeedPa2] = "FeedPa2";
     147           0 :     names [VisBufferComponent2::FieldId] = "FieldId";
     148             :     //names [VisBufferComponent2::Flag] = "Flag";
     149           0 :     names [VisBufferComponent2::FlagCategory] = "FlagCategory";
     150           0 :     names [VisBufferComponent2::FlagCube] = "FlagCube";
     151           0 :     names [VisBufferComponent2::FlagCubes] = "FlagCubes";
     152           0 :     names [VisBufferComponent2::FlagRow] = "FlagRow";
     153           0 :     names [VisBufferComponent2::FloatData] = "FloatData";
     154           0 :     names [VisBufferComponent2::Frequencies] = "Frequencies";
     155           0 :     names [VisBufferComponent2::ImagingWeight] = "ImagingWeight";
     156           0 :     names [VisBufferComponent2::JonesC] = "JonesC";
     157           0 :     names [VisBufferComponent2::NAntennas] = "NAntennas";
     158           0 :     names [VisBufferComponent2::NChannels] = "NChannels";
     159           0 :     names [VisBufferComponent2::NCorrelations] = "NCorrelations";
     160           0 :     names [VisBufferComponent2::NRows] = "NRows";
     161           0 :     names [VisBufferComponent2::NShapes] = "NShapes";
     162           0 :     names [VisBufferComponent2::NRowsPerShape] = "NRowsPerShape";
     163           0 :     names [VisBufferComponent2::NChannelsPerShape] = "NChannelsPerShape";
     164           0 :     names [VisBufferComponent2::NCorrelationsPerShape] = "NCorrelationsPerShape";
     165           0 :     names [VisBufferComponent2::ObservationId] = "ObservationId";
     166           0 :     names [VisBufferComponent2::PhaseCenter] = "PhaseCenter";
     167           0 :     names [VisBufferComponent2::PolFrame] = "PolFrame";
     168           0 :     names [VisBufferComponent2::PolarizationId] = "PolarizationId";
     169           0 :     names [VisBufferComponent2::ProcessorId] = "ProcessorId";
     170           0 :     names [VisBufferComponent2::ReceptorAngles] = "ReceptorAngles";
     171           0 :     names [VisBufferComponent2::RowIds] = "RowIds";
     172           0 :     names [VisBufferComponent2::Scan] = "Scan";
     173           0 :     names [VisBufferComponent2::Sigma] = "Sigma";
     174           0 :     names [VisBufferComponent2::Sigmas] = "Sigmas";
     175           0 :     names [VisBufferComponent2::SpectralWindows] = "SpectralWindows";
     176           0 :     names [VisBufferComponent2::StateId] = "StateId";
     177           0 :     names [VisBufferComponent2::Time] = "Time";
     178           0 :     names [VisBufferComponent2::TimeCentroid] = "TimeCentroid";
     179           0 :     names [VisBufferComponent2::TimeInterval] = "TimeInterval";
     180           0 :     names [VisBufferComponent2::Weight] = "Weight";
     181           0 :     names [VisBufferComponent2::Weights] = "Weights";
     182           0 :     names [VisBufferComponent2::WeightScaled] = "WeightScaled";
     183           0 :     names [VisBufferComponent2::WeightSpectrum] = "WeightSpectrum";
     184           0 :     names [VisBufferComponent2::WeightSpectra] = "WeightSpectra";
     185           0 :     names [VisBufferComponent2::SigmaSpectrum] = "SigmaSpectrum";
     186           0 :     names [VisBufferComponent2::SigmaSpectra] = "SigmaSpectra";
     187           0 :     names [VisBufferComponent2::WeightSpectrumScaled] = "WeightSpectrumScaled";
     188           0 :     names [VisBufferComponent2::Uvw] = "Uvw";
     189           0 :     names [VisBufferComponent2::VisibilityCorrected] = "VisibilityCorrected";
     190           0 :     names [VisBufferComponent2::VisibilityModel] = "VisibilityModel";
     191           0 :     names [VisBufferComponent2::VisibilityObserved] = "VisibilityObserved";
     192           0 :     names [VisBufferComponent2::VisibilityCubeCorrected] = "VisibilityCubeCorrected";
     193           0 :     names [VisBufferComponent2::VisibilityCubeModel] = "VisibilityCubeModel";
     194           0 :     names [VisBufferComponent2::VisibilityCubeObserved] = "VisibilityCubeObserved";
     195           0 :     names [VisBufferComponent2::VisibilityCubeFloat] = "VisibilityCubeFloat";
     196           0 :     names [VisBufferComponent2::VisibilityCubesCorrected] = "VisibilityCubesCorrected";
     197           0 :     names [VisBufferComponent2::VisibilityCubesModel] = "VisibilityCubesModel";
     198           0 :     names [VisBufferComponent2::VisibilityCubesObserved] = "VisibilityCubesObserved";
     199           0 :     names [VisBufferComponent2::VisibilityCubesFloat] = "VisibilityCubesFloat";
     200             : 
     201           0 :     assert (names.size() == static_cast<int> (VisBufferComponent2::N_VisBufferComponents2));
     202             : 
     203           0 :     return names [id];
     204             : }
     205             : 
     206             : VisBufferComponents2
     207           0 : VisBufferComponents2::none ()
     208             : {
     209           0 :     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             : }
     220             : 
     221             : VisBufferComponents2
     222           0 : VisBufferComponents2::these (std::initializer_list<VisBufferComponent2> components)
     223             : {
     224           0 :    VisBufferComponents2 result;
     225             : 
     226           0 :    for (auto component : components){
     227           0 :        result.set_p.insert (component);
     228             :    }
     229             : 
     230           0 :    return result;
     231             : }
     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             : }
     247             : 
     248             : 
     249             : } // end namespace vi
     250             : 
     251             : using namespace casacore;
     252             : } // end namespace casa

Generated by: LCOV version 1.16