This file is indexed.

/usr/include/casacore/lattices/Lattices/MaskedLattice.tcc is in casacore-dev 2.2.0-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
//# MaskedLattice.cc: Abstract base class for array-like classes with masks
//# Copyright (C) 1998,1999,2000
//# Associated Universities, Inc. Washington DC, USA.
//#
//# This library is free software; you can redistribute it and/or modify it
//# under the terms of the GNU Library General Public License as published by
//# the Free Software Foundation; either version 2 of the License, or (at your
//# option) any later version.
//#
//# This library is distributed in the hope that it will be useful, but WITHOUT
//# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
//# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
//# License for more details.
//#
//# You should have received a copy of the GNU Library General Public License
//# along with this library; if not, write to the Free Software Foundation,
//# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
//#
//# Correspondence concerning AIPS++ should be addressed as follows:
//#        Internet email: aips2-request@nrao.edu.
//#        Postal address: AIPS++ Project Office
//#                        National Radio Astronomy Observatory
//#                        520 Edgemont Road
//#                        Charlottesville, VA 22903-2475 USA
//#
//# $Id$

#ifndef LATTICES_MASKEDLATTICE_TCC
#define LATTICES_MASKEDLATTICE_TCC


#include <casacore/lattices/Lattices/MaskedLattice.h>
#include <casacore/lattices/LRegions/LatticeRegion.h>
#include <casacore/lattices/LRegions/LCBox.h>
#include <casacore/casa/Arrays/Array.h>
#include <casacore/casa/Arrays/Slicer.h>
#include <casacore/casa/Utilities/COWPtr.h>
#include <casacore/casa/Exceptions/Error.h>


