casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
FunctionOrder.h
Go to the documentation of this file.
00001 //# FunctionOrder.h: Container of function description details
00002 //# Copyright (C) 2002,2003
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: FunctionOrder.h 21024 2011-03-01 11:46:18Z gervandiepen $
00027 
00028 #ifndef SCIMATH_FUNCTIONORDER_H
00029 #define SCIMATH_FUNCTIONORDER_H
00030 
00031 //# Include files
00032 #include <casa/aips.h>
00033 #include <casa/Arrays/Vector.h>
00034 #include <casa/Containers/Block.h>
00035 #include <casa/Utilities/RecordTransformable.h>
00036 #include <scimath/Functionals/Function.h>
00037 #include <casa/BasicSL/String.h>
00038 #include <casa/iosfwd.h>
00039 
00040 namespace casa { //# NAMESPACE CASA - BEGIN
00041 
00042 //# Forward declarations
00043 class RecordInterface;
00044 
00045 // <summary> Container of function description details
00046 // </summary>
00047 //
00048 // <use visibility=export>
00049 //
00050 // <reviewed reviewer="UNKNOWN" date="before2004/08/25"tFunctionOrder"
00051 //       demos="">
00052 // </reviewed>
00053 //
00054 // <synopsis>
00055 // <src>FunctionOrder</src> is used to provide an interface to an entity which
00056 // has special fixed parameters (like dimension of Gaussian; oder of
00057 // Polynomial). 
00058 // This is useful, for example, in implementinggeneric function factories.
00059 // 
00060 // </synopsis>
00061 //
00062 // <example>
00063 // See the <linkto class=FunctionHolder>FunctionHolder</linkto>
00064 // class for a usage interface.
00065 // </example>
00066 //
00067 // <motivation>
00068 // Generically manipulatable parameters are important for Glish interface
00069 // </motivation>
00070 //
00071 // <templating arg=T>
00072 //  <li> <src>T</src> must have a default constructor, assignment operator,
00073 //       and copy constructor (for the Vector interface). 
00074 //  <li> Complex/DComplex or Float/Double supported
00075 // </templating>
00076 //
00077 // <todo asof="2002/05/28">
00078 //   <li> Nothing I know of
00079 // </todo>
00080 
00081 template<class T> class FunctionOrder : public RecordTransformable {
00082  public:
00083   //# Constructors
00084   // Construct a default FunctionOrder with 0 parameters
00085   FunctionOrder();
00086   // Copy constructor (deep copy)
00087   FunctionOrder(const FunctionOrder<T> &other);
00088   // Destructor
00089   virtual ~FunctionOrder();
00090 
00091   //# Operators
00092   // Copy assignment (deep copy)
00093   FunctionOrder &operator=(const FunctionOrder<T> &other);
00094 
00095   //# Member functions
00096   // Get and set the various parameters (no check for index range).
00097   // Automatic extension for write.
00098   // <group>
00099   Int &getInt(const uInt n);
00100   const Int &getInt(const uInt n) const;
00101   T &getPar(const uInt n);
00102   const T &getPar(const uInt n) const;
00103   String &getString();
00104   const String &getString() const;
00105   T &getScale(const uInt n);
00106   const T &getScale(const uInt n) const;
00107   T &getCenter(const uInt n);
00108   const T &getCenter(const uInt n) const;
00109   T &getWidth(const uInt n);
00110   const T &getWidth(const uInt n) const;
00111   const Function<T> &getFunction(const uInt n) const;
00112   void setFunction(const uInt n, Function<T> &other);
00113   // </group>
00114 
00115   // Create a FunctionOrder from a record
00116   // Error messages are postfixed to error.
00117   // <group>
00118   virtual Bool fromRecord(String &error, const RecordInterface &in);
00119   virtual Bool fromString(String &error, const String &in);
00120   // </group>
00121   // Create a record from a FunctionOrder.
00122   // Error messages are postfixed to error.
00123   virtual Bool toRecord(String &error, RecordInterface &out) const;
00124   // Get identification of record
00125   virtual const String &ident() const;
00126 
00127   // Output the parameters
00128   ostream &print(ostream &os) const;
00129 
00130  private:
00131   //# Data
00132   // All data vectors can be empty
00133   // <group>
00134   // Integer details (order etc)
00135   Vector<Int> int_p;
00136   // Double parameters
00137   Vector<T> double_p;
00138   // String parameters
00139   String string_p;
00140   // List of functions (say for Combi and Compound)
00141   PtrBlock<Function<T> *> function_p;
00142   // Scale of y (length 1)
00143   Vector<T> scale_p;
00144   // Centers of x (length ndim)
00145   Vector<T> center_p;
00146   // Width of x (ndim)
00147   Vector<T> width_p;
00148   // </group>
00149 
00150 };
00151 
00152 //# Global functions
00153 // <summary> Global functions </summary>
00154 // <group name=Output>
00155 // Output declaration
00156 template<class T>
00157 ostream &operator<<(ostream &os, const FunctionOrder<T> &par);
00158 // </group>
00159 
00160 //# Inlines
00161 template<class T>
00162 inline ostream &operator<<(ostream &os, const FunctionOrder<T> &par) {
00163   return par.print(os); }
00164 
00165 
00166 } //# NAMESPACE CASA - END
00167 
00168 #ifndef CASACORE_NO_AUTO_TEMPLATES
00169 #include <scimath/Functionals/FunctionOrder.tcc>
00170 #endif //# CASACORE_NO_AUTO_TEMPLATES
00171 #endif
00172