LCOV - code coverage report
Current view: top level - synthesis/ImagerObjects - ParamFieldIterator.h (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 0 22 0.0 %
Date: 2024-10-10 15:00:01 Functions: 0 7 0.0 %

          Line data    Source code
       1             : /* -*- mode: c++ -*- */
       2             : //# ParamFieldIterator.h: Single field 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 PARAM_FIELD_ITERATOR_H_
      28             : #define PARAM_FIELD_ITERATOR_H_
      29             : 
      30             : #include <casacore/casa/Containers/Record.h>
      31             : #include <iterator>
      32             : 
      33             : namespace casa {
      34             : 
      35             : class ParamFieldIterator
      36             :         : public std::iterator<std::forward_iterator_tag, casacore::Record *, int> {
      37             :         casacore::Record *record;
      38             :         casacore::String prefix;
      39             :         casacore::uInt field_index;
      40             : 
      41             : public:
      42             :         ParamFieldIterator()
      43             :                 : record(nullptr)
      44             :                 , prefix("")
      45             :                 , field_index(0) {};
      46             : 
      47           0 :         ParamFieldIterator(casacore::Record *rec, const string &prefix = "")
      48           0 :                 : record(rec)
      49           0 :                 , prefix(casacore::String(prefix))
      50           0 :                 , field_index(0) {};
      51             : 
      52             :         ParamFieldIterator(const ParamFieldIterator &fit)
      53             :                 : record(fit.record)
      54             :                 , prefix(fit.prefix)
      55             :                 , field_index(fit.field_index) {};
      56             : 
      57           0 :         ParamFieldIterator & operator++() {
      58           0 :                 ++field_index;
      59           0 :                 return *this;
      60             :         };
      61             : 
      62             :         ParamFieldIterator operator++(int) {
      63             :                 ParamFieldIterator tmp(*this);
      64             :                 operator++();
      65             :                 return tmp;
      66             :         };
      67             : 
      68           0 :         bool operator==(const ParamFieldIterator &rhs) {
      69           0 :                 return record == rhs.record
      70           0 :                         && field_index == rhs.field_index
      71           0 :                         && prefix == rhs.prefix;
      72             :         };
      73             : 
      74           0 :         bool operator!=(const ParamFieldIterator &rhs) {
      75           0 :                 return !operator==(rhs);
      76             :         };
      77             : 
      78           0 :         casacore::Record & operator*() {
      79           0 :                 return record->rwSubRecord(prefix + casacore::String::toString(field_index));
      80             :         };
      81             : 
      82           0 :         static ParamFieldIterator begin(casacore::Record *rec, const string &prefix = "") {
      83           0 :                 return ParamFieldIterator(rec, prefix);
      84             :         };
      85             : 
      86           0 :         static ParamFieldIterator end(casacore::Record *rec, const string &prefix = "") {
      87           0 :                 ParamFieldIterator result(rec, prefix);
      88           0 :                 result.field_index = rec->nfields();
      89           0 :                 return result;
      90           0 :         };
      91             : };
      92             : 
      93             : }
      94             : 
      95             : #endif // FIELD_ITERATOR_H_

Generated by: LCOV version 1.16