Loading...
Searching...
No Matches
casacore::FunctionHolder< T > Class Template Reference
scimath package (libcasa_scimath) » Functionals_module

More...

`#include <FunctionHolder.h>`

## Classes

struct | FuncStat
| Structure to hold functional status. More...

## Public Types

enum | Types { GAUSSIAN1D , GAUSSIAN2D , GAUSSIAN3D , GAUSSIANND , HYPERPLANE , POLYNOMIAL , EVENPOLYNOMIAL , ODDPOLYNOMIAL , SINUSOID1D , CHEBYSHEV , BUTTERWORTH , COMBINE , COMPOUND , COMPILED , N_Types }
| Types of functions. More...

## Public Member Functions

| FunctionHolder ()
| Creates an empty holder.
| FunctionHolder (const Function< T > &in)
| Create from a Function (copy made).
| FunctionHolder (const FunctionHolder< T > &other)
| Copy a holder (copy semantics).
| ~FunctionHolder ()
FunctionHolder & | operator= (const FunctionHolder< T > &other)
| Assignment (copy semantics).
Bool | isEmpty () const
| Check the the FunctionHolder holds the specified type.
const Vector< String > & | names () const
| Get the known names.
const Function< T > & | asFunction () const
| Get a specific Function from the holder (with lifetime as long as holder exists).
Bool | addFunction (const Function< T > &fnc)
| Add a function.
Types | type () const
| Get the type of currently filled holder.
virtual Bool | fromRecord (String &error, const RecordInterface &in)
| Create a Function from a record.
virtual Bool | fromString (String &error, const String &in)
| Initialise the class from a String representation.
template<class U>
Bool | getRecord (String &error, Function< U > *&fn, const RecordInterface &in)
virtual Bool | toRecord (String &error, RecordInterface &out) const
| Create a record from a Function.
virtual const String & | ident () const
| Get identification of record.
Public Member Functions inherited from casacore::RecordTransformable
virtual | ~RecordTransformable ()
| The destructor must be virtual so that the destructor of derived classes is actually used.

## Private Member Functions

void | init () const
| Initialise and check the name list.
Bool | putType (String &error, RecordInterface &out) const
| Aid for to/from Record, String.
template<class U>
Bool | getType (String &error, Function< U > *&fn, const RecordInterface &in)
template<class U>
Bool | getType (String &error, Function< U > *&fn)
void | setParameters (Function< T > *&fn, const Vector< T > &params)
void | setParameters (Function< AutoDiff< T > > *&fn, const Vector< T > &params)

## Private Attributes

