casacore
Loading...
Searching...
No Matches
ScalarSampledFunctional.h
Go to the documentation of this file.
1// # ScalarSampledFunctional.h:
2// # Copyright (C) 1996
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_SCALARSAMPLEDFUNCTIONAL_H
27#define SCIMATH_SCALARSAMPLEDFUNCTIONAL_H
28
29#include <casacore/casa/aips.h>
30#include <casacore/scimath/Functionals/SampledFunctional.h>
31#include <casacore/casa/Arrays/Vector.h>
32
33namespace casacore { // # NAMESPACE CASACORE - BEGIN
34
35template <class T>
36class Block;
37
38// <summary> A unified interface for indexing into Vectors or Blocks </summary>
39
40// <use visibility=export>
41
42// <reviewed reviewer="wyoung" date="1996/10/18" tests="tSampledFunctional.cc">
43
44// <prerequisite>
45// <li> <linkto class="SampledFunctional">SampledFunctional</linkto>
46// <li> <linkto class="Vector">Vector</linkto>
47// <li> <linkto class="Block">Block</linkto>
48// </prerequisite>
49
50// <etymology>
51// A SampledFunctional is an interface that allows random access to a fixed
52// size data set. I originally conceived this class as being used to access
53// scalar values (Int's Float's etc.) stored in Vectors, using the
54// SampledFunctional interface. It became generalised to incorporate Blocks
55// and I now realise that a better name might be MemorySampledFunctional, to
56// highlight that the data is stored in memory (and not on disk).
57// </etymology>
58
59// <synopsis>
60// This derived class allows allows a Block<T> or Vector<T> object to be
61// accessed through the SampledFunctional<T> interface. The principle
62// advantage of this is that it unifies the different indexing operators
63// (ie. [] for Blocks and () for Vectors). The disadvantage is that it hides
64// just about all the other functionality of Vectors and Blocks. If all you
65// are interested in is random access to various elements of these objects
66// then this class is a suitable abstraction.
67
68// Reference semantics are used (ie. the class does not make a copy of the
69// data but refers to the original data) whenever possible. It is not
70// possible to use reference semantics (so a physical copy of the data is
71// made), in the following cases:
72// <ul>
73// <li> When constructing the class from a Block<T>
74// <li> When constructing the class from a const Vector<T>
75// </ul>
76// Reference semantics are always used for the copy constructor and
77// assignment operators when the ScalarSampledFunctional is
78// non-const. Otherwise copy semantics are used.
79
80// When reference semantics are used you need to be aware that modifying the
81// contents of the original Vector will modify the data used by this class.
82
83// This class is always more efficient if reference semantics are used, so
84// avoid using const arguments unless you really need to.
85
86// </synopsis>
87
88// <example>
89// Constructing and using ScalarSampledFunctional's
90// <srcblock>
91// Block<Float> b(10); // Create a block of ten elements
92// // ... Fill the block any way you like ...
93// ScalarSampledFunctional<Float> fb(b);
94// for(uInt i = 0; i < 10; i++)
95// cout << "f(" << i << ") = " << fb(i) << endl;
96// </srcblock>
97// </example>
98
99// <motivation>
100// The SampledFunctional is a useful interface. But it needs some concrete
101// classes to back it up. This is the first one that was written.
102// </motivation>
103
104// <templating arg=Range>
105// <li> Very few assumptions are made on the templating type. So this class
106// should work for a wide variety of templates types.
107// </templating>
108
109// <thrown>
110// <li> Exceptions are not thrown directly by this class.
111// </thrown>
112
113// <todo asof="1996/10/28">
114// <li> Nothing I can think of
115// </todo>
116
117template <class T>
119 public:
120 // See the description above to determine whether a copy or a reference is
121 // made to the original data.
122 // <group>
127 // </group>
128
129 // The standard copy constructor and assignment operator. These functions
130 // use reference semantics when the ScalarSampledFunctional is
131 // non-const, and copy semantics otherwise.
132 // <group>
137 // </group>
138
139 // Define the functions for the SampledFunctional interface
140 // <group>
141 virtual T operator()(const uInt &index) const;
142 virtual uInt nelements() const;
144 // </group>
145
146 private:
148};
149
150} // namespace casacore
151
152#ifndef CASACORE_NO_AUTO_TEMPLATES
153#include <casacore/scimath/Functionals/ScalarSampledFunctional.tcc>
154#endif // # CASACORE_NO_AUTO_TEMPLATES
155#endif
ScalarSampledFunctional(ScalarSampledFunctional< T > &other)
The standard copy constructor and assignment operator.
ScalarSampledFunctional(const ScalarSampledFunctional< T > &other)
ScalarSampledFunctional< T > & operator=(ScalarSampledFunctional< T > &other)
ScalarSampledFunctional(Vector< T > &data)
virtual T operator()(const uInt &index) const
Define the functions for the SampledFunctional interface.
ScalarSampledFunctional(const Block< T > &data)
ScalarSampledFunctional< T > & operator=(const ScalarSampledFunctional< T > &other)
virtual uInt nelements() const
Return the total size of the data set.
ScalarSampledFunctional()
See the description above to determine whether a copy or a reference is made to the original data.
ScalarSampledFunctional(const Vector< T > &data)
For temporary backward namespace compatibility, use casa as alias for casacore.
Definition mainpage.dox:28
unsigned int uInt
Definition aipstype.h:49