Loading...
Searching...
No Matches
casacore::ScalarSampledFunctional< T > Class Template Reference
scimath package (libcasa_scimath) » Functionals_module

More...

`#include <ScalarSampledFunctional.h>`

## Public Member Functions

| ScalarSampledFunctional ()
| See the description above to determine whether a copy or a reference is made to the original data.
| ScalarSampledFunctional (Vector< T > &data)
| ScalarSampledFunctional (const Vector< T > &data)
| ScalarSampledFunctional (const Block< T > &data)
| ScalarSampledFunctional (ScalarSampledFunctional< T > &other)
| The standard copy constructor and assignment operator.
| ScalarSampledFunctional (const ScalarSampledFunctional< T > &other)
ScalarSampledFunctional< T > & | operator= (ScalarSampledFunctional< T > &other)
ScalarSampledFunctional< T > & | operator= (const ScalarSampledFunctional< T > &other)
virtual T | operator() (const uInt &index) const
| Define the functions for the SampledFunctional interface.
virtual uInt | nelements () const
| Return the total size of the data set.
virtual | ~ScalarSampledFunctional ()
Public Member Functions inherited from casacore::SampledFunctional< T >
virtual | ~SampledFunctional ()
| The virtual destructor does nothing.
Public Member Functions inherited from casacore::Functional< uInt, T >
virtual | ~Functional ()
| Destructor.

## Private Attributes

Vector< T > | refData

## Detailed Description

template<class T>
class casacore::ScalarSampledFunctional< T >

A unified interface for indexing into Vectors or Blocks

### Intended use:

Public interface

### Review Status

Reviewed By:
  wyoung
Date Reviewed:
  1996/10/18
Test programs:
  tSampledFunctional

### Prerequisite

- SampledFunctional
- Vector
- Block

### Etymology

A SampledFunctional is an interface that allows random access to a fixed size data set. I originally conceived this class as being used to access scalar values (Int's Float's etc.) stored in Vectors, using the SampledFunctional interface. It became generalised to incorporate Blocks and I now realise that a better name might be MemorySampledFunctional, to highlight that the data is stored in memory (and not on disk).

### Synopsis

This derived class allows allows a Block<T> or Vector<T> object to be accessed through the SampledFunctional<T> interface. The principle advantage of this is that it unifies the different indexing operators (ie. [] for Blocks and () for Vectors). The disadvantage is that it hides just about all the other functionality of Vectors and Blocks. If all you are interested in is random access to various elements of these objects then this class is a suitable abstraction.

Reference semantics are used (ie. the class does not make a copy of the data but refers to the original data) whenever possible. It is not possible to use reference semantics (so a physical copy of the data is made), in the following cases:

- When constructing the class from a Block<T>
- When constructing the class from a const Vector<T>

Reference semantics are always used for the copy constructor and assignment operators when the ScalarSampledFunctional is non-const. Otherwise copy semantics are used.

When reference semantics are used you need to be aware that modifying the contents of the original Vector will modify the data used by this class.

This class is always more efficient if reference semantics are used, so avoid using const arguments unless you really need to.

### Example

Constructing and using ScalarSampledFunctional's

Block<Float> b(10); // Create a block of ten elements
//... Fill the block any way you like..\.
ScalarSampledFunctional<Float> fb(b);
for(uInt i = 0; i < 10; i++)
cout << "f(" << i << ") = " << fb(i) << endl;
casacore::Block
simple 1-D array
Definition Block.h:198
casacore::ScalarSampledFunctional::ScalarSampledFunctional
ScalarSampledFunctional()
See the description above to determine whether a copy or a reference is made to the original data.
casacore::uInt
unsigned int uInt
Definition aipstype.h:49

### Motivation

The SampledFunctional is a useful interface. But it needs some concrete classes to back it up. This is the first one that was written.

### Template Type Argument Requirements (Range)

- Very few assumptions are made on the templating type. So this class should work for a wide variety of templates types.

### Thrown Exceptions

- Exceptions are not thrown directly by this class.

### To Do

- Nothing I can think of

Definition at line 116 of file ScalarSampledFunctional.h.

## Constructor & Destructor Documentation

## ScalarSampledFunctional() [1/6]

template<class T>

casacore::ScalarSampledFunctional< T >::ScalarSampledFunctional | ( |  | ) |

See the description above to determine whether a copy or a reference is made to the original data.

Referenced by operator=(), operator=(), ScalarSampledFunctional(), and ScalarSampledFunctional().

## ScalarSampledFunctional() [2/6]

template<class T>

casacore::ScalarSampledFunctional< T >::ScalarSampledFunctional | ( | Vector< T > & | data | ) |

## ScalarSampledFunctional() [3/6]

template<class T>

casacore::ScalarSampledFunctional< T >::ScalarSampledFunctional | ( | const Vector< T > & | data | ) |

## ScalarSampledFunctional() [4/6]

template<class T>

casacore::ScalarSampledFunctional< T >::ScalarSampledFunctional | ( | const Block< T > & | data | ) |

## ScalarSampledFunctional() [5/6]

template<class T>

casacore::ScalarSampledFunctional< T >::ScalarSampledFunctional | ( | ScalarSampledFunctional< T > & | other | ) |

The standard copy constructor and assignment operator.

These functions use reference semantics when the ScalarSampledFunctional is non-const, and copy semantics otherwise.

References ScalarSampledFunctional().

## ScalarSampledFunctional() [6/6]

template<class T>

casacore::ScalarSampledFunctional< T >::ScalarSampledFunctional | ( | const ScalarSampledFunctional< T > & | other | ) |

References ScalarSampledFunctional().

## ~ScalarSampledFunctional()

template<class T>

virtual casacore::ScalarSampledFunctional< T >::~ScalarSampledFunctional | ( |  | ) |

virtual

## Member Function Documentation

## nelements()

template<class T>

virtual uInt casacore::ScalarSampledFunctional< T >::nelements | ( |  | ) | const

virtual

Return the total size of the data set.

Implements casacore::SampledFunctional< T >.

## operator()()

template<class T>

virtual T casacore::ScalarSampledFunctional< T >::operator() | ( | const uInt & | index | ) | const

virtual

Define the functions for the SampledFunctional interface.

Implements casacore::SampledFunctional< T >.

## operator=() [1/2]

template<class T>

ScalarSampledFunctional< T > & casacore::ScalarSampledFunctional< T >::operator= | ( | const ScalarSampledFunctional< T > & | other | ) |

References ScalarSampledFunctional().

## operator=() [2/2]

template<class T>

ScalarSampledFunctional< T > & casacore::ScalarSampledFunctional< T >::operator= | ( | ScalarSampledFunctional< T > & | other | ) |

References ScalarSampledFunctional().

## Member Data Documentation

## refData

template<class T>

Vector<T> casacore::ScalarSampledFunctional< T >::refData

private

Definition at line 147 of file ScalarSampledFunctional.h.

The documentation for this class was generated from the following file:

- scimath/Functionals/ScalarSampledFunctional.h