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 SCIMATH_STATSDATAPROVIDER_H 00028 #define SCIMATH_STATSDATAPROVIDER_H 00029 00030 #include <casacore/scimath/Mathematics/StatisticsTypes.h> 00031 00032 #include <casacore/casa/aips.h> 00033 00034 namespace casacore { 00035 00036 // Abstract base class which defines interface for providing "datasets" to the statistics framework 00037 // when nontrivial means of doing so are not sufficient. 00038 00039 template <class AccumType, class DataIterator, class MaskIterator=const Bool *, class WeightsIterator=DataIterator> 00040 class StatsDataProvider { 00041 public: 00042 00043 virtual ~StatsDataProvider(); 00044 00045 // increment the data provider to the next dataset, mask, range set, and weights. 00046 virtual void operator++() = 0; 00047 00048 // Are there any data sets left to provide? 00049 virtual Bool atEnd() const = 0; 00050 00051 // Take any actions necessary to finalize the provider. This will be called when 00052 // atEnd() returns True. 00053 virtual void finalize() = 0; 00054 00055 // get the count of elements in the current data set. When implementing this method, be 00056 // certain to take stride into account; ie for a data set with nominally 100 elements that 00057 // is to have a stride of two, this method should return 50. 00058 virtual uInt64 getCount() = 0; 00059 00060 // get the current dataset 00061 virtual DataIterator getData() = 0; 00062 00063 // Get the associated mask of the current dataset. Only called if hasMask() returns True; 00064 virtual MaskIterator getMask() = 0; 00065 00066 // Get the stride for the current mask (only called if hasMask() returns True). 00067 virtual uInt getMaskStride() = 0; 00068 00069 // Get the associated range(s) of the current dataset. Only called if hasRanges() returns True; 00070 virtual DataRanges getRanges() = 0; 00071 00072 // Get the stride for the current data set. 00073 virtual uInt getStride() = 0; 00074 00075 // Get the associated weights of the current dataset. Only called if hasWeights() returns True; 00076 virtual WeightsIterator getWeights() = 0; 00077 00078 // Does the current data set have an associated mask? 00079 virtual Bool hasMask() const = 0; 00080 00081 // Does the current data set have associated range(s)? 00082 virtual Bool hasRanges() const = 0; 00083 00084 // Does the current data set have associated weights? 00085 virtual Bool hasWeights() const = 0; 00086 00087 // If the associated data set has ranges, are these include (return True) or 00088 // exclude (return False) ranges? 00089 virtual Bool isInclude() const = 0; 00090 00091 // reset the provider to point to the first data set it manages. 00092 virtual void reset() = 0; 00093 00094 // <group> 00095 // In general, unless you are writing statistics algorithm code, you shouldn't need 00096 // to call these methods. 00097 // The statistics framework calls these methods when the min and max posiitons are 00098 // updated. It passes in the relevant index of the current sub dataset it is processing. 00099 // Data providers can use this information to transform into something more useful, eg 00100 // an IPosition for lattice data providers, so that they may be retreived easily after 00101 // statistics have been calculated. The default implementations do nothing. 00102 virtual void updateMaxPos(const std::pair<Int64, Int64>&) {} 00103 00104 virtual void updateMinPos(const std::pair<Int64, Int64>&) {} 00105 // </group> 00106 00107 protected: 00108 00109 StatsDataProvider(); 00110 00111 }; 00112 00113 } 00114 00115 #ifndef CASACORE_NO_AUTO_TEMPLATES 00116 #include <casacore/scimath/Mathematics/StatsDataProvider.tcc> 00117 #endif //# CASACORE_NO_AUTO_TEMPLATES 00118 00119 #endif