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

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1