casacore
Loading...
Searching...
No Matches
LELConvert.h
Go to the documentation of this file.
1// # LELConvert.h: Class to convert a LEL node from one numerical type to another
2// # Copyright (C) 1997,1998,1999,2000
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 LATTICES_LELCONVERT_H
27#define LATTICES_LELCONVERT_H
28
29// # Includes
30#include <casacore/casa/aips.h>
31#include <casacore/lattices/LEL/LELInterface.h>
32
33namespace casacore { // # NAMESPACE CASACORE - BEGIN
34
35// <summary>
36// Class to convert a LEL node from one numerical type to another
37// </summary>
38
39// <use visibility=local>
40
41// <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
42// </reviewed>
43
44// <prerequisite>
45// <li> <linkto class="Lattice"> Lattice</linkto>
46// <li> <linkto class="LatticeExpr"> LatticeExpr</linkto>
47// <li> <linkto class="LatticeExprNode"> LatticeExprNode</linkto>
48// <li> <linkto class="LELInterface"> LELInterface</linkto>
49// </prerequisite>
50
51// <etymology>
52// This derived LEL letter class handles numerical type conversions
53// </etymology>
54
55// <synopsis>
56// This LEL letter class is derived from LELInterface. It
57// is used to construct LEL objects that know how to convert
58// between numerical types, such as Double to Float. They
59// operate on numerical Lattices and return a numerical Lattice.
60// The LELConvert object is embedded in the tree, and the conversion
61// actually happens at tree evaluation time.
62// <p>
63// A description of the implementation details of the LEL classes can
64// be found in
65// <a href="../notes/216.html">Note 216</a>
66// </synopsis>
67
68// <example>
69// Examples are not very useful as the user would never use
70// these classes directly. Look in LatticeExprNode.cc to see
71// how it invokes these classes. An example of how the user
72// would indirectly use this class (through the envelope) is:
73// <srcblock>
74// IPosition shape(2,5,10);
75// ArrayLattice<Float> x(shape); x.set(1.0);
76// ArrayLattice<Double> y(shape);
77// y.copyData(x); // y = x;
78// </srcblock>
79// The LELConvert class is embedded in the tree at construction time
80// so as to handle the conversion from Float to Double at evaluation time
81// </example>
82
83// <motivation>
84// We needed to be able to handle mixed types in the LEL classes
85// </motivation>
86
87// # <todo asof="1998/01/21">
88// # </todo>
89
90template <class T, class F>
91class LELConvert : public LELInterface<T> {
92 public:
93 // Constructor. <src><F></src> is the type we are coinverting from.
94 // <src><T></src> is the type we are converting to.
95 LELConvert(const std::shared_ptr<LELInterface<F>>& expr);
96
97 // Destructor does nothing
99
100 // Recursively evaluate the expression.
101 virtual void eval(LELArray<T>& result, const Slicer& section) const;
102
103 // Recursively evaluate the scalar
104 virtual LELScalar<T> getScalar() const;
105
106 // Do further preparations (e.g. optimization) on the expression.
108
109 // Get class name
110 virtual String className() const;
111
112 // Handle locking/syncing of a lattice in a lattice expression.
113 // <group>
114 virtual Bool lock(FileLocker::LockType, uInt nattempts);
115 virtual void unlock();
117 virtual void resync();
118 // </group>
119
120 private:
121 std::shared_ptr<LELInterface<F>> pExpr_p;
122};
123
124} // namespace casacore
125
126#ifndef CASACORE_NO_AUTO_TEMPLATES
127#include <casacore/lattices/LEL/LELConvert.tcc>
128#endif // # CASACORE_NO_AUTO_TEMPLATES
129#endif
LockType
Define the possible lock types.
Definition FileLocker.h:89
virtual String className() const
Get class name.
virtual void eval(LELArray< T > &result, const Slicer &section) const
Recursively evaluate the expression.
virtual void unlock()
virtual void resync()
virtual Bool lock(FileLocker::LockType, uInt nattempts)
Handle locking/syncing of a lattice in a lattice expression.
virtual Bool prepareScalarExpr()
Do further preparations (e.g.
virtual LELScalar< T > getScalar() const
Recursively evaluate the scalar.
std::shared_ptr< LELInterface< F > > pExpr_p
Definition LELConvert.h:121
~LELConvert()
Destructor does nothing.
virtual Bool hasLock(FileLocker::LockType) const
LELConvert(const std::shared_ptr< LELInterface< F > > &expr)
Constructor.
String: the storage and methods of handling collections of characters.
Definition String.h:355
For temporary backward namespace compatibility, use casa as alias for casacore.
Definition mainpage.dox:28
unsigned int uInt
Definition aipstype.h:49
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40