LatticeStatsDataProvider.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_LATTICESTATSDATAPROVIDER_H
00028 #define LATTICES_LATTICESTATSDATAPROVIDER_H
00029 
00030 #include <casacore/lattices/Lattices/LatticeIterator.h>
00031 #include <casacore/lattices/LatticeMath/LatticeStatsDataProviderBase.h>
00032 
00033 #include <casacore/casa/aips.h>
00034 
00035 namespace casacore {
00036 
00037 // Data provider which allows stats framework to iterate through an unmasked lattice.
00038 
00039 template <class T> class LatticeStatsDataProvider
00040         : public  LatticeStatsDataProviderBase<T> {
00041 
00042 public:
00043 
00044         // default constructor, must set lattice after construction but before
00045         // using the object
00046         LatticeStatsDataProvider();
00047 
00048         // <src>iteratorLimitBytes</src> is related to the size of the lattice.
00049         // If the lattice is greater than this size, then a lattice iterator will
00050         // be used to step through the lattice. If less, then all the data in the
00051         // values in the lattice are retrieved in a single chunk. The advantage of
00052         // the iterator is that less memory is used. The disadvantage is there is
00053         // a significant performace cost, so if the lattice is small, it is better to
00054         // get all its values in a single chunk and forgo the iterator. This is particularly
00055         // true when looping for a large number of iterations and creating a
00056         // LatticeStatsDataProvider each loop (in that case, you probably will want
00057         // to create a single object before the loop and use setLattice() to update
00058         // its lattice).
00059         LatticeStatsDataProvider(
00060                 const Lattice<T>& lattice, uInt iteratorLimitBytes=4096*4096
00061         );
00062 
00063         ~LatticeStatsDataProvider();
00064 
00065         void operator++();
00066 
00067         // estimated number of steps to iterate through the the lattice
00068         uInt estimatedSteps() const;
00069 
00070         // Are there any data sets left to provide?
00071         Bool atEnd() const;
00072 
00073         // Take any actions necessary to finalize the provider. This will be called when
00074         // atEnd() returns True.
00075         void finalize();
00076 
00077         // get the count of elements in the current data set. When implementing this method, be
00078         // certain to take stride into account; ie for a data set with nominally 100 elements that
00079         // is to have a stride of two, this method should return 50.
00080         uInt64 getCount();
00081 
00082         // get the current data set
00083         const T* getData();
00084 
00085         // Get the associated mask of the current dataset. Only called if hasMask() returns True;
00086         const Bool* getMask();
00087 
00088         // Does the current data set have an associated mask?
00089         Bool hasMask() const;
00090 
00091         // reset the provider to point to the first data set it manages.
00092         void reset();
00093 
00094         // set the lattice. Automatically resets the lattice iterator
00095         // <src>iteratorLimitBytes</src> is related to the size of the lattice.
00096         // If the lattice is greater than this size, then a lattice iterator will
00097         // be used to step through the lattice. If less, then all the data in the
00098         // values in the lattice are retrieved in a single chunk. The advantage of
00099         // the iterator is that less memory is used. The disadvantage is there is
00100         // a significant performace cost, so if the lattice is small, it is better to
00101         // get all its values in a single chunk and forgo the iterator. This is particularly
00102         // true when looping for a large number of iterations and creating a
00103         // LatticeStatsDataProvider each loop (in that case, you probably will want
00104         // to create a single object before the loop and use setLattice() to update
00105         // its lattice).
00106         void setLattice(
00107                 const Lattice<T>& lattice, uInt iteratorLimitBytes=4096*4096
00108         );
00109 
00110         // <group>
00111         // see base class documentation.
00112         void updateMaxPos(const std::pair<Int64, Int64>& maxpos);
00113 
00114         void updateMinPos(const std::pair<Int64, Int64>& minpos);
00115         // </group>
00116 
00117 private:
00118         CountedPtr<RO_LatticeIterator<T> > _iter;
00119         Array<T> _currentSlice;
00120         const T* _currentPtr;
00121         Bool _delData, _atEnd;
00122 
00123         void _freeStorage();
00124 
00125 };
00126 
00127 }
00128 
00129 #ifndef CASACORE_NO_AUTO_TEMPLATES
00130 #include <casacore/lattices/LatticeMath/LatticeStatsDataProvider.tcc>
00131 #endif //# CASACORE_NO_AUTO_TEMPLATES
00132 
00133 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1