Loading...
Searching...
No Matches
casacore::LELInterface< T > Class Template Referenceabstract
lattices package (libcasa_lattices) » LEL_module » LEL_module_internal_classes

More...

`#include <LELInterface.h>`

## Public Member Functions

virtual | ~LELInterface ()
| Virtual destructor.
virtual void | eval (LELArray< T > &result, const Slicer &section) const =0
| Evaluate the expression and fill the result array.
virtual void | evalRef (LELArrayRef< T > &result, const Slicer &section) const
virtual LELScalar< T > | getScalar () const =0
| Get the result of a scalar subexpression.
LELArray< T > | getArray () const
| Get the result of an array subexpression.
virtual Bool | prepareScalarExpr ()=0
| Do further preparations (e.g.
Bool | isScalar () const
| Is the result of evaluating this expression a scalar ?
const IPosition & | shape () const
| Get the shape of the expression result.
const LELAttribute & | getAttribute () const
| Get expression attribute.
virtual String | className () const =0
| Get class name.
virtual Bool | lock (FileLocker::LockType, uInt nattempts)
| Handle locking/syncing of the parts of a lattice expression.
virtual void | unlock ()
virtual Bool | hasLock (FileLocker::LockType) const
virtual void | resync ()

## Static Public Member Functions

static Bool | replaceScalarExpr (std::shared_ptr< LELInterface< T > > &expr)
| If the given expression is a valid scalar, replace it by its result.

## Protected Member Functions

void | setAttr (const LELAttribute &attrib)
| Set the expression attributes of this object.

## Private Attributes

LELAttribute | attr_p

## Detailed Description

template<class T>
class casacore::LELInterface< T >

This base class provides the interface for Lattice expressions

### Intended use:

Internal

### Review Status

Date Reviewed:
  yyyy/mm/dd

### Prerequisite

- Lattice
- LatticeExpr
- LatticeExprNode

### Etymology

The name means "Lattice Expression Language Interface". This class provides the declaration for the interface for classes that are to provide Lattice expression computational functionality

### Synopsis

This class is part of the Letter/envelope scheme which enables the C++ programmer to write mathematical expressions involving Lattices. The envelope class LatticeExpr invokes the bridge class LatticeExprNode. LatticeExprNode activates the letter classes which provide the real functionality.

A description of the implementation details of these classes can be found in Note 216

This class, LELInterface, is the abstract base class for all of the letter classes. Its purpose is to declare the interface inherited by all of its derived classes which are used polymorphically. The derived classes offer the functionality to create and evaluate the expression tree that results from the compiler parsing the expression.
For example, these derived classes are activated by LatticeExprNode to handle operations like reading pixels from a Lattice, applying binary operations to Lattices, applying mathematical functions to Lattices and so on.

The heart of the interface is in the functions eval and getScalar. These recursively evaluate the result of the current expression when the result is either an array or a scalar, respectively. The need for recursion can be understood with a simple example.

Consider an expression summing two Lattices such as "2*(b+c)". The expression tree consists of nodes (leaves) that 1) get Lattice pixels from the Lattice (expressions "b" and "c"), 2) add the pixel values of the Lattices together (operator "+"), and 3) multiply a Lattice by a scalar (operator "*"). At the top of the tree, we have a scalar (2.0) and a Lattice (the result of "b+c"). The top-of-the-tree expression has to multiply them together. That's what the eval function for the "*" operation needs to do. The key is that each of the "2.0" and "b+c" are really Lattice expressions themselves and they can be evaluated. So before the "*" eval function can multiply its two expressions together, it must individually evaluate them. Thus, it first calls the getScalar function of the object housing the expression "2.0". This will in fact return the scalar value "2.0". Then it calls eval on the expression object housing "b+c". This object in turn first calls eval on the left ("b") and right ("c") expressions which results in the pixels for the Lattices being returned. It then adds them together, returning the result to the top of the tree where they are multiplied by 2. You can see that since all these different expression objects call the eval or getScalar function that they all inherit from LELInterface. Indeed for our example above, the actual classes involved are are LELLattice (get pixels from Lattice) and LELBinary ("+" and "*" operators) which inherit from LELInterface. When these objects are constructed, they work out whether the result of their evaluation is a scalar or not. This is how the classes higher up the tree know whether to call eval or getScalar.

The results of the computations are either returned in the buffer in the eval function or by value by getScalar

The classes evaluate the expression for each specified Lattice chunk (usually tile by tile). The section argument in the eval function specifies the section of the Lattice being evaluated. The absence of the section argument in the getScalar function emphasises the scalar nature; a scalar expression does not have a shape. For most of the letter classes, the section argument is irrelevant; the only one it really matters for is LELLattice which fetches the pixels from the Lattice. The rest only care about the shape of the buffer in the eval call.

