casacore
Loading...
Searching...
No Matches
LELCondition.h
Go to the documentation of this file.
1//# LELCondition.h: Class to make a mask from a condition
2//# Copyright (C) 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_LELCONDITION_H
27#define LATTICES_LELCONDITION_H
28
29
30//# Includes
31#include <casacore/casa/aips.h>
32#include <casacore/lattices/LEL/LELInterface.h>
33
34
35namespace casacore { //# NAMESPACE CASACORE - BEGIN
36
37// <summary>
38// Class to make a mask from a condition.
39// </summary>
40
41// <use visibility=local>
42
43// <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
44// </reviewed>
45
46// <prerequisite>
47// <li> <linkto class="Lattice"> Lattice</linkto>
48// <li> <linkto class="LatticeExpr"> LatticeExpr</linkto>
49// <li> <linkto class="LatticeExprNode"> LatticeExprNode</linkto>
50// <li> <linkto class="LELInterface"> LELInterface</linkto>
51// </prerequisite>
52
53// <etymology>
54// This derived LEL letter class handles a condition as a mask.
55// </etymology>
56
57// <synopsis>
58// This LEL letter class is derived from LELInterface. It
59// is used to construct LEL objects that know how to deal with
60// a condition (given using operator[]).
61// The operands cannot be a scalar.
62// The LELCondition object is embedded in the tree, and the conversion
63// actually happens at tree evaluation time.
64// <p>
65// A description of the implementation details of the LEL classes can
66// be found in
67// <a href="../notes/216.html">Note 216</a>
68// </synopsis>
69
70// <example>
71// Examples are not very useful as the user would never use
72// these classes directly. Look in LatticeExprNode.cc to see
73// how it invokes these classes. An example of how the user
74// would indirectly use this class (through the envelope) is:
75// <srcblock>
76// IPosition shape(2,5,10);
77// ArrayLattice<Float> x(shape); x.set(1.0);
78// ArrayLattice<Double> y(shape);
79// y.copyData(x[x>5]); // y = x;
80// </srcblock>
81// The LELCondition class is embedded in the tree at construction time
82// so as to turn the condition in a mask on x.
83// </example>
84
85//# <todo asof="1998/01/21">
86//# </todo>
87
88
89template <class T> class LELCondition : public LELInterface<T>
90{
91 //# Make members of parent class known.
92protected:
93 using LELInterface<T>::setAttr;
94
95public:
96// Construct the condition on the given expression.
97 LELCondition (const std::shared_ptr<LELInterface<T>>& expr,
98 const std::shared_ptr<LELInterface<Bool>>& cond);
99
100// Destructor does nothing
102
103// Recursively evaluate the expression.
104 virtual void eval (LELArray<T>& result,
105 const Slicer& section) const;
106
107// Recursively evaluate the scalar
108 virtual LELScalar<T> getScalar() const;
109
110// Do further preparations (e.g. optimization) on the expression.
112
113// Get class name
114 virtual String className() const;
115
116 // Handle locking/syncing of a lattice in a lattice expression.
117 // <group>
118 virtual Bool lock (FileLocker::LockType, uInt nattempts);
119 virtual void unlock();
121 virtual void resync();
122 // </group>
123
124private:
125 std::shared_ptr<LELInterface<T>> pExpr_p;
126 std::shared_ptr<LELInterface<Bool>> pCond_p;
127};
128
129
130
131} //# NAMESPACE CASACORE - END
132
133#ifndef CASACORE_NO_AUTO_TEMPLATES
134#include <casacore/lattices/LEL/LELCondition.tcc>
135#endif //# CASACORE_NO_AUTO_TEMPLATES
136#endif
LockType
Define the possible lock types.
Definition FileLocker.h:93
std::shared_ptr< LELInterface< Bool > > pCond_p
LELCondition(const std::shared_ptr< LELInterface< T > > &expr, const std::shared_ptr< LELInterface< Bool > > &cond)
Construct the condition on the given expression.
~LELCondition()
Destructor does nothing.
virtual Bool prepareScalarExpr()
Do further preparations (e.g.
virtual Bool lock(FileLocker::LockType, uInt nattempts)
Handle locking/syncing of a lattice in a lattice expression.
virtual void resync()
virtual LELScalar< T > getScalar() const
Recursively evaluate the scalar.
virtual void eval(LELArray< T > &result, const Slicer &section) const
Recursively evaluate the expression.
virtual String className() const
Get class name.
std::shared_ptr< LELInterface< T > > pExpr_p
virtual void unlock()
virtual Bool hasLock(FileLocker::LockType) const
void setAttr(const LELAttribute &attrib)
Set the expression attributes of this object.
String: the storage and methods of handling collections of characters.
Definition String.h:223
this file contains all the compiler specific defines
Definition mainpage.dox:28
unsigned int uInt
Definition aipstype.h:49
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40