casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
LCPagedMask.h
Go to the documentation of this file.
1 //# LCPagedMask.h: Class to define a rectangular mask as a region
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: 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_LCPAGEDMASK_H
29 #define LATTICES_LCPAGEDMASK_H
30 
31 
32 //# Includes
33 #include <casacore/casa/aips.h>
36 
37 
38 namespace casacore { //# NAMESPACE CASACORE - BEGIN
39 
40 // <summary>
41 // Class to define a rectangular mask as a region
42 // </summary>
43 
44 // <use visibility=export>
45 
46 // <reviewed reviewer="" date="" tests="">
47 // </reviewed>
48 
49 // <prerequisite>
50 // <li> <linkto class=LCRegion>LCRegion</linkto>
51 // </prerequisite>
52 
53 // <synopsis>
54 // The LCPagedMask class is a specialization of class
55 // <linkto class=LCRegion>LCRegion</linkto>.
56 // </synopsis>
57 
58 // <example>
59 // <srcblock>
60 // </srcblock>
61 // </example>
62 
63 // <todo asof="1997/11/11">
64 // </todo>
65 
67 {
68 public:
69  LCPagedMask();
70 
71  // Construct a PagedMask object for (part of) a lattice.
72  // The box defines the position of the mask.
73  // The default mask shape is the lattice shape.
74  // <group>
75  LCPagedMask (const TiledShape& latticeShape, const String& tableName);
76  LCPagedMask (const TiledShape& maskShape, const LCBox& box,
77  const String& tableName);
78  LCPagedMask (PagedArray<Bool>& mask, const LCBox& box);
79  // </group>
80 
81  // Copy constructor (copy semantics).
82  LCPagedMask (const LCPagedMask& other);
83 
84  // Destructor
85  virtual ~LCPagedMask();
86 
87  // Assignment (reference semantics).
88  LCPagedMask& operator= (const LCPagedMask& other);
89 
90  // Comparison
91  virtual Bool operator==(const LCRegion& other) const;
92 
93  // Make a copy of the derived object.
94  virtual LCRegion* cloneRegion() const;
95 
96  // This function is used by the LatticeIterator class to generate an
97  // iterator of the correct type for this Lattice. Not recommended
98  // for general use.
100  (const LatticeNavigator& navigator,
101  Bool useRef) const;
102 
103  // Returns the maximum recommended number of pixels for a cursor.
104  // This is the number of pixels in a tile.
105  virtual uInt advisedMaxPixels() const;
106 
107  // Help the user pick a cursor for most efficient access.
108  virtual IPosition doNiceCursorShape (uInt maxPixels) const;
109 
110  // Maximum size - not necessarily all used. In pixels.
111  virtual uInt maximumCacheSize() const;
112 
113  // Set the maximum (allowed) cache size as indicated.
114  virtual void setMaximumCacheSize (uInt howManyPixels);
115 
116  // Set the cache size as to "fit" the indicated path.
117  virtual void setCacheSizeFromPath (const IPosition& sliceShape,
118  const IPosition& windowStart,
119  const IPosition& windowLength,
120  const IPosition& axisPath);
121 
122  // Set the actual cache size for this Array to be be big enough for the
123  // indicated number of tiles. This cache is not shared with PagedArrays
124  // in other rows and is always clipped to be less than the maximum value
125  // set using the setMaximumCacheSize member function.
126  // tiles. Tiles are cached using a first in first out algorithm.
127  virtual void setCacheSizeInTiles (uInt howManyTiles);
128 
129  // Clears and frees up the caches, but the maximum allowed cache size is
130  // unchanged from when setCacheSize was called
131  virtual void clearCache();
132 
133  // Report on cache success.
134  virtual void showCacheStatistics (ostream& os) const;
135 
136  // Handle deletion of the region by deleting the associated table.
137  virtual void handleDelete();
138 
139  // Handle renaming the region by renaming the associated table.
140  // If overwrite=False, an exception will be thrown if a table with the
141  // new name already exists.
142  virtual void handleRename (const String& newName, Bool overwrite);
143 
144  // Handle the (un)locking.
145  // <group>
146  virtual Bool lock (FileLocker::LockType, uInt nattempts);
147  virtual void unlock();
148  virtual Bool hasLock (FileLocker::LockType) const;
149  // </group>
150 
151  // Resynchronize the PagedArray object with the lattice file.
152  // This function is only useful if no read-locking is used, ie.
153  // if the table lock option is UserNoReadLocking or AutoNoReadLocking.
154  // In that cases the table system does not acquire a read-lock, thus
155  // does not synchronize itself automatically.
156  virtual void resync();
157 
158  // Flush the data (but do not unlock).
159  virtual void flush();
160 
161  // Temporarily close the lattice.
162  // It will be reopened automatically on the next access.
163  virtual void tempClose();
164 
165  // Explicitly reopen the temporarily closed lattice.
166  virtual void reopen();
167 
168  // Get the class name (to store in the record).
169  static String className();
170 
171  // Region type. Returns class name.
172  virtual String type() const;
173 
174  // Convert the (derived) object to a record.
175  virtual TableRecord toRecord (const String& tableName) const;
176 
177  // Convert correct object from a record.
178  static LCPagedMask* fromRecord (const TableRecord&,
179  const String& tablename);
180 
181  // An LCPagedMask is writable if the underlying PagedArray is.
182  virtual Bool isWritable() const;
183 
184 protected:
185  // Construct another LCPagedMask (for e.g. another lattice) by moving
186  // this one. It recalculates the bounding mask.
187  // A positive translation value indicates "to right".
188  virtual LCRegion* doTranslate (const Vector<Float>& translateVector,
189  const IPosition& newLatticeShape) const;
190 
191 private:
192  // Create the object from a record (for an existing mask).
194  const IPosition& blc,
195  const IPosition& latticeShape);
196 
197 
200 };
201 
202 
203 
204 } //# NAMESPACE CASACORE - END
205 
206 #endif
A Vector of integers, for indexing into Array&lt;T&gt; objects.
Definition: IPosition.h:119
virtual String type() const
Region type.
virtual void tempClose()
Temporarily close the lattice.
virtual uInt advisedMaxPixels() const
Returns the maximum recommended number of pixels for a cursor.
virtual void unlock()
virtual Bool isWritable() const
An LCPagedMask is writable if the underlying PagedArray is.
PagedArray< Bool > itsMask
Definition: LCPagedMask.h:199
Class to define a rectangular box of interest.
Definition: LCBox.h:67
virtual void handleDelete()
Handle deletion of the region by deleting the associated table.
virtual Bool operator==(const LCRegion &other) const
Comparison.
LatticeExprNode mask(const LatticeExprNode &expr)
This function returns the mask of the given expression.
virtual void clearCache()
Clears and frees up the caches, but the maximum allowed cache size is unchanged from when setCacheSiz...
virtual void setCacheSizeFromPath(const IPosition &sliceShape, const IPosition &windowStart, const IPosition &windowLength, const IPosition &axisPath)
Set the cache size as to &quot;fit&quot; the indicated path.
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...
static LCPagedMask * fromRecord(const TableRecord &, const String &tablename)
Convert correct object from a record.
virtual void setCacheSizeInTiles(uInt howManyTiles)
Set the actual cache size for this Array to be be big enough for the indicated number of tiles...
LCPagedMask & operator=(const LCPagedMask &other)
Assignment (reference semantics).
virtual Bool hasLock(FileLocker::LockType) const
virtual void handleRename(const String &newName, Bool overwrite)
Handle renaming the region by renaming the associated table.
virtual IPosition doNiceCursorShape(uInt maxPixels) const
Help the user pick a cursor for most efficient access.
A base class for Lattice iterators.
Definition: SubImage.h:46
Define the shape and tile shape.
Definition: TiledShape.h:99
static String className()
Get the class name (to store in the record).
virtual void flush()
Flush the data (but do not unlock).
virtual LCRegion * doTranslate(const Vector< Float > &translateVector, const IPosition &newLatticeShape) const
Construct another LCPagedMask (for e.g.
virtual TableRecord toRecord(const String &tableName) const
Convert the (derived) object to a record.
virtual LCRegion * cloneRegion() const
Make a copy of the derived object.
const IPosition & latticeShape() const
Give the full lattice shape.
Definition: LCRegion.h:231
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
virtual void showCacheStatistics(ostream &os) const
Report on cache success.
virtual Bool lock(FileLocker::LockType, uInt nattempts)
Handle the (un)locking.
A hierarchical collection of named fields of various types.
Definition: TableRecord.h:182
Class to define a rectangular mask as a region.
Definition: LCPagedMask.h:66
virtual void setMaximumCacheSize(uInt howManyPixels)
Set the maximum (allowed) cache size as indicated.
String: the storage and methods of handling collections of characters.
Definition: String.h:223
virtual void resync()
Resynchronize the PagedArray object with the lattice file.
virtual uInt maximumCacheSize() const
Maximum size - not necessarily all used.
LockType
Define the possible lock types.
Definition: FileLocker.h:95
Abstract base class to define a single region.
virtual void reopen()
Explicitly reopen the temporarily closed lattice.
virtual ~LCPagedMask()
Destructor.
unsigned int uInt
Definition: aipstype.h:51
Abstract base class to steer lattice iterators.
Abstract base class to define a region of interest in lattice coordinates.
Definition: LCRegion.h:87
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42