casacore
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>
34 #include <casacore/lattices/LRegions/LCBox.h>
35 #include <casacore/lattices/Lattices/PagedArray.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:
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);
79  // </group>
80 
81  // Copy constructor (copy semantics).
82  LCPagedMask (const LCPagedMask& other);
83 
84  // Destructor
85  virtual ~LCPagedMask();
86 
87  // Assignment (reference semantics).
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();
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.
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
casacore::LCPagedMask::clearCache
virtual void clearCache()
Clears and frees up the caches, but the maximum allowed cache size is unchanged from when setCacheSiz...
casacore::LCPagedMask::advisedMaxPixels
virtual uInt advisedMaxPixels() const
Returns the maximum recommended number of pixels for a cursor.
casacore::LCPagedMask
Definition: LCPagedMask.h:67
casacore::LCPagedMask::tempClose
virtual void tempClose()
Temporarily close the lattice.
casacore::LCPagedMask::handleDelete
virtual void handleDelete()
Handle deletion of the region by deleting the associated table.
casacore::IPosition
Definition: IPosition.h:120
casacore::LCPagedMask::LCPagedMask
LCPagedMask(PagedArray< Bool > &mask, const LCBox &box)
casacore::LCPagedMask::unlock
virtual void unlock()
casacore::LCPagedMask::fromRecord
static LCPagedMask * fromRecord(const TableRecord &, const String &tablename)
Convert correct object from a record.
casacore::LCPagedMask::cloneRegion
virtual LCRegion * cloneRegion() const
Make a copy of the derived object.
casacore::LCPagedMask::reopen
virtual void reopen()
Explicitly reopen the temporarily closed lattice.
casacore::LCPagedMask::doTranslate
virtual LCRegion * doTranslate(const Vector< Float > &translateVector, const IPosition &newLatticeShape) const
Construct another LCPagedMask (for e.g.
casacore::LCPagedMask::operator=
LCPagedMask & operator=(const LCPagedMask &other)
Assignment (reference semantics).
casacore::TableRecord
Definition: TableRecord.h:183
casacore::LCPagedMask::doNiceCursorShape
virtual IPosition doNiceCursorShape(uInt maxPixels) const
Help the user pick a cursor for most efficient access.
casacore::LCBox
Definition: LCBox.h:68
casacore::LCPagedMask::setCacheSizeFromPath
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.
casacore::LCPagedMask::isWritable
virtual Bool isWritable() const
An LCPagedMask is writable if the underlying PagedArray is.
casacore::LCPagedMask::LCPagedMask
LCPagedMask(const LCPagedMask &other)
Copy constructor (copy semantics).
casacore::FileLocker::LockType
LockType
Define the possible lock types.
Definition: FileLocker.h:95
casacore::LCPagedMask::operator==
virtual Bool operator==(const LCRegion &other) const
Comparison.
casacore::LCPagedMask::itsBox
LCBox itsBox
Definition: LCPagedMask.h:198
casacore::LatticeNavigator
Definition: LatticeNavigator.h:182
casacore::LCPagedMask::LCPagedMask
LCPagedMask(const TiledShape &maskShape, const LCBox &box, const String &tableName)
casacore::LCPagedMask::setCacheSizeInTiles
virtual void setCacheSizeInTiles(uInt howManyTiles)
Set the actual cache size for this Array to be be big enough for the indicated number of tiles.
casacore::uInt
unsigned int uInt
Definition: aipstype.h:51
casacore::LCPagedMask::type
virtual String type() const
Region type.
casacore::LCPagedMask::showCacheStatistics
virtual void showCacheStatistics(ostream &os) const
Report on cache success.
casacore::LCPagedMask::LCPagedMask
LCPagedMask(const TiledShape &latticeShape, const String &tableName)
Construct a PagedMask object for (part of) a lattice.
casacore::LCRegion
Definition: LCRegion.h:88
casacore::LCPagedMask::flush
virtual void flush()
Flush the data (but do not unlock).
casacore::LCPagedMask::handleRename
virtual void handleRename(const String &newName, Bool overwrite)
Handle renaming the region by renaming the associated table.
casacore::LCPagedMask::lock
virtual Bool lock(FileLocker::LockType, uInt nattempts)
Handle the (un)locking.
casacore::LCPagedMask::className
static String className()
Get the class name (to store in the record).
casacore::PagedArray< Bool >
casacore::LCPagedMask::maximumCacheSize
virtual uInt maximumCacheSize() const
Maximum size - not necessarily all used.
casacore::LCPagedMask::makeIter
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...
casacore
this file contains all the compiler specific defines
Definition: mainpage.dox:28
casacore::LCRegionSingle
Definition: LCRegionSingle.h:81
casacore::LCRegion::latticeShape
const IPosition & latticeShape() const
Give the full lattice shape.
Definition: LCRegion.h:231
casacore::mask
LatticeExprNode mask(const LatticeExprNode &expr)
This function returns the mask of the given expression.
casacore::LCPagedMask::LCPagedMask
LCPagedMask()
casacore::LCPagedMask::LCPagedMask
LCPagedMask(PagedArray< Bool > &mask, const IPosition &blc, const IPosition &latticeShape)
Create the object from a record (for an existing mask).
casacore::String
String: the storage and methods of handling collections of characters.
Definition: String.h:223
casacore::LCPagedMask::resync
virtual void resync()
Resynchronize the PagedArray object with the lattice file.
casacore::Bool
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
casacore::LCPagedMask::setMaximumCacheSize
virtual void setMaximumCacheSize(uInt howManyPixels)
Set the maximum (allowed) cache size as indicated.
casacore::Vector< Float >
casacore::LCPagedMask::hasLock
virtual Bool hasLock(FileLocker::LockType) const
casacore::LCPagedMask::~LCPagedMask
virtual ~LCPagedMask()
Destructor.
casacore::TiledShape
Definition: TiledShape.h:100
casacore::LCPagedMask::toRecord
virtual TableRecord toRecord(const String &tableName) const
Convert the (derived) object to a record.
casacore::LatticeIterInterface
Definition: LatticeIterInterface.h:117
casacore::LCPagedMask::itsMask
PagedArray< Bool > itsMask
Definition: LCPagedMask.h:199