### Motivation

The many letter classes that actually do the computational work are used polymorphically. Therefore, they must have a base class declaring the interface.

Definition at line 148 of file LELInterface.h.

## Constructor & Destructor Documentation

## ~LELInterface()

template<class T>

virtual casacore::LELInterface< T >::~LELInterface | ( |  | ) |

virtual

Virtual destructor.

## Member Function Documentation

## className()

template<class T>

virtual String casacore::LELInterface< T >::className | ( |  | ) | const

pure virtual

Get class name.

Implemented in casacore::LELBinary< T >, casacore::LELBinaryBool, casacore::LELBinaryCmp< T >, casacore::LELCondition< T >, casacore::LELConvert< T, F >, casacore::LELFunction1D< T >, casacore::LELFunctionBool, casacore::LELFunctionComplex, casacore::LELFunctionDComplex, casacore::LELFunctionDouble, casacore::LELFunctionFloat, casacore::LELFunctionND< T >, casacore::LELFunctionReal1D< T >, casacore::LELLattice< T >, casacore::LELRegion, casacore::LELRegionAsBool, casacore::LELSpectralIndex< T >, casacore::LELUnary< T >, casacore::LELUnaryBool, and casacore::LELUnaryConst< T >.

## eval()

template<class T>

virtual void casacore::LELInterface< T >::eval | ( | LELArray< T > & | result,
|  | const Slicer & | section ) const

pure virtual

Evaluate the expression and fill the result array.

Implemented in casacore::LELBinary< T >, casacore::LELBinaryBool, casacore::LELBinaryCmp< T >, casacore::LELCondition< T >, casacore::LELConvert< T, F >, casacore::LELFunction1D< T >, casacore::LELFunctionBool, casacore::LELFunctionComplex, casacore::LELFunctionDComplex, casacore::LELFunctionDouble, casacore::LELFunctionFloat, casacore::LELFunctionND< T >, casacore::LELFunctionReal1D< T >, casacore::LELLattice< T >, casacore::LELRegion, casacore::LELRegionAsBool, casacore::LELSpectralIndex< T >, casacore::LELUnary< T >, casacore::LELUnaryBool, and casacore::LELUnaryConst< T >.

## evalRef()

template<class T>

virtual void casacore::LELInterface< T >::evalRef | ( | LELArrayRef< T > & | result,
|  | const Slicer & | section ) const

virtual

Reimplemented in casacore::LELLattice< T >.

## getArray()

template<class T>

LELArray< T > casacore::LELInterface< T >::getArray | ( |  | ) | const

Get the result of an array subexpression.

It does eval for the entire array. An exception is thrown if the shape of the subexpression is unknown.

## getAttribute()

template<class T>

const LELAttribute & casacore::LELInterface< T >::getAttribute | ( |  | ) | const

inline

Get expression attribute.

Definition at line 183 of file LELInterface.h.

References attr_p.

## getScalar()

template<class T>

virtual LELScalar< T > casacore::LELInterface< T >::getScalar | ( |  | ) | const

pure virtual

Get the result of a scalar subexpression.

Implemented in casacore::LELBinary< T >, casacore::LELBinaryBool, casacore::LELBinaryCmp< T >, casacore::LELCondition< T >, casacore::LELConvert< T, F >, casacore::LELFunction1D< T >, casacore::LELFunctionBool, casacore::LELFunctionComplex, casacore::LELFunctionDComplex, casacore::LELFunctionDouble, casacore::LELFunctionFloat, casacore::LELFunctionND< T >, casacore::LELFunctionReal1D< T >, casacore::LELLattice< T >, casacore::LELRegion, casacore::LELRegionAsBool, casacore::LELSpectralIndex< T >, casacore::LELUnary< T >, casacore::LELUnaryBool, and casacore::LELUnaryConst< T >.

## hasLock()

template<class T>

virtual Bool casacore::LELInterface< T >::hasLock | ( | FileLocker::LockType |  | ) | const

virtual

Reimplemented in casacore::LELBinary< T >, casacore::LELBinaryBool, casacore::LELBinaryCmp< T >, casacore::LELCondition< T >, casacore::LELConvert< T, F >, casacore::LELFunction1D< T >, casacore::LELFunctionBool, casacore::LELFunctionComplex, casacore::LELFunctionDComplex, casacore::LELFunctionDouble, casacore::LELFunctionFloat, casacore::LELFunctionND< T >, casacore::LELFunctionReal1D< T >, casacore::LELLattice< T >, casacore::LELSpectralIndex< T >, casacore::LELUnary< T >, and casacore::LELUnaryBool.

## isScalar()

template<class T>

