casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
WrapperBase.h
Go to the documentation of this file.
00001 //# WrapperBase.h: Aid in constructing function objects from C++ functions 
00002 //# Copyright (C) 2001,2002
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: WrapperBase.h 21024 2011-03-01 11:46:18Z gervandiepen $
00027 
00028 #ifndef SCIMATH_WRAPPERBASE_H
00029 #define SCIMATH_WRAPPERBASE_H
00030 
00031 //# Includes
00032 #include <casa/aips.h>
00033 #include <scimath/Functionals/Function.h>
00034 #include <casa/Arrays/Vector.h>
00035 
00036 namespace casa { //# NAMESPACE CASA - BEGIN
00037 
00038 //# Forward declarations
00039 
00040 // <summary> Aid in constructing function objects from C++ functions 
00041 // </summary>
00042 //
00043 // <use visibility=local>
00044 //
00045 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="" demos="">
00046 // </reviewed>
00047 //
00048 // <prerequisite>
00049 //   <li> <linkto class="FunctionWrapper">FunctionWrapper</linkto> class
00050 //   <li> <linkto class="WrapperData">WrapperData</linkto> class
00051 // </prerequisite>
00052 //
00053 // <synopsis>
00054 // This base class is provided to enable compile time selection of the
00055 // appropriate function call through <src>WrapperData</src>.
00056 // </synopsis>
00057 //
00058 // <example>
00059 // <srcblock>
00060 // Float func(const Vector<Float>& x) { return x(0)*x(1); }        // x*y
00061 // // Convert C++ functions to Functionals
00062 // FunctionWrapper<Float> Func(func, 2);
00063 // </srcblock>
00064 //
00065 
00066 template<class T> class WrapperBase {
00067  public:
00068   //# Constructors
00069   // Default constructor: zero dimension
00070   WrapperBase() : ndim_p(0), arg_p(0) {}
00071   // Standard constructor
00072   explicit WrapperBase(const uInt dim) : ndim_p(dim), arg_p(dim) {}
00073 
00074   // Destructor
00075   virtual ~WrapperBase() {}
00076 
00077   //# Operators    
00078   // Evaluate the function at <src>x</src>.
00079   // <group>
00080   virtual T eval(typename Function<T>::FunctionArg x,
00081                  const Vector<T> &par) const = 0;
00082   // </group>
00083 
00084   //# Member functions
00085   // Get the dimensionality
00086   virtual uInt ndim() const { return ndim_p; }
00087 
00088  protected:
00089   //# Data
00090   // Dimensionality
00091   uInt ndim_p;
00092   // Vector argument interface
00093   mutable Vector<T> arg_p;
00094 
00095  private:
00096   // Copy constructor and assignment (not implemented)
00097   // <group>
00098   WrapperBase(const WrapperBase<T> &other);
00099   WrapperBase<T> &operator=(const WrapperBase<T> &other);
00100   // </group>
00101 
00102 };
00103 
00104 
00105 } //# NAMESPACE CASA - END
00106 
00107 #endif