casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
LineCollapser.h
Go to the documentation of this file.
00001 //# LineCollapser.h: Abstract base class to collapse lines for LatticeApply
00002 //# Copyright (C) 1996,1997,1998
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: LineCollapser.h 20229 2008-01-29 15:19:06Z gervandiepen $
00027 
00028 #ifndef LATTICES_LINECOLLAPSER_H
00029 #define LATTICES_LINECOLLAPSER_H
00030  
00031 
00032 //# Includes
00033 #include <casa/aips.h>
00034 #include <scimath/Mathematics/NumericTraits.h>
00035 
00036 namespace casa { //# NAMESPACE CASA - BEGIN
00037 
00038 //# Forward Declarations
00039 template <class T> class Vector;
00040 class IPosition;
00041 
00042 // <summary>
00043 // Abstract base class for LatticeApply function signatures
00044 // </summary>
00045 
00046 // <use visibility=export>
00047 
00048 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
00049 // </reviewed>
00050 
00051 // <prerequisite>
00052 //   <li> <linkto class=LatticeApply>LatticeApply</linkto>
00053 // </prerequisite>
00054 
00055 // <etymology>
00056 // </etymology>
00057 
00058 // <synopsis>
00059 // This is an abstract base class for the collapsing of lines to
00060 // be used in function <src>lineApply</src> or <src>lineMultiApply</src>
00061 // in class <linkto class=LatticeApply>LatticeApply</linkto>.
00062 // It is meant for cases where the entire line is needed (e.g. moment
00063 // calculation). If that is not needed (e.g. to calculate maximum),
00064 // it is better to use function <src>LatticeApply::tiledApply</src>
00065 // with class <linkto class=TiledCollapser>TiledCollapser</linkto>.
00066 // <p>
00067 // The user has to derive a concrete class from this base class
00068 // and implement the (pure) virtual functions.
00069 // <br> The main function is <src>process</src>, which needs to do the
00070 // calculation.
00071 // <br> Other functions make it possible to perform an initial check.
00072 // <p>
00073 // The class is Doubly templated.  Ths first template type 
00074 // is for the data type you are processing.  The second type is
00075 // for what type you want the results of the processing assigned to.
00076 // For example, if you are computing sums of squares for statistical
00077 // purposes, you might use higher precision (FLoat->Double) for this.
00078 // No check is made that the template types are self-consistent.
00079 // </synopsis>
00080 
00081 // <example>
00082 // <srcblock>
00083 // </srcblock>
00084 // </example>
00085 
00086 // <motivation>
00087 // </motivation>
00088 
00089 // <todo asof="1997/08/01">   
00090 //   <li> 
00091 // </todo>
00092 
00093 template <class T, class U=T> class LineCollapser
00094 {
00095 public:
00096 // Destructor
00097     virtual ~LineCollapser();
00098 
00099 // The init function for a derived class.
00100 // It can be used to check if <src>nOutPixelsPerCollapse</src>
00101 // corresponds with the number of pixels produced per collapsed line.
00102     virtual void init (uInt nOutPixelsPerCollapse) = 0;
00103 
00104 // Can the process function in the derived class handle a null mask?
00105 // If not, LatticeApply ensures that it'll always pass a filled mask vector,
00106 // even if the lattice does not have a mask (in that case that mask
00107 // contains all True values).
00108 // <br>The default implementation returns False.
00109 // <br>The function is there to make optimization possible when no masks
00110 // are involved. On the other side, it allows the casual user to ignore
00111 // optimization.
00112     virtual Bool canHandleNullMask() const;
00113 
00114 // Collapse the given line and return one value from that operation.
00115 // The position in the Lattice at the start of the line is input
00116 // as well.
00117 // <br>When function <src>canHandleNullMask</src> returned True,
00118 // it is possible that <src>mask</src> is an empty vector indicating
00119 // that the input has no mask, thus all values are valid.
00120 // If not empty, the mask has the same length as the line.
00121     virtual void process (U& result, Bool& resultMask,
00122                           const Vector<T>& line,
00123                           const Vector<Bool>& mask,
00124                           const IPosition& pos) = 0;
00125 
00126 // Collapse the given line and return a line of values from that operation.
00127 // The position in the Lattice at the start of the line is input
00128 // as well.
00129 // <br>When function <src>canHandleNullMask</src> returned True,
00130 // it is possible that <src>mask</src> is an empty vector indicating
00131 // that the input has no mask, thus all values are valid.
00132 // If not empty, the mask has the same length as the line.
00133     virtual void multiProcess (Vector<U>& result, Vector<Bool>& resultMask,
00134                                const Vector<T>& line,
00135                                const Vector<Bool>& mask,
00136                                const IPosition& pos) = 0;
00137 };
00138 
00139 
00140 
00141 } //# NAMESPACE CASA - END
00142 
00143 #ifndef CASACORE_NO_AUTO_TEMPLATES
00144 #include <lattices/Lattices/LineCollapser.tcc>
00145 #endif //# CASACORE_NO_AUTO_TEMPLATES
00146 #endif