casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
SampledFunctional.h
Go to the documentation of this file.
00001 //# SampledFunctional.h:
00002 //# Copyright (C) 1996,1999
00003 //# Associated Universities, Inc. Washington DC, USA.
00004 //#
00005 //# This library is free software; you can redistribute it and/or modify it
00006 //# under the terms of the GNU Library General Public License as published by
00007 //# the Free Software Foundation; either version 2 of the License, or (at your
00008 //# option) any later version.
00009 //#
00010 //# This library is distributed in the hope that it will be useful, but WITHOUT
00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00013 //# License for more details.
00014 //#
00015 //# You should have received a copy of the GNU Library General Public License
00016 //# along with this library; if not, write to the Free Software Foundation,
00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00018 //#
00019 //# Correspondence concerning AIPS++ should be addressed as follows:
00020 //#        Internet email: aips2-request@nrao.edu.
00021 //#        Postal address: AIPS++ Project Office
00022 //#                        National Radio Astronomy Observatory
00023 //#                        520 Edgemont Road
00024 //#                        Charlottesville, VA 22903-2475 USA
00025 //#
00026 //# $Id: SampledFunctional.h 21024 2011-03-01 11:46:18Z gervandiepen $
00027 
00028 #ifndef SCIMATH_SAMPLEDFUNCTIONAL_H
00029 #define SCIMATH_SAMPLEDFUNCTIONAL_H
00030 
00031 #include <casa/aips.h>
00032 #include <casa/BasicMath/Functional.h>
00033 
00034 namespace casa { //# NAMESPACE CASA - BEGIN
00035 
00036 // <summary> A base class for indexing into arbitrary data types </summary>
00037 
00038 // <use visibility=export>
00039 
00040 // <reviewed reviewer="wyoung" date="1996/10/10" tests="tSampledFunctional.cc">
00041 
00042 // <prerequisite>
00043 //   <li> Functional
00044 // </prerequisite>
00045 
00046 // <etymology>
00047 // A Functional is simply a mapping from a Domain type to a Range
00048 // type. Experimental data is usually sampled, and is can be represented as
00049 // a mapping from the unsigned integers to an arbitrary Domain.
00050 // </etymology>
00051 
00052 // <synopsis>
00053 // This abstract class defines an interface for functions that map from the
00054 // unsigned integers to an arbitrary type. It defines two functions: the
00055 // operator() function which it inherits from the Functional class, and the
00056 // nelements function which is necessary to know how many data elements. 
00057 //
00058 // This class is useful for freeing the writer of other classes from having
00059 // to know how how a linear data set is stored or represented. For example,
00060 // four floating point numbers will probably be stored as a Vector<Float>,
00061 // and kept in memory for fast access. But 400 million floating point
00062 // numbers cannot usually be kept in memory, and may be stored on disk as a
00063 // Table. By using a SampledFunctional writers of other classes
00064 // (Interpolate1D is an example), can ignore these details if all they are
00065 // interested in is random access to individual elements of the data.
00066 // </synopsis>
00067 
00068 // <example>
00069 // Because this is an abstract class the example will be inside a function
00070 // <srcblock>
00071 // T sum(SampledFunctional<T> data)
00072 // {
00073 //   T result = 0;
00074 //   for (uInt i = 0; i < data.nelements(); i++)
00075 //     result += data(i);
00076 //   return result;
00077 // }
00078 // </srcblock>
00079 // </example>
00080 
00081 // <motivation>
00082 // If all you need to do is random access indexing into arbitrary data sets
00083 // this class provides a suitable abstraction of that functionality.
00084 // </motivation>
00085 
00086 // <templating arg=Range>
00087 // <li> Templating restrictions will depend on the actual derived class that is
00088 // used. 
00089 // </templating>
00090 
00091 // <thrown>
00092 // <li> Exceptions will depend on derived classes and the templating
00093 // arguements. This abstract class only defines an interface and does not
00094 // throw any exceptions. 
00095 // </thrown>
00096 
00097 // <todo asof="1996/10/19">
00098 //   <li> I cannot think of anything
00099 // </todo>
00100 
00101 template <class Range> class SampledFunctional: 
00102   public Functional<uInt, Range>
00103 {
00104 public:
00105   // Access the specified element of the data
00106   virtual Range operator()(const uInt &index) const = 0;
00107   // Return the total size of the data set.
00108   virtual uInt nelements() const = 0;
00109   // The virtual destructor does nothing
00110   virtual ~SampledFunctional(){}
00111 };
00112 
00113 
00114 } //# NAMESPACE CASA - END
00115 
00116 #endif