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