std::unique_ptr< Function< T > > | hold_p
| Pointer to a Function.
Types | nf_p
| Aids (only filled after a succesful to/fromRecord.
Int | order_p
String | text_p
std::unique_ptr< RecordInterface > | mode_p
Vector< String > | nam_p
| List of known names.
Bool | isFilled
| Filled list?

## Detailed Description

template<class T>
class casacore::FunctionHolder< T >

A holder for Functions to enable record conversions

### Intended use:

Public interface

### Review Status

Date Reviewed:
  yyyy/mm/dd
Test programs:
  tFunctionHolder

### Prerequisite

- RecordInterface class
- Function class

### 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.
casacore::FunctionHolder::FunctionHolder
FunctionHolder()
Creates an empty holder.
casacore::FunctionHolder::toRecord
virtual Bool toRecord(String &error, RecordInterface &out) const
Create a record from a Function.
casacore::MDirection
Definition MDirection.h:171
casacore::MDirection::J2000
@ J2000
Definition MDirection.h:186
casacore::MVDirection
Definition MVDirection.h:105
casacore::String
String: the storage and methods of handling collections of characters.
Definition String.h:223
casacore::TableRecord
Definition TableRecord.h:183
casacore::Record
Record()
casacore::Quantity
Quantum< Double > Quantity
Definition Quantum.h:39

### Motivation

To make general conversions between Functions and records, without knowing the actual Function being converted.

Definition at line 89 of file FunctionHolder.h.

## Member Enumeration Documentation

## Types

template<class T>

enum casacore::FunctionHolder::Types

Types of functions.

Enumerator
GAUSSIAN1D |
GAUSSIAN2D |
GAUSSIAN3D |
GAUSSIANND |
HYPERPLANE |
POLYNOMIAL |
EVENPOLYNOMIAL |
ODDPOLYNOMIAL |
SINUSOID1D |
CHEBYSHEV |
BUTTERWORTH |
COMBINE |
COMPOUND |
COMPILED |
N_Types |

Definition at line 93 of file FunctionHolder.h.

## Constructor & Destructor Documentation

## FunctionHolder() [1/3]

template<class T>

casacore::FunctionHolder< T >::FunctionHolder | ( |  | ) |

Creates an empty holder.

Referenced by FunctionHolder(), and operator=().

## FunctionHolder() [2/3]

template<class T>

casacore::FunctionHolder< T >::FunctionHolder | ( | const Function< T > & | in | ) |

Create from a Function (copy made).

## FunctionHolder() [3/3]

template<class T>

casacore::FunctionHolder< T >::FunctionHolder | ( | const FunctionHolder< T > & | other | ) |

Copy a holder (copy semantics).

References FunctionHolder().

## ~FunctionHolder()

template<class T>

casacore::FunctionHolder< T >::~FunctionHolder | ( |  | ) |

## Member Function Documentation

## addFunction()

template<class T>

Bool casacore::FunctionHolder< T >::addFunction | ( | const Function< T > & | fnc | ) |

Add a function.

## asFunction()

template<class T>

const Function< T > & casacore::FunctionHolder< T >::asFunction | ( |  | ) | const

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

## fromRecord()

template<class T>

virtual Bool casacore::FunctionHolder< T >::fromRecord | ( | String & | error,
|  | const RecordInterface & | in )

virtual

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.

Implements casacore::RecordTransformable.

References casacore::RecordInterface().

## fromString()

template<class T>

virtual Bool casacore::FunctionHolder< T >::fromString | ( | String & | error,
|  | const String & | inString )

virtual

Initialise the class from a String representation.

A string cannot contain enough information for many objects. Hence the default implementation of this class returns False, indicating that the class could not be initialised and an error message is appended to the supplied string. If the class can be initialised from a string then this function should be overridden.

Reimplemented from casacore::RecordTransformable.

## getRecord()

template<class T>
template<class U>

Bool casacore::FunctionHolder< T >::getRecord | ( | String & | error,
|  | Function< U > *& | fn,
|  | const RecordInterface & | in )

References casacore::RecordInterface().

## getType() [1/2]

template<class T>
template<class U>

Bool casacore::FunctionHolder< T >::getType | ( | String & | error,
|  | Function< U > *& | fn )

private

## getType() [2/2]

template<class T>
template<class U>

Bool casacore::FunctionHolder< T >::getType | ( | String & | error,
|  | Function< U > *& | fn,
|  | const RecordInterface & | in )

private

References casacore::RecordInterface().

## ident()

template<class T>

virtual const String & casacore::FunctionHolder< T >::ident | ( |  | ) | const

virtual

Get identification of record.

Reimplemented from casacore::RecordTransformable.

## init()

template<class T>

void casacore::FunctionHolder< T >::init | ( |  | ) | const

private

Initialise and check the name list.

## isEmpty()

template<class T>

Bool casacore::FunctionHolder< T >::isEmpty | ( |  | ) | const

Check the the FunctionHolder holds the specified type.

Return True if if does and False otherwise.

## names()

template<class T>

const Vector< String > & casacore::FunctionHolder< T >::names | ( |  | ) | const

Get the known names.

## operator=()

template<class T>

FunctionHolder & casacore::FunctionHolder< T >::operator= | ( | const FunctionHolder< T > & | other | ) |

Assignment (copy semantics).

References FunctionHolder().

## putType()

template<class T>

Bool casacore::FunctionHolder< T >::putType | ( | String & | error,
|  | RecordInterface & | out ) const

private

Aid for to/from Record, String.

References casacore::RecordInterface().

## setParameters() [1/2]

template<class T>

void casacore::FunctionHolder< T >::setParameters | ( | Function< AutoDiff< T > > *& | fn,
|  | const Vector< T > & | params )

private

## setParameters() [2/2]

template<class T>

void casacore::FunctionHolder< T >::setParameters | ( | Function< T > *& | fn,
|  | const Vector< T > & | params )

private

## toRecord()

template<class T>

virtual Bool casacore::FunctionHolder< T >::toRecord | ( | String & | error,
|  | RecordInterface & | out ) const

virtual

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.

Implements casacore::RecordTransformable.

References casacore::RecordInterface().

## type()

template<class T>

Types casacore::FunctionHolder< T >::type | ( |  | ) | const

Get the type of currently filled holder.

## Member Data Documentation

## hold_p

template<class T>

std::unique_ptr<Function<T> > casacore::FunctionHolder< T >::hold_p

private

Pointer to a Function.

Definition at line 189 of file FunctionHolder.h.

## isFilled

template<class T>

Bool casacore::FunctionHolder< T >::isFilled

mutable private

Filled list?

Definition at line 200 of file FunctionHolder.h.

## mode_p

template<class T>

std::unique_ptr<RecordInterface> casacore::FunctionHolder< T >::mode_p

mutable private

Definition at line 195 of file FunctionHolder.h.

## nam_p

template<class T>

Vector<String> casacore::FunctionHolder< T >::nam_p

mutable private

List of known names.

Definition at line 198 of file FunctionHolder.h.

## nf_p

template<class T>

Types casacore::FunctionHolder< T >::nf_p

mutable private

Aids (only filled after a succesful to/fromRecord.

Definition at line 192 of file FunctionHolder.h.

## order_p

template<class T>

Int casacore::FunctionHolder< T >::order_p

mutable private

Definition at line 193 of file FunctionHolder.h.

## text_p

template<class T>

String casacore::FunctionHolder< T >::text_p

mutable private

Definition at line 194 of file FunctionHolder.h.

The documentation for this class was generated from the following file:

- scimath/Functionals/FunctionHolder.h