casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
LELArray.h
Go to the documentation of this file.
00001 //# LELArray.h: Hold an array with a mask in LEL
00002 //# Copyright (C) 1999
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: LELArray.h 20229 2008-01-29 15:19:06Z gervandiepen $
00027 
00028 #ifndef LATTICES_LELARRAY_H
00029 #define LATTICES_LELARRAY_H
00030 
00031 
00032 //# Includes
00033 #include <lattices/Lattices/LELArrayBase.h>
00034 
00035 
00036 namespace casa { //# NAMESPACE CASA - BEGIN
00037 
00038 // <summary>
00039 // This LEL class holds an array with a mask.
00040 // </summary>
00041 
00042 // <use visibility=local>
00043 
00044 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
00045 // </reviewed>
00046 
00047 // <synopsis>
00048 // This LEL class holds an array with a mask.
00049 // The mask can be a single Bool valid for all elements of the array.
00050 // Otherwise it is a full mask with the same shape as the array.
00051 // </synopsis>
00052 
00053 // <motivation>
00054 // It makes it possible to handle an array with its mask as a single object.
00055 // </motivation>
00056 
00057 // <todo asof="1998/01/20">
00058 // </todo>
00059  
00060 
00061 template <class T> class LELArray : public LELArrayBase
00062 {
00063 public: 
00064 // Constructor takes value.
00065 // Its mask is set to all True.
00066    LELArray (const Array<T>& value)
00067       : itsValue (value) {}
00068 
00069 // Constructor takes value and mask.
00070    LELArray (const Array<T>& value, const Array<Bool>& mask)
00071       : LELArrayBase (mask), itsValue (value) {}
00072 
00073 // Constructor takes shape.
00074 // Its mask is set to all True.
00075    LELArray (const IPosition& shape);
00076 
00077 // Copy constructor (reference semantics).
00078    LELArray (const LELArray<T>& other);
00079 
00080    ~LELArray();
00081 
00082    // Assignment (reference semantics).
00083    LELArray<T>& operator= (const LELArray<T>& other);
00084 
00085 // Get shape (of the value).
00086    const IPosition& shape() const
00087       { return itsValue.shape(); }
00088 
00089 // Get value.
00090 // <group>
00091    const Array<T>& value() const
00092       { return itsValue; }
00093    Array<T>& value()
00094       { return itsValue; }
00095 // </group>
00096 
00097 private:
00098    Array<T> itsValue;
00099 };
00100 
00101 
00102 
00103 
00104 // <summary>
00105 // This LEL class holds a possible referenced array with a mask.
00106 // </summary>
00107 
00108 // <use visibility=local>
00109 
00110 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
00111 // </reviewed>
00112 
00113 // <synopsis>
00114 // This LEL class is derived from LELArray.
00115 // Its purpose is to provide only const access to the array value, so
00116 // the array can be a reference to another array.
00117 // It is meant for optimization, so references can safely be used
00118 // when evaluating a subexpression.
00119 // </synopsis>
00120 
00121 // <motivation>
00122 // It makes it possible to use the function evalRef in a safe way.
00123 // It would be unsafe to use a LELArray object, because that
00124 // gives non-const access to the value.
00125 // </motivation>
00126 
00127 // <todo asof="1998/01/20">
00128 // </todo>
00129  
00130 
00131 template <class T> class LELArrayRef : public LELArray<T>
00132 {
00133 public: 
00134 // Constructor takes shape.
00135 // Its mask is set to all True.
00136    LELArrayRef (const IPosition& shape)
00137     : LELArray<T> (shape) {}
00138 
00139    ~LELArrayRef()
00140     {}
00141 
00142 // Get value.
00143    const Array<T>& value() const
00144       { return LELArray<T>::value(); }
00145 
00146 private:
00147 // Copy constructor is not needed.
00148    LELArrayRef (const LELArrayRef<T>& other);
00149 // Assignment is not needed.
00150    LELArrayRef<T>& operator= (const LELArrayRef<T>& other);
00151 };
00152 
00153 
00154 
00155 } //# NAMESPACE CASA - END
00156 
00157 #ifndef CASACORE_NO_AUTO_TEMPLATES
00158 #include <lattices/Lattices/LELArray.tcc>
00159 #endif //# CASACORE_NO_AUTO_TEMPLATES
00160 #endif