00001 //# LCPagedMask.h: Class to define a rectangular mask as a region 00002 //# Copyright (C) 1998,1999,2000,2003 00003 //# Associated Universities, Inc. Washington DC, USA. 00004 //# 00005 //# This library is free software; you can redistribute it and/or modify it 00006 //# under the terms of the GNU Library General Public License as published by 00007 //# the Free Software Foundation; either version 2 of the License, or (at your 00008 //# option) any later version. 00009 //# 00010 //# This library is distributed in the hope that it will be useful, but WITHOUT 00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00012 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 00013 //# License for more details. 00014 //# 00015 //# You should have received a copy of the GNU Library General Public License 00016 //# along with this library; if not, write to the Free Software Foundation, 00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. 00018 //# 00019 //# Correspondence concerning AIPS++ should be addressed as follows: 00020 //# Internet email: aips2-request@nrao.edu. 00021 //# Postal address: AIPS++ Project Office 00022 //# National Radio Astronomy Observatory 00023 //# 520 Edgemont Road 00024 //# Charlottesville, VA 22903-2475 USA 00025 //# 00026 //# $Id$ 00027 00028 #ifndef LATTICES_LCPAGEDMASK_H 00029 #define LATTICES_LCPAGEDMASK_H 00030 00031 00032 //# Includes 00033 #include <casacore/casa/aips.h> 00034 #include <casacore/lattices/LRegions/LCBox.h> 00035 #include <casacore/lattices/Lattices/PagedArray.h> 00036 00037 00038 namespace casacore { //# NAMESPACE CASACORE - BEGIN 00039 00040 // <summary> 00041 // Class to define a rectangular mask as a region 00042 // </summary> 00043 00044 // <use visibility=export> 00045 00046 // <reviewed reviewer="" date="" tests=""> 00047 // </reviewed> 00048 00049 // <prerequisite> 00050 // <li> <linkto class=LCRegion>LCRegion</linkto> 00051 // </prerequisite> 00052 00053 // <synopsis> 00054 // The LCPagedMask class is a specialization of class 00055 // <linkto class=LCRegion>LCRegion</linkto>. 00056 // </synopsis> 00057 00058 // <example> 00059 // <srcblock> 00060 // </srcblock> 00061 // </example> 00062 00063 // <todo asof="1997/11/11"> 00064 // </todo> 00065 00066 class LCPagedMask: public LCRegionSingle 00067 { 00068 public: 00069 LCPagedMask(); 00070 00071 // Construct a PagedMask object for (part of) a lattice. 00072 // The box defines the position of the mask. 00073 // The default mask shape is the lattice shape. 00074 // <group> 00075 LCPagedMask (const TiledShape& latticeShape, const String& tableName); 00076 LCPagedMask (const TiledShape& maskShape, const LCBox& box, 00077 const String& tableName); 00078 LCPagedMask (PagedArray<Bool>& mask, const LCBox& box); 00079 // </group> 00080 00081 // Copy constructor (copy semantics). 00082 LCPagedMask (const LCPagedMask& other); 00083 00084 // Destructor 00085 virtual ~LCPagedMask(); 00086 00087 // Assignment (reference semantics). 00088 LCPagedMask& operator= (const LCPagedMask& other); 00089 00090 // Comparison 00091 virtual Bool operator==(const LCRegion& other) const; 00092 00093 // Make a copy of the derived object. 00094 virtual LCRegion* cloneRegion() const; 00095 00096 // This function is used by the LatticeIterator class to generate an 00097 // iterator of the correct type for this Lattice. Not recommended 00098 // for general use. 00099 virtual LatticeIterInterface<Bool>* makeIter 00100 (const LatticeNavigator& navigator, 00101 Bool useRef) const; 00102 00103 // Returns the maximum recommended number of pixels for a cursor. 00104 // This is the number of pixels in a tile. 00105 virtual uInt advisedMaxPixels() const; 00106 00107 // Help the user pick a cursor for most efficient access. 00108 virtual IPosition doNiceCursorShape (uInt maxPixels) const; 00109 00110 // Maximum size - not necessarily all used. In pixels. 00111 virtual uInt maximumCacheSize() const; 00112 00113 // Set the maximum (allowed) cache size as indicated. 00114 virtual void setMaximumCacheSize (uInt howManyPixels); 00115 00116 // Set the cache size as to "fit" the indicated path. 00117 virtual void setCacheSizeFromPath (const IPosition& sliceShape, 00118 const IPosition& windowStart, 00119 const IPosition& windowLength, 00120 const IPosition& axisPath); 00121 00122 // Set the actual cache size for this Array to be be big enough for the 00123 // indicated number of tiles. This cache is not shared with PagedArrays 00124 // in other rows and is always clipped to be less than the maximum value 00125 // set using the setMaximumCacheSize member function. 00126 // tiles. Tiles are cached using a first in first out algorithm. 00127 virtual void setCacheSizeInTiles (uInt howManyTiles); 00128 00129 // Clears and frees up the caches, but the maximum allowed cache size is 00130 // unchanged from when setCacheSize was called 00131 virtual void clearCache(); 00132 00133 // Report on cache success. 00134 virtual void showCacheStatistics (ostream& os) const; 00135 00136 // Handle deletion of the region by deleting the associated table. 00137 virtual void handleDelete(); 00138 00139 // Handle renaming the region by renaming the associated table. 00140 // If overwrite=False, an exception will be thrown if a table with the 00141 // new name already exists. 00142 virtual void handleRename (const String& newName, Bool overwrite); 00143 00144 // Handle the (un)locking. 00145 // <group> 00146 virtual Bool lock (FileLocker::LockType, uInt nattempts); 00147 virtual void unlock(); 00148 virtual Bool hasLock (FileLocker::LockType) const; 00149 // </group> 00150 00151 // Resynchronize the PagedArray object with the lattice file. 00152 // This function is only useful if no read-locking is used, ie. 00153 // if the table lock option is UserNoReadLocking or AutoNoReadLocking. 00154 // In that cases the table system does not acquire a read-lock, thus 00155 // does not synchronize itself automatically. 00156 virtual void resync(); 00157 00158 // Flush the data (but do not unlock). 00159 virtual void flush(); 00160 00161 // Temporarily close the lattice. 00162 // It will be reopened automatically on the next access. 00163 virtual void tempClose(); 00164 00165 // Explicitly reopen the temporarily closed lattice. 00166 virtual void reopen(); 00167 00168 // Get the class name (to store in the record). 00169 static String className(); 00170 00171 // Region type. Returns class name. 00172 virtual String type() const; 00173 00174 // Convert the (derived) object to a record. 00175 virtual TableRecord toRecord (const String& tableName) const; 00176 00177 // Convert correct object from a record. 00178 static LCPagedMask* fromRecord (const TableRecord&, 00179 const String& tablename); 00180 00181 // An LCPagedMask is writable if the underlying PagedArray is. 00182 virtual Bool isWritable() const; 00183 00184 protected: 00185 // Construct another LCPagedMask (for e.g. another lattice) by moving 00186 // this one. It recalculates the bounding mask. 00187 // A positive translation value indicates "to right". 00188 virtual LCRegion* doTranslate (const Vector<Float>& translateVector, 00189 const IPosition& newLatticeShape) const; 00190 00191 private: 00192 // Create the object from a record (for an existing mask). 00193 LCPagedMask (PagedArray<Bool>& mask, 00194 const IPosition& blc, 00195 const IPosition& latticeShape); 00196 00197 00198 LCBox itsBox; 00199 PagedArray<Bool> itsMask; 00200 }; 00201 00202 00203 00204 } //# NAMESPACE CASACORE - END 00205 00206 #endif