casacore
Loading...
Searching...
No Matches
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: casa-feedback@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#ifndef SCIMATH_WRAPPERBASE_H
27#define SCIMATH_WRAPPERBASE_H
28
29//# Includes
30#include <casacore/casa/aips.h>
31#include <casacore/scimath/Functionals/Function.h>
32#include <casacore/casa/Arrays/Vector.h>
33
34namespace casacore { //# NAMESPACE CASACORE - BEGIN
35
36//# Forward declarations
37
38// <summary> Aid in constructing function objects from C++ functions
39// </summary>
40//
41// <use visibility=local>
42//
43// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="" demos="">
44// </reviewed>
45//
46// <prerequisite>
47// <li> <linkto class="FunctionWrapper">FunctionWrapper</linkto> class
48// <li> <linkto class="WrapperData">WrapperData</linkto> class
49// </prerequisite>
50//
51// <synopsis>
52// This base class is provided to enable compile time selection of the
53// appropriate function call through <src>WrapperData</src>.
54// </synopsis>
55//
56// <example>
57// <srcblock>
58// Float func(const Vector<Float>& x) { return x(0)*x(1); } // x*y
59// // Convert C++ functions to Functionals
60// FunctionWrapper<Float> Func(func, 2);
61// </srcblock>
62//
63
64template<class T> class WrapperBase {
65 public:
66 //# Constructors
67 // Default constructor: zero dimension
68 WrapperBase() : ndim_p(0), arg_p(0) {}
69 // Standard constructor
70 explicit WrapperBase(const uInt dim) : ndim_p(dim), arg_p(dim) {}
71
72 // Destructor
73 virtual ~WrapperBase() {}
74
75 //# Operators
76 // Evaluate the function at <src>x</src>.
77 // <group>
78 virtual T eval(typename Function<T>::FunctionArg x,
79 const Vector<T> &par) const = 0;
80 // </group>
81
82 //# Member functions
83 // Get the dimensionality
84 virtual uInt ndim() const { return ndim_p; }
85
86 protected:
87 //# Data
88 // Dimensionality
90 // Vector argument interface
92
93 private:
94 // Copy constructor and assignment (not implemented)
95 // <group>
98 // </group>
99
100};
101
102
103} //# NAMESPACE CASACORE - END
104
105#endif
virtual ~WrapperBase()
Destructor.
Definition WrapperBase.h:73
virtual uInt ndim() const
Get the dimensionality.
Definition WrapperBase.h:84
WrapperBase(const uInt dim)
Standard constructor.
Definition WrapperBase.h:70
virtual T eval(typename Function< T >::FunctionArg x, const Vector< T > &par) const =0
Evaluate the function at x.
WrapperBase< T > & operator=(const WrapperBase< T > &other)
WrapperBase()
Default constructor: zero dimension.
Definition WrapperBase.h:68
Vector< T > arg_p
Vector argument interface.
Definition WrapperBase.h:91
WrapperBase(const WrapperBase< T > &other)
Copy constructor and assignment (not implemented)
uInt ndim_p
Dimensionality.
Definition WrapperBase.h:89
this file contains all the compiler specific defines
Definition mainpage.dox:28
unsigned int uInt
Definition aipstype.h:49