casacore
StatsDataProvider.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 
26 #ifndef SCIMATH_STATSDATAPROVIDER_H
27 #define SCIMATH_STATSDATAPROVIDER_H
28 
29 #include <casacore/scimath/StatsFramework/StatisticsTypes.h>
30 
31 #include <casacore/casa/aips.h>
32 
33 namespace casacore {
34 
35 // Abstract base class which defines interface for providing "datasets" to the
36 // statistics framework in cases where the data structure involved does not
37 // allow for a trivial means of doing so (eg, in the case of a Lattice).
38 
39 template <
40  class AccumType, class DataIterator, class MaskIterator=const Bool *,
41  class WeightsIterator=DataIterator
42 >
44 public:
45 
46  virtual ~StatsDataProvider();
47 
48  // increment the data provider to the next dataset, mask, range set, and
49  // weights.
50  virtual void operator++() = 0;
51 
52  // Are there any data sets left to provide?
53  virtual Bool atEnd() const = 0;
54 
55  // Take any actions necessary to finalize the provider. This will be called
56  // when atEnd() returns True.
57  virtual void finalize() = 0;
58 
59  // get the count of elements in the current data set. When implementing this
60  // method, be certain to take stride into account; ie for a data set with
61  // nominally 100 elements that is to have a stride of two, this method
62  // should return 50.
63  virtual uInt64 getCount() = 0;
64 
65  // get an iterator to the first element of the current dataset
66  virtual DataIterator getData() = 0;
67 
68  // Get an iterator to the first element of the mask for the current dataset.
69  // Only called if hasMask() returns True;
70  virtual MaskIterator getMask() = 0;
71 
72  // Get the stride for the current mask.
73  // Only called if hasMask() returns True.
74  virtual uInt getMaskStride() = 0;
75 
76  // If OpenMP is enabled and statistics methods are being called in a
77  // multi-threaded context, get maximum number of threads that should be
78  // used. If zero is returned, the statistics classes will use the maximum
79  // number of threads available to openmp. Returning less than that helps to
80  // decrease overhead used by statistics methods when the maximum number of
81  // threads available to openmp are unnecessary. The base class
82  // implmentation returns 0.
83  virtual uInt getNMaxThreads() const;
84 
85  // Get the associated range(s) of the current dataset. Only called if
86  // hasRanges() returns True;
87  virtual DataRanges getRanges() = 0;
88 
89  // Get the stride for the current data set.
90  virtual uInt getStride() = 0;
91 
92  // Get an iterator to the first weights element of the current dataset.
93  // Only called if hasWeights() returns True;
94  virtual WeightsIterator getWeights() = 0;
95 
96  // Does the current data set have an associated mask?
97  virtual Bool hasMask() const = 0;
98 
99  // Does the current data set have associated range(s)?
100  virtual Bool hasRanges() const = 0;
101 
102  // Does the current data set have associated weights?
103  virtual Bool hasWeights() const = 0;
104 
105  // If the associated data set has ranges, are these include (return True) or
106  // exclude (return False) ranges?
107  virtual Bool isInclude() const = 0;
108 
109  // reset the provider to point to the beginning of the first data set it
110  // manages.
111  virtual void reset() = 0;
112 
113  // <group>
114  // In general, unless you are writing statistics algorithm code, you
115  // shouldn't need to call these methods.
116  // The statistics framework calls these methods when the min and max
117  // posiitons are updated. It passes in the relevant index of the current sub
118  // dataset it is processing. Data providers can use this information to
119  // transform into something more useful, eg an IPosition for lattice data
120  // providers, so that they may be retreived easily after statistics have
121  // been calculated. The default implementations do nothing.
122  virtual void updateMaxPos(const LocationType&) {}
123 
124  virtual void updateMinPos(const LocationType&) {}
125  // </group>
126 
127 protected:
128 
130 
131 };
132 
133 }
134 
135 #ifndef CASACORE_NO_AUTO_TEMPLATES
136 #include <casacore/scimath/StatsFramework/StatsDataProvider.tcc>
137 #endif //# CASACORE_NO_AUTO_TEMPLATES
138 
139 #endif
#define DataRanges
Abstract base class which defines interface for providing "datasets" to the statistics framework in c...
virtual uInt getNMaxThreads() const
If OpenMP is enabled and statistics methods are being called in a multi-threaded context,...
virtual uInt getMaskStride()=0
Get the stride for the current mask.
virtual DataRanges getRanges()=0
Get the associated range(s) of the current dataset.
virtual void updateMinPos(const LocationType &)
virtual void finalize()=0
Take any actions necessary to finalize the provider.
virtual WeightsIterator getWeights()=0
Get an iterator to the first weights element of the current dataset.
virtual MaskIterator getMask()=0
Get an iterator to the first element of the mask for the current dataset.
virtual Bool hasMask() const =0
Does the current data set have an associated mask?
virtual DataIterator getData()=0
get an iterator to the first element of the current dataset
virtual void reset()=0
reset the provider to point to the beginning of the first data set it manages.
virtual Bool isInclude() const =0
If the associated data set has ranges, are these include (return True) or exclude (return False) rang...
virtual Bool atEnd() const =0
Are there any data sets left to provide?
virtual void operator++()=0
increment the data provider to the next dataset, mask, range set, and weights.
virtual Bool hasWeights() const =0
Does the current data set have associated weights?
virtual uInt getStride()=0
Get the stride for the current data set.
virtual Bool hasRanges() const =0
Does the current data set have associated range(s)?
virtual void updateMaxPos(const LocationType &)
In general, unless you are writing statistics algorithm code, you shouldn't need to call these method...
virtual uInt64 getCount()=0
get the count of elements in the current data set.
this file contains all the compiler specific defines
Definition: mainpage.dox:28
unsigned int uInt
Definition: aipstype.h:51
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
unsigned long long uInt64
Definition: aipsxtype.h:39
std::pair< Int64, Int64 > LocationType