casacore
Loading...
Searching...
No Matches
LatticeRegion.h
Go to the documentation of this file.
1//# LatticeRegion.h: An optionally strided region in a lattice
2//# Copyright (C) 1998,1999,2000,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: casa-feedback@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#ifndef LATTICES_LATTICEREGION_H
27#define LATTICES_LATTICEREGION_H
28
29
30//# Includes
31#include <casacore/casa/aips.h>
32#include <casacore/lattices/Lattices/Lattice.h>
33#include <casacore/casa/Arrays/Slicer.h>
34
35namespace casacore { //# NAMESPACE CASACORE - BEGIN
36
37//# Forward Declarations
38class LCRegion;
39
40
41// <summary>
42// An optionally strided region in a Lattice
43// </summary>
44
45// <use visibility=local>
46
47// <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
48// </reviewed>
49
50// <prerequisite>
51// <li> <linkto class="LCRegion">LCRegion</linkto>
52// </prerequisite>
53
54// <synopsis>
55// A LatticeRegion is a lattice referencing a subset of another lattice
56// by means of a <linkto class="Slicer">Slicer</linkto> object.
57// <br>It is useful when only a subset of a lattice needs to be accessed.
58// <p>
59// When the LatticeRegion is created from a const <src>Lattice</src> object,
60// it is not writable, thus it can only be used as an rvalue.
61// </synopsis>
62
63// <example>
64// <srcblock>
65// </srcblock>
66// </example>
67
68//# <todo asof="yyyy/mm/dd">
69//# </todo>
70
71class LatticeRegion: public Lattice<Bool>
72{
73public:
74 // The default constructor creates a LatticeRegion that is useless for just
75 // about everything, except that it can be assigned to with the assignment
76 // operator.
78
79 // Create from the given region.
80 // The pointer to the parent can be 0.
82
83 // Create from the given region and take over the pointer.
84 // This means the user should not delete the region object pointed to,
85 // because it will be deleted by the LatticeRegion destructor.
86 // The pointer to the parent is set to 0.
88
89 // Construct from the given slicer. The lattice shape has to be
90 // the lattice shape of the lattice where the region is taken from.
91 LatticeRegion (const Slicer& slicer, const IPosition& latticeShape);
92
93 // Copy constructor (reference semantics).
95
96 virtual ~LatticeRegion();
97
98 // Assignment (reference semantics).
100
101 // Make a copy of the object (reference semantics).
102 virtual Lattice<Bool>* clone() const;
103
104 // Is the LatticeRegion writable?
105 virtual Bool isWritable() const;
106
107 // Has the region a mask?
108 Bool hasMask() const;
109
110 // Handle the (un)locking.
111 // <group>
112 virtual Bool lock (FileLocker::LockType, uInt nattempts);
113 virtual void unlock();
115 // </group>
116
117 // Resynchronize the PagedArray object with the lattice file.
118 // This function is only useful if no read-locking is used, ie.
119 // if the table lock option is UserNoReadLocking or AutoNoReadLocking.
120 // In that cases the table system does not acquire a read-lock, thus
121 // does not synchronize itself automatically.
122 virtual void resync();
123
124 // Flush the data (but do not unlock).
125 virtual void flush();
126
127 // Temporarily close the lattice.
128 // It will be reopened automatically on the next access.
129 virtual void tempClose();
130
131 // Explicitly reopen the temporarily closed lattice.
132 virtual void reopen();
133
134 // Get the LCRegion object describing the region.
135 // Note that it does not contain strides, even if this LatticeRegion
136 // object was constructed from a Slicer with strides. In that case
137 // the region only defines the resulting shape.
138 const LCRegion& region() const;
139
140 // Get the Slicer object describing the region.
141 // Note that it may contain strides.
142 const Slicer& slicer() const;
143
144 // Returns the shape of the LatticeRegion including all degenerate axes
145 // (i.e. axes with a length of one).
146 virtual IPosition shape() const;
147
148 // Returns the number of axes in this LatticeRegion. This includes all
149 // degenerate axes.
150 virtual uInt ndim() const;
151
152 // Returns the total number of elements in this LatticeRegion.
153 virtual size_t nelements() const;
154
155 // Check class internals - used for debugging. Should always return True
156 virtual Bool ok() const;
157
158 // This function is used by the LatticeIterator class to generate an
159 // iterator of the correct type for this Lattice. Not recommended
160 // for general use.
162 (const LatticeNavigator& navigator,
163 Bool useRef) const;
164
165 // Returns the maximum recommended number of pixels for a cursor.
166 // This is the number of pixels in a tile.
167 virtual uInt advisedMaxPixels() const;
168
169 // Help the user pick a cursor for most efficient access.
170 virtual IPosition doNiceCursorShape (uInt maxPixels) const;
171
172 // Maximum size - not necessarily all used. In pixels.
173 virtual uInt maximumCacheSize() const;
174
175 // Set the maximum (allowed) cache size as indicated.
176 virtual void setMaximumCacheSize (uInt howManyPixels);
177
178 // Set the cache size as to "fit" the indicated path.
179 virtual void setCacheSizeFromPath (const IPosition& sliceShape,
180 const IPosition& windowStart,
181 const IPosition& windowLength,
182 const IPosition& axisPath);
183
184 // Set the actual cache size for this Array to be be big enough for the
185 // indicated number of tiles. This cache is not shared with PagedArrays
186 // in other rows and is always clipped to be less than the maximum value
187 // set using the setMaximumCacheSize member function.
188 // tiles. Tiles are cached using a first in first out algorithm.
189 virtual void setCacheSizeInTiles (uInt howManyTiles);
190
191 // Clears and frees up the caches, but the maximum allowed cache size is
192 // unchanged from when setCacheSize was called
193 virtual void clearCache();
194
195 // Report on cache success.
196 virtual void showCacheStatistics (ostream& os) const;
197
198 // The following "put" functions are described in detail in class
199 // <linkto class=Lattice>Lattice</linkto>.
200 // They'll throw an exception is no mask is available or if
201 // the mask is not writable.
202 // <group>
203 virtual void set (const Bool& value);
204 virtual void apply (Bool (*function)(Bool));
205 virtual void apply (Bool (*function)(const Bool&));
206 virtual void apply (const Functional<Bool,Bool>& function);
207 virtual void putAt (const Bool& value, const IPosition& where);
208 virtual void copyData (const Lattice<Bool>& from);
209 // </group>
210
211 // Convert positions to positions in the parent object.
212 // <group>
213 Slicer convert (const Slicer& slicer) const;
214 IPosition convert (const IPosition& position) const;
215 // </group>
216
217 // Do the actual getting of the mask.
218 virtual Bool doGetSlice (Array<Bool>& buffer, const Slicer& section);
219
220 // Do the actual putting of the mask. Only possible if region is writable.
221 virtual void doPutSlice (const Array<Bool>& sourceBuffer,
222 const IPosition& where,
223 const IPosition& stride);
224
225
226private:
230};
231
232
234{
235 return itsHasRegionMask;
236}
237inline const LCRegion& LatticeRegion::region() const
238{
239 return *itsRegion;
240}
241inline const Slicer& LatticeRegion::slicer() const
242{
243 return itsSlicer;
244}
245
246
247
248} //# NAMESPACE CASACORE - END
249
250#endif
LockType
Define the possible lock types.
Definition FileLocker.h:93
virtual LatticeIterInterface< Bool > * makeIter(const LatticeNavigator &navigator, Bool useRef) const
This function is used by the LatticeIterator class to generate an iterator of the correct type for th...
virtual void unlock()
virtual void showCacheStatistics(ostream &os) const
Report on cache success.
LatticeRegion()
The default constructor creates a LatticeRegion that is useless for just about everything,...
virtual uInt maximumCacheSize() const
Maximum size - not necessarily all used.
virtual void doPutSlice(const Array< Bool > &sourceBuffer, const IPosition &where, const IPosition &stride)
Do the actual putting of the mask.
virtual size_t nelements() const
Returns the total number of elements in this LatticeRegion.
virtual void copyData(const Lattice< Bool > &from)
Copy the data from the given lattice to this one.
virtual void apply(const Functional< Bool, Bool > &function)
IPosition convert(const IPosition &position) const
LatticeRegion(const LatticeRegion &other)
Copy constructor (reference semantics).
LatticeRegion(const LCRegion &region)
Create from the given region.
LatticeRegion(const Slicer &slicer, const IPosition &latticeShape)
Construct from the given slicer.
Bool hasMask() const
Has the region a mask?
virtual Bool lock(FileLocker::LockType, uInt nattempts)
Handle the (un)locking.
virtual void clearCache()
Clears and frees up the caches, but the maximum allowed cache size is unchanged from when setCacheSiz...
virtual void setMaximumCacheSize(uInt howManyPixels)
Set the maximum (allowed) cache size as indicated.
virtual void tempClose()
Temporarily close the lattice.
virtual void putAt(const Bool &value, const IPosition &where)
Put the value of a single element.
virtual IPosition shape() const
Returns the shape of the LatticeRegion including all degenerate axes (i.e.
virtual void setCacheSizeFromPath(const IPosition &sliceShape, const IPosition &windowStart, const IPosition &windowLength, const IPosition &axisPath)
Set the cache size as to "fit" the indicated path.
virtual uInt advisedMaxPixels() const
Returns the maximum recommended number of pixels for a cursor.
Slicer convert(const Slicer &slicer) const
Convert positions to positions in the parent object.
virtual void apply(Bool(*function)(Bool))
Replace every element, x, of the Lattice with the result of f(x).
virtual Lattice< Bool > * clone() const
Make a copy of the object (reference semantics).
virtual void flush()
Flush the data (but do not unlock).
virtual Bool hasLock(FileLocker::LockType) const
virtual void apply(Bool(*function)(const Bool &))
virtual Bool isWritable() const
Is the LatticeRegion writable?
virtual IPosition doNiceCursorShape(uInt maxPixels) const
Help the user pick a cursor for most efficient access.
LatticeRegion & operator=(const LatticeRegion &other)
Assignment (reference semantics).
virtual uInt ndim() const
Returns the number of axes in this LatticeRegion.
LatticeRegion(LCRegion *region)
Create from the given region and take over the pointer.
const Slicer & slicer() const
Get the Slicer object describing the region.
virtual Bool ok() const
Check class internals - used for debugging.
virtual void reopen()
Explicitly reopen the temporarily closed lattice.
virtual void resync()
Resynchronize the PagedArray object with the lattice file.
virtual void set(const Bool &value)
The following "put" functions are described in detail in class Lattice.
virtual void setCacheSizeInTiles(uInt howManyTiles)
Set the actual cache size for this Array to be be big enough for the indicated number of tiles.
virtual Bool doGetSlice(Array< Bool > &buffer, const Slicer &section)
Do the actual getting of the mask.
const LCRegion & region() const
Get the LCRegion object describing the region.
this file contains all the compiler specific defines
Definition mainpage.dox:28
unsigned int uInt
Definition aipstype.h:49
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.