namespace casacore { //# NAMESPACE CASACORE - BEGIN

template <class T>
MaskedLattice<T>::MaskedLattice (const MaskedLattice<T>& that)
: Lattice<T>(),
  itsDefRegPtr (0)
{
  if (that.itsDefRegPtr != 0) {
    itsDefRegPtr = new LatticeRegion (*that.itsDefRegPtr);
  }
}

template <class T>
MaskedLattice<T>::~MaskedLattice()
{
  delete itsDefRegPtr;
}

template <class T>
MaskedLattice<T>& MaskedLattice<T>::operator= (const MaskedLattice<T>& that)
{
  if (this != &that) {
    delete itsDefRegPtr;
    itsDefRegPtr = 0;
    if (that.itsDefRegPtr != 0) {
      itsDefRegPtr = new LatticeRegion (*that.itsDefRegPtr);
    }
  }
  return *this;
}

template<class T>
Lattice<T>* MaskedLattice<T>::clone() const
{
    return cloneML();
}

template<class T>
Bool MaskedLattice<T>::isMasked() const
{
  const LatticeRegion* ptr = getRegionPtr();
  if (ptr == 0) {
    return False;
  }
  return ptr->hasMask();
}


template<class T>
Bool MaskedLattice<T>::hasPixelMask() const
{
  return False;
}

template<class T>
const Lattice<Bool>& MaskedLattice<T>::pixelMask() const
{
  throw (AipsError ("MaskedLattice::pixelMask - no pixelmask available"));
  //# Make the compiler happy.
  return *itsDefRegPtr;
}
template<class T>
Lattice<Bool>& MaskedLattice<T>::pixelMask()
{
  throw (AipsError ("MaskedLattice::pixelMask - no pixelmask available"));
  //# Make the compiler happy.
  return *itsDefRegPtr;
}

template<class T>
const LatticeRegion& MaskedLattice<T>::region() const
{
  // If there is a region, return it.
  const LatticeRegion* ptr = getRegionPtr();
  if (ptr != 0) {
    return *ptr;
  }
  // No region, so use the one in the MaskedLattice itself which
  // describes the entire lattice. Create it if it does not exist yet.
  // Check if its shape still matches.
  if (itsDefRegPtr != 0) {
    if (itsDefRegPtr->slicer().length().isEqual (shape())) {
      return *itsDefRegPtr;
    }
    delete itsDefRegPtr;
    itsDefRegPtr = 0;
  }
  itsDefRegPtr = new LatticeRegion (LCBox(shape()));
  return *itsDefRegPtr;
}


template<class T>
Bool MaskedLattice<T>::getMask (COWPtr<Array<Bool> >& buffer,
				Bool removeDegenerateAxes) const
{
  uInt nd = ndim();
  return getMaskSlice (buffer, Slicer(IPosition(nd,0), shape()),
		       removeDegenerateAxes);
}

template<class T>
Bool MaskedLattice<T>::getMask (Array<Bool>& buffer,
				Bool removeDegenerateAxes)
{
  uInt nd = ndim();
  return getMaskSlice (buffer, Slicer(IPosition(nd,0), shape()),
		       removeDegenerateAxes);
}

template<class T>
Array<Bool> MaskedLattice<T>::getMask (Bool removeDegenerateAxes) const
{
  uInt nd = ndim();
  return getMaskSlice (Slicer(IPosition(nd,0), shape()),
		       removeDegenerateAxes);
}

template<class T>
Bool MaskedLattice<T>::getMaskSlice (COWPtr<Array<Bool> >& buffer,
				     const IPosition& start, 
				     const IPosition& shape,
				     Bool removeDegenerateAxes) const
{
  return getMaskSlice (buffer, Slicer(start, shape),
		       removeDegenerateAxes);
}

template<class T>
Bool MaskedLattice<T>::getMaskSlice (COWPtr<Array<Bool> >& buffer,
				     const IPosition& start, 
				     const IPosition& shape,
				     const IPosition& stride,
				     Bool removeDegenerateAxes) const
{
  return getMaskSlice (buffer, Slicer(start, shape, stride),
		       removeDegenerateAxes);
}

template<class T>
Bool MaskedLattice<T>::getMaskSlice (COWPtr<Array<Bool> >& buffer,
				     const Slicer& section,
				     Bool removeDegenerateAxes) const
{
  // Cast pointer to non-const.
  // This is safe, since the array is copied when needed by COWptr.
  MaskedLattice<T>* This = (MaskedLattice<T>*)this;
  // The COWPtr takes over the pointer to the array.
  Array<Bool>* arr = new Array<Bool>;
  Bool isARef = This->getMaskSlice (*arr, section, removeDegenerateAxes);
  buffer = COWPtr<Array<Bool> > (arr, True, isARef);
  return False;
}

template<class T>
Bool MaskedLattice<T>::getMaskSlice (Array<Bool>& buffer,
				     const IPosition& start,
				     const IPosition& shape,
				     Bool removeDegenerateAxes)
{
  return getMaskSlice (buffer, Slicer(start, shape), removeDegenerateAxes);
}

template<class T>
Bool MaskedLattice<T>::getMaskSlice (Array<Bool>& buffer,
				     const IPosition& start,
				     const IPosition& shape,
				     const IPosition& stride,
				     Bool removeDegenerateAxes)
{
  return getMaskSlice (buffer, Slicer(start, shape, stride),
		       removeDegenerateAxes);
}

template<class T>
Bool MaskedLattice<T>::getMaskSlice (Array<Bool>& buffer,
				     const Slicer& section,
				     Bool removeDegenerateAxes)
{
  Bool isARef;
  // When the slicer is fixed, it can be used immediately.
  // Otherwise unspecified values are to be filled in.
  if (section.isFixed()) {
    isARef = doGetMaskSlice (buffer, section);
  } else {
    IPosition blc,trc,inc;
    section.inferShapeFromSource (shape(), blc, trc, inc);
    isARef = doGetMaskSlice (buffer, Slicer(blc,trc,inc,Slicer::endIsLast));
  }
  if (removeDegenerateAxes) {
    Array<Bool> tmp = buffer.nonDegenerate();
    buffer.reference (tmp);
  }
  return isARef;
}

template<class T>
Array<Bool> MaskedLattice<T>::getMaskSlice (const IPosition& start,
					    const IPosition& shape,
					    Bool removeDegenerateAxes) const
{
  return getMaskSlice (Slicer(start,shape), removeDegenerateAxes);
}

template<class T>
Array<Bool> MaskedLattice<T>::getMaskSlice (const IPosition& start,
					    const IPosition& shape,
					    const IPosition& stride,
					    Bool removeDegenerateAxes) const
{
  return getMaskSlice (Slicer(start,shape,stride), removeDegenerateAxes);
}

template<class T>
Array<Bool> MaskedLattice<T>::getMaskSlice (const Slicer& section,
					    Bool removeDegenerateAxes) const
{
  // Cast pointer to non-const.
  // This is safe, since the array is copied when needed.
  MaskedLattice<T>* This = (MaskedLattice<T>*)this;
  // Note that getMaskSlice is used to be sure that section getMasks filled
  // when needed.
  Array<Bool> arr;
  Bool isARef = This->getMaskSlice (arr, section, removeDegenerateAxes);
  // When not referenced, return it as such.
  // Otherwise make a copy.
  if (!isARef) {
    return arr;
  }
  Array<Bool> tmp;
  tmp = arr;
  return tmp;
}


template<class T>
Bool MaskedLattice<T>::doGetMaskSlice (Array<Bool>& buffer,
				       const Slicer& section)
{
  // Note that Slicer::inferShapeFromSource has already been called
  // by getMaskSlice.
  const LatticeRegion* ptr = getRegionPtr();
  if (ptr == 0) {
    buffer.resize (section.length());
    buffer = True;
    return False;
  }
  return const_cast<LatticeRegion*>(ptr)->doGetSlice (buffer, section);
}

} //# NAMESPACE CASACORE - END


#endif