casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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: aips2-request@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 //# $Id$
27 
28 #ifndef LATTICES_LELCONVERT_H
29 #define LATTICES_LELCONVERT_H
30 
31 
32 //# Includes
33 #include <casacore/casa/aips.h>
35 
36 
37 namespace casacore { //# NAMESPACE CASACORE - BEGIN
38 
39 // <summary>
40 // Class to convert a LEL node from one numerical type to another
41 // </summary>
42 
43 // <use visibility=local>
44 
45 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
46 // </reviewed>
47 
48 // <prerequisite>
49 // <li> <linkto class="Lattice"> Lattice</linkto>
50 // <li> <linkto class="LatticeExpr"> LatticeExpr</linkto>
51 // <li> <linkto class="LatticeExprNode"> LatticeExprNode</linkto>
52 // <li> <linkto class="LELInterface"> LELInterface</linkto>
53 // </prerequisite>
54 
55 // <etymology>
56 // This derived LEL letter class handles numerical type conversions
57 // </etymology>
58 
59 // <synopsis>
60 // This LEL letter class is derived from LELInterface. It
61 // is used to construct LEL objects that know how to convert
62 // between numerical types, such as Double to Float. They
63 // operate on numerical Lattices and return a numerical Lattice.
64 // The LELConvert object is embedded in the tree, and the conversion
65 // actually happens at tree evaluation time.
66 // <p>
67 // A description of the implementation details of the LEL classes can
68 // be found in
69 // <a href="../notes/216.html">Note 216</a>
70 // </synopsis>
71 
72 // <example>
73 // Examples are not very useful as the user would never use
74 // these classes directly. Look in LatticeExprNode.cc to see
75 // how it invokes these classes. An example of how the user
76 // would indirectly use this class (through the envelope) is:
77 // <srcblock>
78 // IPosition shape(2,5,10);
79 // ArrayLattice<Float> x(shape); x.set(1.0);
80 // ArrayLattice<Double> y(shape);
81 // y.copyData(x); // y = x;
82 // </srcblock>
83 // The LELConvert class is embedded in the tree at construction time
84 // so as to handle the conversion from Float to Double at evaluation time
85 // </example>
86 
87 // <motivation>
88 // We needed to be able to handle mixed types in the LEL classes
89 // </motivation>
90 
91 //# <todo asof="1998/01/21">
92 //# </todo>
93 
94 
95 template <class T, class F> class LELConvert : public LELInterface<T>
96 {
97 public:
98 
99 // Constructor. <src><F></src> is the type we are coinverting from.
100 // <src><T></src> is the type we are converting to.
101  LELConvert (const CountedPtr<LELInterface<F> >& expr);
102 
103 // Destructor does nothing
104  ~LELConvert();
105 
106 // Recursively evaluate the expression.
107  virtual void eval (LELArray<T>& result,
108  const Slicer& section) const;
109 
110 // Recursively evaluate the scalar
111  virtual LELScalar<T> getScalar() const;
112 
113 // Do further preparations (e.g. optimization) on the expression.
114  virtual Bool prepareScalarExpr();
115 
116 // Get class name
117  virtual String className() const;
118 
119  // Handle locking/syncing of a lattice in a lattice expression.
120  // <group>
121  virtual Bool lock (FileLocker::LockType, uInt nattempts);
122  virtual void unlock();
123  virtual Bool hasLock (FileLocker::LockType) const;
124  virtual void resync();
125  // </group>
126 
127 private:
129 };
130 
131 
132 
133 } //# NAMESPACE CASACORE - END
134 
135 #ifndef CASACORE_NO_AUTO_TEMPLATES
136 #include <casacore/lattices/LEL/LELConvert.tcc>
137 #endif //# CASACORE_NO_AUTO_TEMPLATES
138 #endif
Class to convert a LEL node from one numerical type to another.
Definition: LELConvert.h:95
virtual LELScalar< T > getScalar() const
Recursively evaluate the scalar.
This LEL class holds an array with a mask.
Definition: LELInterface.h:44
~LELConvert()
Destructor does nothing.
virtual Bool prepareScalarExpr()
Do further preparations (e.g.
virtual void eval(LELArray< T > &result, const Slicer &section) const
Recursively evaluate the expression.
virtual String className() const
Get class name.
This base class provides the interface for Lattice expressions.
Definition: LELInterface.h:150
virtual void unlock()
Referenced counted pointer for constant data.
Definition: VisModelData.h:42
virtual Bool lock(FileLocker::LockType, uInt nattempts)
Handle locking/syncing of a lattice in a lattice expression.
virtual Bool hasLock(FileLocker::LockType) const
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
LELConvert(const CountedPtr< LELInterface< F > > &expr)
Constructor.
Specify which elements to extract from an n-dimensional array.
Definition: Slicer.h:289
virtual void resync()
String: the storage and methods of handling collections of characters.
Definition: String.h:223
LockType
Define the possible lock types.
Definition: FileLocker.h:95
unsigned int uInt
Definition: aipstype.h:51
CountedPtr< LELInterface< F > > pExpr_p
Definition: LELConvert.h:128
This LEL class holds a scalar with a mask.
Definition: LELInterface.h:43
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42