casacore
ExtendLattice.h
Go to the documentation of this file.
1 //# ExtendLattice.h: A subset of a Lattice or MaskedLattice
2 //# Copyright (C) 2001,2003
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 //#
27 //# $Id$
28 
29 #ifndef LATTICES_EXTENDLATTICE_H
30 #define LATTICES_EXTENDLATTICE_H
31 
32 
33 //# Includes
34 #include <casacore/casa/aips.h>
35 #include <casacore/lattices/Lattices/MaskedLattice.h>
36 #include <casacore/casa/Arrays/ExtendSpecifier.h>
37 
38 namespace casacore { //# NAMESPACE CASACORE - BEGIN
39 
40 //# Forward Declarations
41 
42 
43 // <summary>
44 // An extension of a Lattice or MaskedLattice
45 // </summary>
46 
47 // <use visibility=export>
48 
49 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
50 // </reviewed>
51 
52 // <prerequisite>
53 // <li> <linkto class="Lattice">Lattice</linkto>
54 // <li> <linkto class="LatticeRegion">LatticeRegion</linkto>
55 // </prerequisite>
56 
57 // <synopsis>
58 // An ExtendLattice is a lattice virtually extending another lattice
59 // by stretching axes with length 1 and/or by adding new axes.
60 // It is useful for e.g. LEL to have the same shapes for lattices.
61 // An ExtendLattice is not writable (since many pixels map to the same
62 // underlying pixel).
63 // </synopsis>
64 
65 // <example>
66 // <srcblock>
67 // </srcblock>
68 // </example>
69 
70 // <templating arg=T>
71 // <li> Any type that can be used by the Tables System can also be used by
72 // this class.
73 // </templating>
74 
75 //# <todo asof="yyyy/mm/dd">
76 //# </todo>
77 
78 template<class T> class ExtendLattice: public MaskedLattice<T>
79 {
80 public:
81  // The default constructor creates a ExtendLattice that is useless for just
82  // about everything, except that it can be assigned to with the assignment
83  // operator.
85 
86  // Create a ExtendLattice from a Lattice.
87  // <br><src>newShape</src> gives the new shape.
88  // <br><src>newAxes</src> gives the new axes in newShape.
89  // <br><src>stretchAxes</src> gives the stretched axes in newShape.
90  // <br>E.g. lattice has shape [32,1,5,1], newShape=[32,1,4,5,10],
91  // newAxes=[2], and stretchAxes=[4]. It means that axes 2 in the newShape
92  // is a new axes and that axes 4 in the new shape is stretched. The other
93  // axes in the new shape have to match the other axes in the old shape.
94  // Note that stretched axes have to have length 1 in the old shape.
95  // <group>
96  ExtendLattice (const Lattice<T>& lattice, const IPosition& newShape,
97  const IPosition& extendAxes, const IPosition& stretchAxes);
98  ExtendLattice (const MaskedLattice<T>& lattice, const IPosition& newShape,
99  const IPosition& newAxes, const IPosition& stretchAxes);
100  // </group>
101 
102  // Copy constructor (reference semantics).
104 
105  virtual ~ExtendLattice();
106 
107  // Assignment (reference semantics).
109 
110  // Make a copy of the object (reference semantics).
111  virtual MaskedLattice<T>* cloneML() const;
112 
113  // Is the lattice masked?
114  // It is if its parent lattice is masked.
115  virtual Bool isMasked() const;
116 
117  // An ExtendLattice is not persistent.
118  virtual Bool isPersistent() const;
119 
120  // Is the ExtendLattice paged to disk?
121  virtual Bool isPaged() const;
122 
123  // An ExtendLattice is not writable.
124  virtual Bool isWritable() const;
125 
126  // Handle locking of the ExtendLattice which is delegated to its parent.
127  // <br>It is strongly recommended to use class
128  // <linkto class=LatticeLocker>LatticeLocker</linkto> to
129  // handle lattice locking. It also contains a more detailed
130  // explanation of the locking process.
131  // <group>
132  virtual Bool lock (FileLocker::LockType, uInt nattempts);
133  virtual void unlock();
135  // </group>
136 
137  // Resynchronize the Lattice object with the lattice file.
138  // This function is only useful if no read-locking is used, ie.
139  // if the table lock option is UserNoReadLocking or AutoNoReadLocking.
140  // In that cases the table system does not acquire a read-lock, thus
141  // does not synchronize itself automatically.
142  virtual void resync();
143 
144  // Flush the data.
145  virtual void flush();
146 
147  // Close the Lattice temporarily (if it is paged to disk).
148  // It'll be reopened automatically when needed or when
149  // <src>reopen</src> is called explicitly.
150  virtual void tempClose();
151 
152  // If needed, reopen a temporarily closed Lattice.
153  virtual void reopen();
154 
155  // Does the ExtendLattice have a pixelmask?
156  virtual Bool hasPixelMask() const;
157 
158  // Get access to the pixelmask.
159  // An exception is thrown if the ExtendLattice does not have a pixelmask.
160  // <group>
161  virtual const Lattice<Bool>& pixelMask() const;
163  // </group>
164 
165  // Get the region used (always returns 0).
166  virtual const LatticeRegion* getRegionPtr() const;
167 
168  // Returns the shape of the ExtendLattice.
169  virtual IPosition shape() const;
170 
171  // Return the name of the parent lattice.
172  virtual String name (Bool stripPath=False) const;
173 
174  // This function returns the recommended maximum number of pixels to
175  // include in the cursor of an iterator.
176  virtual uInt advisedMaxPixels() const;
177 
178  // Check class internals - used for debugging. Should always return True
179  virtual Bool ok() const;
180 
181  // Do the actual getting of an array of values.
182  virtual Bool doGetSlice (Array<T>& buffer, const Slicer& section);
183 
184  // Putting data is not possible.
185  virtual void doPutSlice (const Array<T>& sourceBuffer,
186  const IPosition& where,
187  const IPosition& stride);
188 
189  // Get a section of the mask.
190  virtual Bool doGetMaskSlice (Array<Bool>& buffer, const Slicer& section);
191 
192  // Get the best cursor shape.
193  virtual IPosition doNiceCursorShape (uInt maxPixels) const;
194 
195 private:
196  // Set the various pointer needed to construct the object.
197  // One of the pointers should be zero.
198  // It takes over the pointer and deletes the object in the destructor.
199  void setPtr (Lattice<T>* latticePtr, MaskedLattice<T>* maskLatPtr);
200 
201  // Get mask data from mask.
202  Bool getMaskDataSlice (Array<Bool>& buffer, const Slicer& section);
203 
209 };
210 
211 
212 
213 } //# NAMESPACE CASACORE - END
214 
215 #ifndef CASACORE_NO_AUTO_TEMPLATES
216 #include <casacore/lattices/Lattices/ExtendLattice.tcc>
217 #endif //# CASACORE_NO_AUTO_TEMPLATES
218 #endif
casacore::ExtendLattice::ExtendLattice
ExtendLattice(const MaskedLattice< T > &lattice, const IPosition &newShape, const IPosition &newAxes, const IPosition &stretchAxes)
casacore::Slicer
Definition: Slicer.h:290
casacore::IPosition
Definition: IPosition.h:120
casacore::ExtendLattice::getMaskDataSlice
Bool getMaskDataSlice(Array< Bool > &buffer, const Slicer &section)
Get mask data from mask.
casacore::MaskedLattice
Definition: MaskedLattice.h:218
casacore::ExtendLattice::name
virtual String name(Bool stripPath=False) const
Return the name of the parent lattice.
casacore::ExtendLattice::doPutSlice
virtual void doPutSlice(const Array< T > &sourceBuffer, const IPosition &where, const IPosition &stride)
Putting data is not possible.
casacore::ExtendLattice::advisedMaxPixels
virtual uInt advisedMaxPixels() const
This function returns the recommended maximum number of pixels to include in the cursor of an iterato...
casacore::ExtendLattice::setPtr
void setPtr(Lattice< T > *latticePtr, MaskedLattice< T > *maskLatPtr)
Set the various pointer needed to construct the object.
casacore::ExtendLattice::cloneML
virtual MaskedLattice< T > * cloneML() const
Make a copy of the object (reference semantics).
casacore::FileLocker::LockType
LockType
Define the possible lock types.
Definition: FileLocker.h:95
casacore::ExtendLattice::reopen
virtual void reopen()
If needed, reopen a temporarily closed Lattice.
casacore::ExtendLattice::getRegionPtr
virtual const LatticeRegion * getRegionPtr() const
Get the region used (always returns 0).
casacore::ExtendLattice::flush
virtual void flush()
Flush the data.
casacore::ExtendLattice::lock
virtual Bool lock(FileLocker::LockType, uInt nattempts)
Handle locking of the ExtendLattice which is delegated to its parent.
casacore::LatticeRegion
Definition: LatticeRegion.h:75
casacore::ExtendLattice::isWritable
virtual Bool isWritable() const
An ExtendLattice is not writable.
casacore::ExtendLattice::~ExtendLattice
virtual ~ExtendLattice()
casacore::ExtendLattice::isPaged
virtual Bool isPaged() const
Is the ExtendLattice paged to disk?
casacore::ExtendLattice::pixelMask
virtual const Lattice< Bool > & pixelMask() const
Get access to the pixelmask.
casacore::ExtendLattice::ok
virtual Bool ok() const
Check class internals - used for debugging.
casacore::ExtendLattice::hasLock
virtual Bool hasLock(FileLocker::LockType) const
casacore::False
const Bool False
Definition: aipstype.h:44
casacore::uInt
unsigned int uInt
Definition: aipstype.h:51
casacore::ExtendLattice::ExtendLattice
ExtendLattice(const ExtendLattice< T > &other)
Copy constructor (reference semantics).
casacore::ExtendLattice::ExtendLattice
ExtendLattice()
The default constructor creates a ExtendLattice that is useless for just about everything,...
casacore::ExtendLattice::itsLatticePtr
Lattice< T > * itsLatticePtr
Definition: ExtendLattice.h:204
casacore::ExtendLattice::shape
virtual IPosition shape() const
Returns the shape of the ExtendLattice.
casacore::ExtendLattice::itsHasPixelMask
Bool itsHasPixelMask
Definition: ExtendLattice.h:206
casacore
this file contains all the compiler specific defines
Definition: mainpage.dox:28
casacore::ExtendLattice::doGetSlice
virtual Bool doGetSlice(Array< T > &buffer, const Slicer &section)
Do the actual getting of an array of values.
casacore::ExtendLattice::itsPixelMask
ExtendLattice< Bool > * itsPixelMask
Definition: ExtendLattice.h:207
casacore::ExtendLattice::doNiceCursorShape
virtual IPosition doNiceCursorShape(uInt maxPixels) const
Get the best cursor shape.
casacore::ExtendLattice::resync
virtual void resync()
Resynchronize the Lattice object with the lattice file.
casacore::ExtendLattice::itsMaskLatPtr
MaskedLattice< T > * itsMaskLatPtr
Definition: ExtendLattice.h:205
casacore::ExtendSpecifier
Definition: ExtendSpecifier.h:91
casacore::Lattice
Definition: Lattice.h:232
casacore::ExtendLattice::itsExtendSpec
ExtendSpecifier itsExtendSpec
Definition: ExtendLattice.h:208
casacore::Array
template <class T, class U> class vector;
Definition: Array.h:167
casacore::String
String: the storage and methods of handling collections of characters.
Definition: String.h:223
casacore::Bool
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
casacore::ExtendLattice::hasPixelMask
virtual Bool hasPixelMask() const
Does the ExtendLattice have a pixelmask?
casacore::ExtendLattice::operator=
ExtendLattice< T > & operator=(const ExtendLattice< T > &other)
Assignment (reference semantics).
casacore::ExtendLattice::ExtendLattice
ExtendLattice(const Lattice< T > &lattice, const IPosition &newShape, const IPosition &extendAxes, const IPosition &stretchAxes)
Create a ExtendLattice from a Lattice.
casacore::ExtendLattice::unlock
virtual void unlock()
casacore::ExtendLattice::pixelMask
virtual Lattice< Bool > & pixelMask()
casacore::ExtendLattice::doGetMaskSlice
virtual Bool doGetMaskSlice(Array< Bool > &buffer, const Slicer &section)
Get a section of the mask.
casacore::ExtendLattice
Definition: ExtendLattice.h:79
casacore::ExtendLattice::isPersistent
virtual Bool isPersistent() const
An ExtendLattice is not persistent.
casacore::ExtendLattice::tempClose
virtual void tempClose()
Close the Lattice temporarily (if it is paged to disk).
casacore::ExtendLattice::isMasked
virtual Bool isMasked() const
Is the lattice masked? It is if its parent lattice is masked.