casa
$Rev:20696$
|
00001 //# LELCondition.h: Class to make a mask from a condition 00002 //# Copyright (C) 1999,2000 00003 //# Associated Universities, Inc. Washington DC, USA. 00004 //# 00005 //# This library is free software; you can redistribute it and/or modify it 00006 //# under the terms of the GNU Library General Public License as published by 00007 //# the Free Software Foundation; either version 2 of the License, or (at your 00008 //# option) any later version. 00009 //# 00010 //# This library is distributed in the hope that it will be useful, but WITHOUT 00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00012 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 00013 //# License for more details. 00014 //# 00015 //# You should have received a copy of the GNU Library General Public License 00016 //# along with this library; if not, write to the Free Software Foundation, 00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. 00018 //# 00019 //# Correspondence concerning AIPS++ should be addressed as follows: 00020 //# Internet email: aips2-request@nrao.edu. 00021 //# Postal address: AIPS++ Project Office 00022 //# National Radio Astronomy Observatory 00023 //# 520 Edgemont Road 00024 //# Charlottesville, VA 22903-2475 USA 00025 //# 00026 //# $Id: LELCondition.h 20508 2009-01-20 11:09:47Z gervandiepen $ 00027 00028 #ifndef LATTICES_LELCONDITION_H 00029 #define LATTICES_LELCONDITION_H 00030 00031 00032 //# Includes 00033 #include <lattices/Lattices/LELInterface.h> 00034 00035 00036 namespace casa { //# NAMESPACE CASA - BEGIN 00037 00038 // <summary> 00039 // Class to make a mask from a condition. 00040 // </summary> 00041 00042 // <use visibility=local> 00043 00044 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos=""> 00045 // </reviewed> 00046 00047 // <prerequisite> 00048 // <li> <linkto class="Lattice"> Lattice</linkto> 00049 // <li> <linkto class="LatticeExpr"> LatticeExpr</linkto> 00050 // <li> <linkto class="LatticeExprNode"> LatticeExprNode</linkto> 00051 // <li> <linkto class="LELInterface"> LELInterface</linkto> 00052 // </prerequisite> 00053 00054 // <etymology> 00055 // This derived LEL letter class handles a condition as a mask. 00056 // </etymology> 00057 00058 // <synopsis> 00059 // This LEL letter class is derived from LELInterface. It 00060 // is used to construct LEL objects that know how to deal with 00061 // a condition (given using operator[]). 00062 // The operands cannot be a scalar. 00063 // The LELCondition object is embedded in the tree, and the conversion 00064 // actually happens at tree evaluation time. 00065 // <p> 00066 // A description of the implementation details of the LEL classes can 00067 // be found in 00068 // <a href="../notes/216.html">Note 216</a> 00069 // </synopsis> 00070 00071 // <example> 00072 // Examples are not very useful as the user would never use 00073 // these classes directly. Look in LatticeExprNode.cc to see 00074 // how it invokes these classes. An example of how the user 00075 // would indirectly use this class (through the envelope) is: 00076 // <srcblock> 00077 // IPosition shape(2,5,10); 00078 // ArrayLattice<Float> x(shape); x.set(1.0); 00079 // ArrayLattice<Double> y(shape); 00080 // y.copyData(x[x>5]); // y = x; 00081 // </srcblock> 00082 // The LELCondition class is embedded in the tree at construction time 00083 // so as to turn the condition in a mask on x. 00084 // </example> 00085 00086 //# <todo asof="1998/01/21"> 00087 //# </todo> 00088 00089 00090 template <class T> class LELCondition : public LELInterface<T> 00091 { 00092 //# Make members of parent class known. 00093 protected: 00094 using LELInterface<T>::setAttr; 00095 00096 public: 00097 // Construct the condition on the given expression. 00098 LELCondition (const CountedPtr<LELInterface<T> >& expr, 00099 const CountedPtr<LELInterface<Bool> >& cond); 00100 00101 // Destructor does nothing 00102 ~LELCondition(); 00103 00104 // Recursively evaluate the expression. 00105 virtual void eval (LELArray<T>& result, 00106 const Slicer& section) const; 00107 00108 // Recursively evaluate the scalar 00109 virtual LELScalar<T> getScalar() const; 00110 00111 // Do further preparations (e.g. optimization) on the expression. 00112 virtual Bool prepareScalarExpr(); 00113 00114 // Get class name 00115 virtual String className() const; 00116 00117 // Handle locking/syncing of a lattice in a lattice expression. 00118 // <group> 00119 virtual Bool lock (FileLocker::LockType, uInt nattempts); 00120 virtual void unlock(); 00121 virtual Bool hasLock (FileLocker::LockType) const; 00122 virtual void resync(); 00123 // </group> 00124 00125 private: 00126 CountedPtr<LELInterface<T> > pExpr_p; 00127 CountedPtr<LELInterface<Bool> > pCond_p; 00128 }; 00129 00130 00131 00132 } //# NAMESPACE CASA - END 00133 00134 #ifndef CASACORE_NO_AUTO_TEMPLATES 00135 #include <lattices/Lattices/LELCondition.tcc> 00136 #endif //# CASACORE_NO_AUTO_TEMPLATES 00137 #endif