casacore
MaskedLatticeStatsDataProvider.h
Go to the documentation of this file.
1 //# Copyright (C) 2000,2001
2 //# Associated Universities, Inc. Washington DC, USA.
3 //#
4 //# This library is free software; you can redistribute it and/or modify it
5 //# under the terms of the GNU Library General Public License as published by
6 //# the Free Software Foundation; either version 2 of the License, or (at your
7 //# option) any later version.
8 //#
9 //# This library is distributed in the hope that it will be useful, but WITHOUT
10 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12 //# License for more details.
13 //#
14 //# You should have received a copy of the GNU Library General Public License
15 //# along with this library; if not, write to the Free Software Foundation,
16 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
17 //#
18 //# Correspondence concerning AIPS++ should be addressed as follows:
19 //# Internet email: aips2-request@nrao.edu.
20 //# Postal address: AIPS++ Project Office
21 //# National Radio Astronomy Observatory
22 //# 520 Edgemont Road
23 //# Charlottesville, VA 22903-2475 USA
24 //#
25 //# $Id: Array.h 21545 2015-01-22 19:36:35Z gervandiepen $
26 
27 #ifndef LATTICES_MASKEDLATTICESTATSDATAPROVIDER_H
28 #define LATTICES_MASKEDLATTICESTATSDATAPROVIDER_H
29 
30 #include <casacore/lattices/LatticeMath/LatticeStatsDataProviderBase.h>
31 
32 #include <casacore/lattices/Lattices/MaskedLattice.h>
33 #include <casacore/lattices/Lattices/MaskedLatticeIterator.h>
34 
35 #include <casacore/casa/aips.h>
36 
37 namespace casacore {
38 
39 // Data provider which allows stats framework to iterate through a masked lattice.
40 
41 template <class T> class MaskedLatticeStatsDataProvider
42  : public LatticeStatsDataProviderBase<T> {
43 public:
44 
45  // default constructor. Must set lattice after construction but before
46  // using the object
47 
49 
50  // <src>iteratorLimitBytes</src> is related to the size of the lattice.
51  // If the lattice is greater than this size, then a lattice iterator will
52  // be used to step through the lattice. If less, then all the data in the
53  // values in the lattice are retrieved in a single chunk. The advantage of
54  // the iterator is that less memory is used. The disadvantage is there is
55  // a significant performace cost, so if the lattice is small, it is better to
56  // get all its values in a single chunk and forgo the iterator. This is particularly
57  // true when looping for a large number of iterations and creating a
58  // MaskedLatticeStatsDataProvider each loop (in that case, you probably will want
59  // to create a single object before the loop and use setLattice() to update
60  // its lattice).
62  MaskedLattice<T>& lattice, uInt iteratorLimitBytes=4096*4096
63  );
64 
66 
67  void operator++();
68 
69  uInt estimatedSteps() const;
70 
71  // Are there any data sets left to provide?
72  Bool atEnd() const;
73 
74  // Take any actions necessary to finalize the provider. This will be called when
75  // atEnd() returns True.
76  void finalize();
77 
78  // get the count of elements in the current data set. When implementing this method, be
79  // certain to take stride into account; ie for a data set with nominally 100 elements that
80  // is to have a stride of two, this method should return 50.
81  uInt64 getCount();
82 
83  // get the current data set
84  const T* getData();
85 
86  // Get the associated mask of the current dataset. Only called if hasMask() returns True;
87  const Bool* getMask();
88 
89  // Does the current data set have an associated mask?
90  Bool hasMask() const;
91 
92  // reset the provider to point to the first data set it manages.
93  void reset();
94 
95  // set the lattice. Automatically resets the lattice iterator.
96  // <src>iteratorLimitBytes</src> is related to the size of the lattice.
97  // If the lattice is greater than this size, then a lattice iterator will
98  // be used to step through the lattice. If less, then all the data in the
99  // values in the lattice are retrieved in a single chunk. The advantage of
100  // the iterator is that less memory is used. The disadvantage is there is
101  // a significant performace cost, so if the lattice is small, it is better to
102  // get all its values in a single chunk and forgo the iterator. This is particularly
103  // true when looping for a large number of iterations and creating a
104  // MaskedLatticeStatsDataProvider each loop (in that case, you probably will want
105  // to create a single object before the loop and use setLattice() to update
106  // its lattice).
107  void setLattice(const MaskedLattice<T>& lattice, uInt iteratorLimitBytes=4096*4096);
108 
109  // <group>
110  // see base class documentation.
111  void updateMaxPos(const std::pair<Int64, Int64>& maxpos);
112 
113  void updateMinPos(const std::pair<Int64, Int64>& minpos);
114  // </group>
115 
116 private:
117 
121  const T* _currentPtr;
124 
125  void _freeStorage();
126 
127 };
128 
129 }
130 
131 #ifndef CASACORE_NO_AUTO_TEMPLATES
132 #include <casacore/lattices/LatticeMath/MaskedLatticeStatsDataProvider.tcc>
133 #endif //# CASACORE_NO_AUTO_TEMPLATES
134 
135 #endif
uInt64 getCount()
get the count of elements in the current data set.
void operator++()
increment the data provider to the next dataset, mask, range set, and weights.
Bool atEnd() const
Are there any data sets left to provide?
unsigned long long uInt64
Definition: aipsxtype.h:39
MaskedLatticeStatsDataProvider()
default constructor.
void setLattice(const MaskedLattice< T > &lattice, uInt iteratorLimitBytes=4096 *4096)
set the lattice.
A templated, abstract base class for array-like objects with masks.
Definition: ImageConcat.h:45
uInt estimatedSteps() const
estimated number of steps to iterate through the the lattice
Bool hasMask() const
Does the current data set have an associated mask?
Data provider which allows stats framework to iterate through a masked lattice.
Referenced counted pointer for constant data.
Definition: CountedPtr.h:86
Abstract base class of data providers which allows stats framework to iterate through a lattice...
void finalize()
Take any actions necessary to finalize the provider.
CountedPtr< RO_MaskedLatticeIterator< T > > _iter
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:39
const Bool * getMask()
Get the associated mask of the current dataset.
const T * getData()
get the current data set
template <class T, class U> class vector;
Definition: Array.h:169
void updateMinPos(const std::pair< Int64, Int64 > &minpos)
void updateMaxPos(const std::pair< Int64, Int64 > &maxpos)
see base class documentation.
void reset()
reset the provider to point to the first data set it manages.
this file contains all the compiler specific defines
Definition: mainpage.dox:28
unsigned int uInt
Definition: aipstype.h:48