casacore
Loading...
Searching...
No Matches
SampledFunctional.h
Go to the documentation of this file.
1//# SampledFunctional.h:
2//# Copyright (C) 1996,1999
3//# Associated Universities, Inc. Washington DC, USA.
4//#
5//# This library is free software; you can redistribute it and/or modify it
6//# under the terms of the GNU Library General Public License as published by
7//# the Free Software Foundation; either version 2 of the License, or (at your
8//# option) any later version.
9//#
10//# This library is distributed in the hope that it will be useful, but WITHOUT
11//# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12//# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13//# License for more details.
14//#
15//# You should have received a copy of the GNU Library General Public License
16//# along with this library; if not, write to the Free Software Foundation,
17//# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18//#
19//# Correspondence concerning AIPS++ should be addressed as follows:
20//# Internet email: casa-feedback@nrao.edu.
21//# Postal address: AIPS++ Project Office
22//# National Radio Astronomy Observatory
23//# 520 Edgemont Road
24//# Charlottesville, VA 22903-2475 USA
25
26#ifndef SCIMATH_SAMPLEDFUNCTIONAL_H
27#define SCIMATH_SAMPLEDFUNCTIONAL_H
28
29#include <casacore/casa/aips.h>
30#include <casacore/casa/BasicMath/Functional.h>
31
32namespace casacore { //# NAMESPACE CASACORE - BEGIN
33
34// <summary> A base class for indexing into arbitrary data types </summary>
35
36// <use visibility=export>
37
38// <reviewed reviewer="wyoung" date="1996/10/10" tests="tSampledFunctional.cc">
39
40// <prerequisite>
41// <li> Functional
42// </prerequisite>
43
44// <etymology>
45// A Functional is simply a mapping from a Domain type to a Range
46// type. Experimental data is usually sampled, and is can be represented as
47// a mapping from the unsigned integers to an arbitrary Domain.
48// </etymology>
49
50// <synopsis>
51// This abstract class defines an interface for functions that map from the
52// unsigned integers to an arbitrary type. It defines two functions: the
53// operator() function which it inherits from the Functional class, and the
54// nelements function which is necessary to know how many data elements.
55//
56// This class is useful for freeing the writer of other classes from having
57// to know how how a linear data set is stored or represented. For example,
58// four floating point numbers will probably be stored as a Vector<Float>,
59// and kept in memory for fast access. But 400 million floating point
60// numbers cannot usually be kept in memory, and may be stored on disk as a
61// Table. By using a SampledFunctional writers of other classes
62// (Interpolate1D is an example), can ignore these details if all they are
63// interested in is random access to individual elements of the data.
64// </synopsis>
65
66// <example>
67// Because this is an abstract class the example will be inside a function
68// <srcblock>
69// T sum(SampledFunctional<T> data)
70// {
71// T result = 0;
72// for (uInt i = 0; i < data.nelements(); i++)
73// result += data(i);
74// return result;
75// }
76// </srcblock>
77// </example>
78
79// <motivation>
80// If all you need to do is random access indexing into arbitrary data sets
81// this class provides a suitable abstraction of that functionality.
82// </motivation>
83
84// <templating arg=Range>
85// <li> Templating restrictions will depend on the actual derived class that is
86// used.
87// </templating>
88
89// <thrown>
90// <li> Exceptions will depend on derived classes and the templating
91// arguements. This abstract class only defines an interface and does not
92// throw any exceptions.
93// </thrown>
94
95// <todo asof="1996/10/19">
96// <li> I cannot think of anything
97// </todo>
98
99template <class Range> class SampledFunctional:
100 public Functional<uInt, Range>
101{
102public:
103 // Access the specified element of the data
104 virtual Range operator()(const uInt &index) const = 0;
105 // Return the total size of the data set.
106 virtual uInt nelements() const = 0;
107 // The virtual destructor does nothing
109};
110
111
112} //# NAMESPACE CASACORE - END
113
114#endif
virtual uInt nelements() const =0
Return the total size of the data set.
virtual ~SampledFunctional()
The virtual destructor does nothing.
virtual Range operator()(const uInt &index) const =0
Access the specified element of the data.
this file contains all the compiler specific defines
Definition mainpage.dox:28
unsigned int uInt
Definition aipstype.h:49