casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
LatticeStatsDataProvider.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_LATTICESTATSDATAPROVIDER_H
28 #define LATTICES_LATTICESTATSDATAPROVIDER_H
29 
32 
33 #include <casacore/casa/aips.h>
34 
35 namespace casacore {
36 
37 // Data provider which allows stats framework to iterate through an unmasked lattice.
38 
39 template <class T> class LatticeStatsDataProvider
40  : public LatticeStatsDataProviderBase<T> {
41 
42 public:
43 
44  // default constructor, must set lattice after construction but before
45  // using the object
47 
48  // <src>iteratorLimitBytes</src> is related to the size of the lattice.
49  // If the lattice is greater than this size, then a lattice iterator will
50  // be used to step through the lattice. If less, then all the data in the
51  // values in the lattice are retrieved in a single chunk. The advantage of
52  // the iterator is that less memory is used. The disadvantage is there is
53  // a significant performace cost, so if the lattice is small, it is better to
54  // get all its values in a single chunk and forgo the iterator. This is particularly
55  // true when looping for a large number of iterations and creating a
56  // LatticeStatsDataProvider each loop (in that case, you probably will want
57  // to create a single object before the loop and use setLattice() to update
58  // its lattice).
60  const Lattice<T>& lattice, uInt iteratorLimitBytes=4096*4096
61  );
62 
64 
65  void operator++();
66 
67  // estimated number of steps to iterate through the the lattice
68  uInt estimatedSteps() const;
69 
70  // Are there any data sets left to provide?
71  Bool atEnd() const;
72 
73  // Take any actions necessary to finalize the provider. This will be called when
74  // atEnd() returns True.
75  void finalize();
76 
77  // get the count of elements in the current data set. When implementing this method, be
78  // certain to take stride into account; ie for a data set with nominally 100 elements that
79  // is to have a stride of two, this method should return 50.
80  uInt64 getCount();
81 
82  // get the current data set
83  const T* getData();
84 
85  // Get the associated mask of the current dataset. Only called if hasMask() returns True;
86  const Bool* getMask();
87 
88  // returns something reasonable based on the lattice size.
89  uInt getNMaxThreads() const;
90 
91  // Does the current data set have an associated mask?
92  Bool hasMask() const;
93 
94  // reset the provider to point to the first data set it manages.
95  void reset();
96 
97  // set the lattice. Automatically resets the lattice iterator
98  // <src>iteratorLimitBytes</src> is related to the size of the lattice.
99  // If the lattice is greater than this size, then a lattice iterator will
100  // be used to step through the lattice. If less, then all the data in the
101  // values in the lattice are retrieved in a single chunk. The advantage of
102  // the iterator is that less memory is used. The disadvantage is there is
103  // a significant performace cost, so if the lattice is small, it is better to
104  // get all its values in a single chunk and forgo the iterator. This is particularly
105  // true when looping for a large number of iterations and creating a
106  // LatticeStatsDataProvider each loop (in that case, you probably will want
107  // to create a single object before the loop and use setLattice() to update
108  // its lattice).
109  void setLattice(
110  const Lattice<T>& lattice, uInt iteratorLimitBytes=4096*4096
111  );
112 
113  // <group>
114  // see base class documentation.
115  void updateMaxPos(const std::pair<Int64, Int64>& maxpos);
116 
117  void updateMinPos(const std::pair<Int64, Int64>& minpos);
118  // </group>
119 
120 private:
123  const T* _currentPtr;
126 
127  void _freeStorage();
128 
129 };
130 
131 }
132 
133 #ifndef CASACORE_NO_AUTO_TEMPLATES
134 #include <casacore/lattices/LatticeMath/LatticeStatsDataProvider.tcc>
135 #endif //# CASACORE_NO_AUTO_TEMPLATES
136 
137 #endif
uInt estimatedSteps() const
estimated number of steps to iterate through the the lattice
void reset()
reset the provider to point to the first data set it manages.
unsigned long long uInt64
Definition: aipsxtype.h:39
void operator++()
increment the data provider to the next dataset, mask, range set, and weights.
void setLattice(const Lattice< T > &lattice, uInt iteratorLimitBytes=4096 *4096)
set the lattice.
Data provider which allows stats framework to iterate through an unmasked lattice.
uInt64 getCount()
get the count of elements in the current data set.
Bool atEnd() const
Are there any data sets left to provide?
CountedPtr< RO_LatticeIterator< T > > _iter
A templated, abstract base class for array-like objects.
Referenced counted pointer for constant data.
Definition: VisModelData.h:42
Abstract base class of data providers which allows stats framework to iterate through a lattice...
Bool hasMask() const
Does the current data set have an associated mask?
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
void updateMaxPos(const std::pair< Int64, Int64 > &maxpos)
see base class documentation.
const T * getData()
get the current data set
template &lt;class T, class U&gt; class vector;
Definition: MSFlagger.h:37
void updateMinPos(const std::pair< Int64, Int64 > &minpos)
void finalize()
Take any actions necessary to finalize the provider.
uInt getNMaxThreads() const
returns something reasonable based on the lattice size.
const Bool * getMask()
Get the associated mask of the current dataset.
unsigned int uInt
Definition: aipstype.h:51
LatticeStatsDataProvider()
default constructor, must set lattice after construction but before using the object ...
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42