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