casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
WrapperBase.h
Go to the documentation of this file.
1 //# WrapperBase.h: Aid in constructing function objects from C++ functions
2 //# Copyright (C) 2001,2002
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 //# $Id$
27 
28 #ifndef SCIMATH_WRAPPERBASE_H
29 #define SCIMATH_WRAPPERBASE_H
30 
31 //# Includes
32 #include <casacore/casa/aips.h>
35 
36 namespace casacore { //# NAMESPACE CASACORE - BEGIN
37 
38 //# Forward declarations
39 
40 // <summary> Aid in constructing function objects from C++ functions
41 // </summary>
42 //
43 // <use visibility=local>
44 //
45 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="" demos="">
46 // </reviewed>
47 //
48 // <prerequisite>
49 // <li> <linkto class="FunctionWrapper">FunctionWrapper</linkto> class
50 // <li> <linkto class="WrapperData">WrapperData</linkto> class
51 // </prerequisite>
52 //
53 // <synopsis>
54 // This base class is provided to enable compile time selection of the
55 // appropriate function call through <src>WrapperData</src>.
56 // </synopsis>
57 //
58 // <example>
59 // <srcblock>
60 // Float func(const Vector<Float>& x) { return x(0)*x(1); } // x*y
61 // // Convert C++ functions to Functionals
62 // FunctionWrapper<Float> Func(func, 2);
63 // </srcblock>
64 //
65 
66 template<class T> class WrapperBase {
67  public:
68  //# Constructors
69  // Default constructor: zero dimension
70  WrapperBase() : ndim_p(0), arg_p(0) {}
71  // Standard constructor
72  explicit WrapperBase(const uInt dim) : ndim_p(dim), arg_p(dim) {}
73 
74  // Destructor
75  virtual ~WrapperBase() {}
76 
77  //# Operators
78  // Evaluate the function at <src>x</src>.
79  // <group>
80  virtual T eval(typename Function<T>::FunctionArg x,
81  const Vector<T> &par) const = 0;
82  // </group>
83 
84  //# Member functions
85  // Get the dimensionality
86  virtual uInt ndim() const { return ndim_p; }
87 
88  protected:
89  //# Data
90  // Dimensionality
92  // Vector argument interface
93  mutable Vector<T> arg_p;
94 
95  private:
96  // Copy constructor and assignment (not implemented)
97  // <group>
98  WrapperBase(const WrapperBase<T> &other);
100  // </group>
101 
102 };
103 
104 
105 } //# NAMESPACE CASACORE - END
106 
107 #endif
virtual T eval(typename Function< T >::FunctionArg x, const Vector< T > &par) const =0
Evaluate the function at x.
A 1-D Specialization of the Array class.
Vector< T > arg_p
Vector argument interface.
Definition: WrapperBase.h:93
virtual ~WrapperBase()
Destructor.
Definition: WrapperBase.h:75
uInt ndim_p
Dimensionality.
Definition: WrapperBase.h:91
Numerical functional interface class.
virtual uInt ndim() const
Get the dimensionality.
Definition: WrapperBase.h:86
WrapperBase()
Default constructor: zero dimension.
Definition: WrapperBase.h:70
WrapperBase(const uInt dim)
Standard constructor.
Definition: WrapperBase.h:72
WrapperBase< T > & operator=(const WrapperBase< T > &other)
Aid in constructing function objects from C++ functions.
Definition: WrapperBase.h:66
unsigned int uInt
Definition: aipstype.h:51
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42