casacore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
LELArrayBase.h
Go to the documentation of this file.
1 //# LELArrayBase.h: Base class for LELArray holding the mask
2 //# Copyright (C) 1999,2001
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This library is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU Library General Public License as published by
7 //# the Free Software Foundation; either version 2 of the License, or (at your
8 //# option) any later version.
9 //#
10 //# This library is distributed in the hope that it will be useful, but WITHOUT
11 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 //# License for more details.
14 //#
15 //# You should have received a copy of the GNU Library General Public License
16 //# along with this library; if not, write to the Free Software Foundation,
17 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 //#
19 //# Correspondence concerning AIPS++ should be addressed as follows:
20 //# Internet email: aips2-request@nrao.edu.
21 //# Postal address: AIPS++ Project Office
22 //# National Radio Astronomy Observatory
23 //# 520 Edgemont Road
24 //# Charlottesville, VA 22903-2475 USA
25 //#
26 //# $Id$
27 
28 #ifndef LATTICES_LELARRAYBASE_H
29 #define LATTICES_LELARRAYBASE_H
30 
31 
32 //# Includes
33 #include <casacore/casa/aips.h>
35 
36 
37 namespace casacore { //# NAMESPACE CASACORE - BEGIN
38 
39 // <summary>
40 // Base class for LELArray holding the mask.
41 // </summary>
42 
43 // <use visibility=local>
44 
45 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
46 // </reviewed>
47 
48 // <synopsis>
49 // This LEL class holds an array with a mask.
50 // The mask can be a single Bool valid for all elements of the array.
51 // Otherwise it is a full mask with the same shape as the array.
52 // </synopsis>
53 
54 // <motivation>
55 // It maskes it possible to handle an array with its mask as a single object.
56 // </motivation>
57 
58 // <todo asof="1998/01/20">
59 // </todo>
60 
61 
63 {
64 public:
65 // Default constructor sets to mask all true.
67  : itsMaskPtr(0) {}
68 
69 // Constructor takes mask.
71  : itsMaskPtr(new Array<Bool>(mask)) {}
72 
73 // Copy constructor (reference semantics).
74  LELArrayBase (const LELArrayBase& other);
75 
76  ~LELArrayBase();
77 
78 // Assignment (reference semantics).
79  LELArrayBase& operator= (const LELArrayBase& other);
80 
81 // Does the value have a mask?
82  Bool isMasked() const
83  { return (itsMaskPtr != 0); }
84 
85 // Get mask.
86 // <group>
87  const Array<Bool>& mask() const
88  { return *itsMaskPtr; }
90  { return *itsMaskPtr; }
91 // </group>
92 
93 // Remove the mask.
94  void removeMask();
95 
96 // Set the mask from given array (takes reference).
97  void setMask (const Array<Bool>& other);
98 
99 // Set the mask from the mask of the other value.
100  void setMask (const LELArrayBase& other);
101 
102 // Set the mask from given array (takes reference).
103  void setMask (Array<Bool>& other);
104 
105 // Set the mask by combining the masks of both values.
106  void setMask (const LELArrayBase& left, const LELArrayBase& right)
107  { setMask (left); combineMask (right); }
108 
109 // Combine the mask of this and the other value (by anding them).
110 // <group>
111  void combineMask (const LELArrayBase& other)
112  { if (other.isMasked()) combineMask (other.mask()); }
113  void combineMask (const Array<Bool>& mask);
114 // </group>
115 
116 // Combine the mask with the given value in case of an OR or AND.
117 // It means the mask is set to true if value is desiredValue
118 // (which should be True for OR and False for AND).
119 // <group>
120 // Combine with a single scalar value for which the mask is false.
121  void combineOrAnd (Bool desiredValue, const Array<Bool>& value);
122 
123 // Combine for two arrays taking the true/false array values into account.
124 // The mask and value are set to desiredValue if the temp value is desiredValue.
125  void combineOrAnd (Bool desiredValue, Array<Bool>& value,
126  const Array<Bool>& temp);
127 
128 // Combine for two arrays taking the true/false array values and mask
129 // into account.
130 // The mask and value are set to desiredValue if the temp value is desiredValue
131 // and its temp mask it true.
132 // The mask is set to false if the temp mask is False.
133  void combineOrAnd (Bool desiredValue, Array<Bool>& value,
134  const Array<Bool>& temp, const Array<Bool>& tempMask);
135 // </group>
136 
137 private:
139 };
140 
141 
142 
143 } //# NAMESPACE CASACORE - END
144 
145 #endif
LELArrayBase & operator=(const LELArrayBase &other)
Assignment (reference semantics).
Array< Bool > & mask()
Definition: LELArrayBase.h:89
const Array< Bool > & mask() const
Get mask.
Definition: LELArrayBase.h:87
LELArrayBase(const Array< Bool > &mask)
Constructor takes mask.
Definition: LELArrayBase.h:70
LELArrayBase()
Default constructor sets to mask all true.
Definition: LELArrayBase.h:66
Base class for LELArray holding the mask.
Definition: LELArrayBase.h:62
Array< Bool > * itsMaskPtr
Definition: LELArrayBase.h:138
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
void setMask(const LELArrayBase &left, const LELArrayBase &right)
Set the mask by combining the masks of both values.
Definition: LELArrayBase.h:106
void setMask(const Array< Bool > &other)
Set the mask from given array (takes reference).
void combineOrAnd(Bool desiredValue, const Array< Bool > &value)
Combine the mask with the given value in case of an OR or AND.
Bool isMasked() const
Does the value have a mask?
Definition: LELArrayBase.h:82
void combineMask(const LELArrayBase &other)
Combine the mask of this and the other value (by anding them).
Definition: LELArrayBase.h:111
void removeMask()
Remove the mask.
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.