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