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