casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Vi2StatsDataIterator.h
Go to the documentation of this file.
1 // -*- mode: c++ -*-
2 //# Copyright (C) 1996,1997,1998,1999,2000,2002,2003,2015
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This library is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU Library General Public License as published by
7 //# the Free Software Foundation; either version 2 of the License, or (at your
8 //# option) any later version.
9 //#
10 //# This library is distributed in the hope that it will be useful, but WITHOUT
11 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 //# License for more details.
14 //#
15 //# You should have received a copy of the GNU Library General Public License
16 //# along with this library; if not, write to the Free Software Foundation,
17 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 //#
19 //# Correspondence concerning AIPS++ should be addressed as follows:
20 //# Internet email: aips2-request@nrao.edu.
21 //# Postal address: AIPS++ Project Office
22 //# National Radio Astronomy Observatory
23 //# 520 Edgemont Road
24 //# Charlottesville, VA 22903-2475 USA
25 //#
26 //
27 // Data iterators for Vi2ChunkDataProvider
28 //
29 #ifndef MSVIS_STATISTICS_VI2_STATS_DATA_ITERATOR_H_
30 #define MSVIS_STATISTICS_VI2_STATS_DATA_ITERATOR_H_
31 
32 #include <casacore/casa/aips.h>
34 #include <iterator>
35 
36 
37 namespace casa {
38 
39 //
40 // Vi2StatsDataIterator is designed to support an on-the-fly application of a
41 // transformation between the values in the source array and the values provided
42 // by the iterator. This feature allows a Vi2ChunkDataProvider to provide, for
43 // example, visibility amplitudes during iteration over visibilities.
44 //
45 template<class Transformed, class Data>
47  : public std::iterator<std::input_iterator_tag,Transformed> {
48 
49 public:
50  typedef Transformed AccumType;
51  typedef Data DataType;
52 
54  : array(&a)
55  , array_iter(array->begin())
56  , end_iter(array->end()) {}
57 
60 
62  ++array_iter;
63  return *this;
64  }
65 
67  Vi2StatsDataIterator tmp(*this);
68  operator++();
69  return tmp;
70  }
71 
72  bool operator==(const Vi2StatsDataIterator& rhs) {
73  return array_iter == rhs.array_iter;
74  }
75 
76  bool operator!=(const Vi2StatsDataIterator& rhs) {
77  return array_iter != rhs.array_iter;
78  }
79 
80  Transformed operator*();
81 
82  bool atEnd() {
83  return array_iter == end_iter;
84  }
85 
87  return array->size();
88  }
89 
90 protected:
91 
93 
95 
97 
99 
100 };
101 
102 
103 template<class Transformed, class Data>
105 
106 // Simple non-transforming (widening excepted) data iterator types.
107 //
108 template <class T>
109 class DataIteratorMixin : public T {
110 
111 public:
112  using T::T;
113 
114  typename T::AccumType operator*() {
115  return *T::array_iter;
116  }
117 };
118 
119 typedef DataIteratorMixin< Vi2StatsDataIterator<casacore::Double,casacore::Float> >
121 
124 
127 
128 }
129 
130 
131 #endif // MSVIS_STATISTICS_VI2_STATS_DATA_ITERATOR_H_
unsigned long long uInt64
Definition: aipsxtype.h:39
Vi2StatsDataIterator(const casacore::Array< Data > &a)
casacore::Array< Data >::const_iterator array_iter
const casacore::Array< Data > * array
const_iterator end() const
DataIteratorMixin< Vi2StatsDataIterator< casacore::Double, casacore::Double > > Vi2StatsDoubleIterator
static const casacore::Array< Data > empty_array
bool operator==(const Vi2StatsDataIterator &rhs)
const_iterator begin() const
DataIteratorMixin< Vi2StatsDataIterator< casacore::Double, casacore::Int > > Vi2StatsIntIterator
casacore::Array< Data >::const_iterator end_iter
bool operator!=(const Vi2StatsDataIterator &rhs)
Vi2StatsDataIterator & operator++()
Vi2StatsDataIterator operator++(int)
Simple non-transforming (widening excepted) data iterator types.
size_t size() const
Definition: ArrayBase.h:101
Vi2StatsDataIterator is designed to support an on-the-fly application of a transformation between the...
DataIteratorMixin< Vi2StatsDataIterator< casacore::Double, casacore::Float > > Vi2StatsFloatIterator