FunctionHolder.h
Classes
- FunctionHolder -- A holder for Functions to enable record conversions (full description)
Types
- GAUSSIAN1D
-
- GAUSSIAN2D
-
- GAUSSIAN3D
-
- GAUSSIANND
-
- HYPERPLANE
-
- POLYNOMIAL
-
- EVENPOLYNOMIAL
-
- ODDPOLYNOMIAL
-
- SINUSOID1D
-
- CHEBYSHEV
-
- BUTTERWORTH
-
- COMBINE
-
- COMPOUND
-
- COMPILED
-
- N_Types
-
Interface
- Public Members
- FunctionHolder()
- FunctionHolder(const Function<T> &in)
- FunctionHolder(const FunctionHolder<T> &other)
- ~FunctionHolder()
- FunctionHolder &operator=(const FunctionHolder<T> &other)
- Bool isEmpty() const
- const Vector<String> &names() const
- const Function<T> &asFunction() const
- Bool addFunction(const Function<T> &fnc)
- FunctionHolder<T>::Types type() const
- virtual Bool fromRecord(String &error, const RecordInterface &in)
- virtual Bool fromString(String &error, const String &in)
- template <class U> Bool getRecord(U &error, String<U> *&fn, const RecordInterface &in)
- virtual Bool toRecord(String &error, RecordInterface &out) const
- virtual const String &ident() const
- Private Members
- void init() const
- Bool putType(String &error, RecordInterface &out) const
- template <class U> Bool getType(U &error, String<U> *&fn, const RecordInterface &in)
- template <class U> Bool getType(U &error, String<U> *&fn)
- void FunctionHolder<T>::setParameters(Function<T> *&fn, const Function<T> ¶ms)
- void FunctionHolder<T>::setParameters(Function<Function<T> > *&fn, const AutoDiff<T> ¶ms)
Review Status
- Date Reviewed:
- yyyy/mm/dd
- Programs:
- Tests:
Prerequisite
Etymology
A Holder of general Measures
Synopsis
This class can be used to handle heterogeneous collections of Functions,
e.g. as a Vector<FunctionHolder>. With the aid of the
toRecord() and fromRecord() functions it can be used
to convert a Function object into or from a record.
A FunctionHolder is created from a Function, or can be empty.
Example
TableRecord rec;
MDirection dir(MVDirection(Quantity(12.5, 'deg'), Quantity(-2, 'deg')),
MDirection::J2000);
String error; // error message
if (!FunctionHolder(dir).toRecord(error, rec)) {
cout << error << endl;
};
Record grec; // a Record
if (!FunctionHolder(dir).toRecord(error, grec)) { // make record
cout << error << endl;
};
// Note that for GlishRecords use can be made of the
// GlishRecord::to/fromrecord() methods.
Motivation
To make general conversions between Functions and records, without knowing
the actual Function being converted.
Member Description
Types of functions
Creates an empty holder
Create from a Function (copy made)
FunctionHolder(const FunctionHolder<T> &other)
Copy a holder (copy semantics)
FunctionHolder &operator=(const FunctionHolder<T> &other)
Assignment (copy semantics)
Check the the FunctionHolder holds the specified type. Return
True if if does and False otherwise.
Get the known names
Get a specific Function from the holder (with lifetime as long
as holder exists).
Thrown Exceptions
- AipsError if holder empty
- AipsError if holder contains wrong Function
Add a function
FunctionHolder<T>::Types type() const
Get the type of currently filled holder
virtual Bool fromRecord(String &error, const RecordInterface &in)
virtual Bool fromString(String &error, const String &in)
template <class U> Bool getRecord(U &error, String<U> *&fn, const RecordInterface &in)
Create a Function from a record. An error message is generated, and False
returned if an invalid record is given. A valid record will return True.
A valid record contains at least the following fields (any additional fields are
ignored):
- tp = TpString: type of Function (gaussian1d, etc; case
insensitive) -- OR an enumeration code
- order = TpInt: the order needed to create a Function (-1 if not
necessary or default)
- ndim, npar, params are optional
- nfunc, funcs are required for COMBI or COMPOUND
A Function can be created from a string. In that case the string
will only indicate the type of function (like polynomial), and will
create a default polynomial of that given type.
Error messages are postfixed to error.
virtual Bool toRecord(String &error, RecordInterface &out) const
Create a record from a Function. The return will be False and an error
message generated only if the FunctionHolder does not contain a Function.
Error messages are postfixed to error.
virtual const String &ident() const
Get identification of record
void init() const
Initialise and check the name list
Bool putType(String &error, RecordInterface &out) const
template <class U> Bool getType(U &error, String<U> *&fn, const RecordInterface &in)
template <class U> Bool getType(U &error, String<U> *&fn)
void FunctionHolder<T>::setParameters(Function<T> *&fn, const Function<T> ¶ms)
void FunctionHolder<T>::setParameters(Function<Function<T> > *&fn, const AutoDiff<T> ¶ms)
Aid for to/from Record, String