Bool casacore::LELInterface< T >::isScalar | ( |  | ) | const

inline

Is the result of evaluating this expression a scalar ?

Definition at line 177 of file LELInterface.h.

References attr_p.

## lock()

template<class T>

virtual Bool casacore::LELInterface< T >::lock | ( | FileLocker::LockType | ,
|  | uInt | nattempts )

virtual

Handle locking/syncing of the parts of a lattice expression.

By default the functions do not do anything at all. lock() and hasLock return True.

Reimplemented in casacore::LELBinary< T >, casacore::LELBinaryBool, casacore::LELBinaryCmp< T >, casacore::LELCondition< T >, casacore::LELConvert< T, F >, casacore::LELFunction1D< T >, casacore::LELFunctionBool, casacore::LELFunctionComplex, casacore::LELFunctionDComplex, casacore::LELFunctionDouble, casacore::LELFunctionFloat, casacore::LELFunctionND< T >, casacore::LELFunctionReal1D< T >, casacore::LELLattice< T >, casacore::LELSpectralIndex< T >, casacore::LELUnary< T >, and casacore::LELUnaryBool.

## prepareScalarExpr()

template<class T>

virtual Bool casacore::LELInterface< T >::prepareScalarExpr | ( |  | ) |

pure virtual

Do further preparations (e.g.

optimization) on the expression. It returns True if the expression is an invalid scalar (i.e. with a False mask). That can happen if the expression has a component with an invalid scalar value (e.g. min(lattice) where lattice contains no valid elements).

Implemented in casacore::LELBinary< T >, casacore::LELBinaryBool, casacore::LELBinaryCmp< T >, casacore::LELCondition< T >, casacore::LELConvert< T, F >, casacore::LELFunction1D< T >, casacore::LELFunctionBool, casacore::LELFunctionComplex, casacore::LELFunctionDComplex, casacore::LELFunctionDouble, casacore::LELFunctionFloat, casacore::LELFunctionND< T >, casacore::LELFunctionReal1D< T >, casacore::LELLattice< T >, casacore::LELRegion, casacore::LELRegionAsBool, casacore::LELSpectralIndex< T >, casacore::LELUnary< T >, casacore::LELUnaryBool, and casacore::LELUnaryConst< T >.

## replaceScalarExpr()

template<class T>

Bool casacore::LELInterface< T >::replaceScalarExpr | ( | std::shared_ptr< LELInterface< T > > & | expr | ) |

static

If the given expression is a valid scalar, replace it by its result.

It returns False if the expression is no scalar or if the expression is an invalid scalar (i.e. with a False mask).

## resync()

template<class T>

virtual void casacore::LELInterface< T >::resync | ( |  | ) |

virtual

Reimplemented in casacore::LELBinary< T >, casacore::LELBinaryBool, casacore::LELBinaryCmp< T >, casacore::LELCondition< T >, casacore::LELConvert< T, F >, casacore::LELFunction1D< T >, casacore::LELFunctionBool, casacore::LELFunctionComplex, casacore::LELFunctionDComplex, casacore::LELFunctionDouble, casacore::LELFunctionFloat, casacore::LELFunctionND< T >, casacore::LELFunctionReal1D< T >, casacore::LELLattice< T >, casacore::LELSpectralIndex< T >, casacore::LELUnary< T >, and casacore::LELUnaryBool.

## setAttr()

template<class T>

void casacore::LELInterface< T >::setAttr | ( | const LELAttribute & | attrib | ) |

protected

Set the expression attributes of this object.

## shape()

template<class T>

const IPosition & casacore::LELInterface< T >::shape | ( |  | ) | const

inline

Get the shape of the expression result.

Definition at line 180 of file LELInterface.h.

References attr_p.

## unlock()

template<class T>

virtual void casacore::LELInterface< T >::unlock | ( |  | ) |

virtual

Reimplemented in casacore::LELBinary< T >, casacore::LELBinaryBool, casacore::LELBinaryCmp< T >, casacore::LELCondition< T >, casacore::LELConvert< T, F >, casacore::LELFunction1D< T >, casacore::LELFunctionBool, casacore::LELFunctionComplex, casacore::LELFunctionDComplex, casacore::LELFunctionDouble, casacore::LELFunctionFloat, casacore::LELFunctionND< T >, casacore::LELFunctionReal1D< T >, casacore::LELLattice< T >, casacore::LELSpectralIndex< T >, casacore::LELUnary< T >, and casacore::LELUnaryBool.

## Member Data Documentation

## attr_p

template<class T>

LELAttribute casacore::LELInterface< T >::attr_p

private

Definition at line 208 of file LELInterface.h.

Referenced by getAttribute(), isScalar(), and shape().

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

- lattices/LEL/LELInterface.h