LCOV - code coverage report
Current view: top level - synthesis/ImagerObjects - MultiParamFieldIterator.h (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 0 30 0.0 %
Date: 2024-10-29 13:38:20 Functions: 0 8 0.0 %

          Line data    Source code
       1             : /* -*- mode: c++ -*- */
       2             : //# MultiParamFielditerator.h: Multiple parameter iterator over Records
       3             : //# Copyright (C) 1997,1998,1999,2000,2001,2002,2003
       4             : //# Associated Universities, Inc. Washington DC, USA.
       5             : //#
       6             : //# This library is free software; you can redistribute it and/or modify it
       7             : //# under the terms of the GNU Library General Public License as published by
       8             : //# the Free Software Foundation; either version 2 of the License, or (at your
       9             : //# option) any later version.
      10             : //#
      11             : //# This library is distributed in the hope that it will be useful, but WITHOUT
      12             : //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
      13             : //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
      14             : //# License for more details.
      15             : //#
      16             : //# You should have received a copy of the GNU Library General Public License
      17             : //# along with this library; if not, write to the Free Software Foundation,
      18             : //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
      19             : //#
      20             : //# Correspondence concerning AIPS++ should be addressed as follows:
      21             : //#        Internet email: casa-feedback@nrao.edu.
      22             : //#        Postal address: AIPS++ Project Office
      23             : //#                        National Radio Astronomy Observatory
      24             : //#                        520 Edgemont Road
      25             : //#                        Charlottesville, VA 22903-2475 USA
      26             : //#
      27             : #ifndef MULTI_PARAM_FIELD_ITERATOR_H_
      28             : #define MULTI_PARAM_FIELD_ITERATOR_H_
      29             : 
      30             : #include <synthesis/ImagerObjects/ParamFieldIterator.h>
      31             : #include <casacore/casa/Containers/Record.h>
      32             : #include <iterator>
      33             : #include <array>
      34             : 
      35             : namespace casa {
      36             : 
      37             : template<size_t N>
      38             : class MultiParamFieldIterator
      39             :         : public std::iterator<std::forward_iterator_tag, std::array<casacore::Record *,N>,
      40             :                                int> {
      41             :         std::array<casacore::Record *,N> records;
      42             :         casacore::String prefix;
      43             :         casacore::uInt field_index;
      44             : 
      45             : public:
      46             :         MultiParamFieldIterator()
      47             :                 : records(std::array<casacore::Record *,N> {})
      48             :                 , prefix(casacore::String(""))
      49             :                 , field_index(0) {};
      50             : 
      51           0 :         MultiParamFieldIterator(
      52             :                 std::array<casacore::Record *,N> &recs, const string prefix = "")
      53           0 :                 : records(recs)
      54           0 :                 , prefix(casacore::String(prefix))
      55           0 :                 , field_index(0) {};
      56             : 
      57           0 :         MultiParamFieldIterator(const MultiParamFieldIterator &fit)
      58           0 :                 : records(fit.records)
      59           0 :                 , prefix(fit.prefix)
      60           0 :                 , field_index(fit.field_index) {};
      61             : 
      62           0 :         MultiParamFieldIterator operator++() {
      63           0 :                 ++field_index;
      64           0 :                 return *this;
      65             :         };
      66             : 
      67             :         MultiParamFieldIterator operator++(int) {
      68             :                 MultiParamFieldIterator tmp(*this);
      69             :                 operator++();
      70             :                 return tmp;
      71             :         };
      72             : 
      73           0 :         bool operator==(const MultiParamFieldIterator &rhs) {
      74           0 :                 return records == rhs.records
      75           0 :                         && field_index == rhs.field_index
      76           0 :                         && prefix == rhs.prefix;
      77             :         };
      78             : 
      79           0 :         bool operator!=(const MultiParamFieldIterator &rhs) {
      80           0 :                 return !operator==(rhs);
      81             :         };
      82             : 
      83           0 :         std::array<casacore::Record *,N> operator*() {
      84             :                 std::array<casacore::Record *,N> result;
      85           0 :                 casacore::String field_name = prefix + casacore::String::toString(field_index);
      86           0 :                 for (size_t i = 0; i < N; ++i)
      87           0 :                         result[i] = &records[i]->rwSubRecord(field_name);
      88           0 :                 return result;
      89           0 :         };
      90             : 
      91           0 :         static MultiParamFieldIterator<N> begin(std::array<casacore::Record *,N> &recs,
      92             :                                                 const string &prefix = "") {
      93           0 :                 return MultiParamFieldIterator(recs, prefix);
      94             :         };
      95             : 
      96           0 :         static MultiParamFieldIterator<N> end(std::array<casacore::Record *,N> &recs,
      97             :                                               const string &prefix = "") {
      98           0 :                 MultiParamFieldIterator result(recs, prefix);
      99           0 :                 result.field_index = recs[0]->nfields();
     100           0 :                 return result;
     101           0 :         };
     102             : };
     103             : 
     104             : } // namespace casa
     105             : 
     106             : #endif // MULTI_PARAM_FIELD_ITERATOR_H_

Generated by: LCOV version 1.16