casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
LELArrayBase.h
Go to the documentation of this file.
00001 //# LELArrayBase.h: Base class for LELArray holding the mask
00002 //# Copyright (C) 1999,2001
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: LELArrayBase.h 20505 2009-01-19 14:37:24Z gervandiepen $
00027 
00028 #ifndef LATTICES_LELARRAYBASE_H
00029 #define LATTICES_LELARRAYBASE_H
00030 
00031 
00032 //# Includes
00033 #include <casa/Arrays/Array.h>
00034 
00035 
00036 namespace casa { //# NAMESPACE CASA - BEGIN
00037 
00038 // <summary>
00039 // Base class for LELArray holding the 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 maskes 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 class LELArrayBase
00062 {
00063 public: 
00064 // Default constructor sets to mask all true.
00065    LELArrayBase()
00066        : itsMaskPtr(0) {}
00067 
00068 // Constructor takes mask.
00069    LELArrayBase (const Array<Bool>& mask)
00070        : itsMaskPtr(new Array<Bool>(mask)) {}
00071 
00072 // Copy constructor (reference semantics).
00073    LELArrayBase (const LELArrayBase& other);
00074 
00075    ~LELArrayBase();
00076 
00077 // Assignment (reference semantics).
00078    LELArrayBase& operator= (const LELArrayBase& other);
00079 
00080 // Does the value have a mask?
00081    Bool isMasked() const
00082       { return  (itsMaskPtr != 0); }
00083 
00084 // Get mask.
00085 // <group>
00086    const Array<Bool>& mask() const
00087       { return *itsMaskPtr; }
00088    Array<Bool>& mask()
00089       { return *itsMaskPtr; }
00090 // </group>
00091 
00092 // Remove the mask.
00093    void removeMask();
00094 
00095 // Set the mask from given array (takes reference).
00096    void setMask (const Array<Bool>& other);
00097 
00098 // Set the mask from the mask of the other value.
00099    void setMask (const LELArrayBase& other);
00100 
00101 // Set the mask from given array (takes reference).
00102    void setMask (Array<Bool>& other);
00103 
00104 // Set the mask by combining the masks of both values.
00105    void setMask (const LELArrayBase& left, const LELArrayBase& right)
00106       { setMask (left); combineMask (right); }
00107 
00108 // Combine the mask of this and the other value (by anding them).
00109 // <group>
00110    void combineMask (const LELArrayBase& other)
00111     { if (other.isMasked()) combineMask (other.mask()); }
00112    void combineMask (const Array<Bool>& mask);
00113 // </group>
00114 
00115 // Combine the mask with the given value in case of an OR or AND.
00116 // It means the mask is set to true if value is desiredValue
00117 // (which should be True for OR and False for AND).
00118 // <group>
00119 // Combine with a single scalar value for which the mask is false.
00120    void combineOrAnd (Bool desiredValue, const Array<Bool>& value);
00121 
00122 // Combine for two arrays taking the true/false array values into account.
00123 // The mask and value are set to desiredValue if the temp value is desiredValue.
00124    void combineOrAnd (Bool desiredValue, Array<Bool>& value,
00125                       const Array<Bool>& temp);
00126 
00127 // Combine for two arrays taking the true/false array values and mask
00128 // into account.
00129 // The mask and value are set to desiredValue if the temp value is desiredValue
00130 // and its temp mask it true.
00131 // The mask is set to false if the temp mask is False.
00132    void combineOrAnd (Bool desiredValue, Array<Bool>& value,
00133                       const Array<Bool>& temp, const Array<Bool>& tempMask);
00134 // </group>
00135 
00136 private:
00137    Array<Bool>* itsMaskPtr;
00138 };
00139 
00140 
00141 
00142 } //# NAMESPACE CASA - END
00143 
00144 #endif