MaskedLatticeStatsDataProvider.h

Go to the documentation of this file.
00001 //# Copyright (C) 2000,2001
00002 //# Associated Universities, Inc. Washington DC, USA.
00003 //#
00004 //# This library is free software; you can redistribute it and/or modify it
00005 //# under the terms of the GNU Library General Public License as published by
00006 //# the Free Software Foundation; either version 2 of the License, or (at your
00007 //# option) any later version.
00008 //#
00009 //# This library is distributed in the hope that it will be useful, but WITHOUT
00010 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00011 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00012 //# License for more details.
00013 //#
00014 //# You should have received a copy of the GNU Library General Public License
00015 //# along with this library; if not, write to the Free Software Foundation,
00016 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00017 //#
00018 //# Correspondence concerning AIPS++ should be addressed as follows:
00019 //#        Internet email: aips2-request@nrao.edu.
00020 //#        Postal address: AIPS++ Project Office
00021 //#                        National Radio Astronomy Observatory
00022 //#                        520 Edgemont Road
00023 //#                        Charlottesville, VA 22903-2475 USA
00024 //#
00025 //# $Id: Array.h 21545 2015-01-22 19:36:35Z gervandiepen $
00026 
00027 #ifndef LATTICES_MASKEDLATTICESTATSDATAPROVIDER_H
00028 #define LATTICES_MASKEDLATTICESTATSDATAPROVIDER_H
00029 
00030 #include <casacore/lattices/LatticeMath/LatticeStatsDataProviderBase.h>
00031 
00032 #include <casacore/lattices/Lattices/MaskedLattice.h>
00033 #include <casacore/lattices/Lattices/MaskedLatticeIterator.h>
00034 
00035 #include <casacore/casa/aips.h>
00036 
00037 namespace casacore {
00038 
00039 // Data provider which allows stats framework to iterate through a masked lattice.
00040 
00041 template <class T> class MaskedLatticeStatsDataProvider
00042         : public LatticeStatsDataProviderBase<T> {
00043 public:
00044 
00045         // default constructor. Must set lattice after construction but before
00046         // using the object
00047 
00048         MaskedLatticeStatsDataProvider();
00049 
00050         // <src>iteratorLimitBytes</src> is related to the size of the lattice.
00051         // If the lattice is greater than this size, then a lattice iterator will
00052         // be used to step through the lattice. If less, then all the data in the
00053         // values in the lattice are retrieved in a single chunk. The advantage of
00054         // the iterator is that less memory is used. The disadvantage is there is
00055         // a significant performace cost, so if the lattice is small, it is better to
00056         // get all its values in a single chunk and forgo the iterator. This is particularly
00057         // true when looping for a large number of iterations and creating a
00058         // MaskedLatticeStatsDataProvider each loop (in that case, you probably will want
00059         // to create a single object before the loop and use setLattice() to update
00060         // its lattice).
00061         MaskedLatticeStatsDataProvider(
00062                 MaskedLattice<T>& lattice, uInt iteratorLimitBytes=4096*4096
00063         );
00064 
00065         ~MaskedLatticeStatsDataProvider();
00066 
00067         void operator++();
00068 
00069         uInt estimatedSteps() const;
00070 
00071         // Are there any data sets left to provide?
00072         Bool atEnd() const;
00073 
00074         // Take any actions necessary to finalize the provider. This will be called when
00075         // atEnd() returns True.
00076         void finalize();
00077 
00078         // get the count of elements in the current data set. When implementing this method, be
00079         // certain to take stride into account; ie for a data set with nominally 100 elements that
00080         // is to have a stride of two, this method should return 50.
00081         uInt64 getCount();
00082 
00083         // get the current data set
00084         const T* getData();
00085 
00086         // Get the associated mask of the current dataset. Only called if hasMask() returns True;
00087         const Bool* getMask();
00088 
00089         // Does the current data set have an associated mask?
00090         Bool hasMask() const;
00091 
00092         // reset the provider to point to the first data set it manages.
00093         void reset();
00094 
00095         // set the lattice. Automatically resets the lattice iterator.
00096         // <src>iteratorLimitBytes</src> is related to the size of the lattice.
00097         // If the lattice is greater than this size, then a lattice iterator will
00098         // be used to step through the lattice. If less, then all the data in the
00099         // values in the lattice are retrieved in a single chunk. The advantage of
00100         // the iterator is that less memory is used. The disadvantage is there is
00101         // a significant performace cost, so if the lattice is small, it is better to
00102         // get all its values in a single chunk and forgo the iterator. This is particularly
00103         // true when looping for a large number of iterations and creating a
00104         // MaskedLatticeStatsDataProvider each loop (in that case, you probably will want
00105         // to create a single object before the loop and use setLattice() to update
00106         // its lattice).
00107         void setLattice(const MaskedLattice<T>& lattice, uInt iteratorLimitBytes=4096*4096);
00108 
00109         // <group>
00110         // see base class documentation.
00111         void updateMaxPos(const std::pair<Int64, Int64>& maxpos);
00112 
00113         void updateMinPos(const std::pair<Int64, Int64>& minpos);
00114         // </group>
00115 
00116 private:
00117 
00118         CountedPtr<RO_MaskedLatticeIterator<T> > _iter;
00119         Array<T> _currentSlice;
00120         Array<Bool> _currentMaskSlice;
00121         const T* _currentPtr;
00122         const Bool* _currentMaskPtr;
00123         Bool _delData, _delMask, _atEnd;
00124 
00125         void _freeStorage();
00126 
00127 };
00128 
00129 }
00130 
00131 #ifndef CASACORE_NO_AUTO_TEMPLATES
00132 #include <casacore/lattices/LatticeMath/MaskedLatticeStatsDataProvider.tcc>
00133 #endif //# CASACORE_NO_AUTO_TEMPLATES
00134 
00135 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1