casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
LCPagedMask.h
Go to the documentation of this file.
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: LCPagedMask.h 18093 2004-11-30 17:51:10Z ddebonis $
00027 
00028 #ifndef LATTICES_LCPAGEDMASK_H
00029 #define LATTICES_LCPAGEDMASK_H
00030 
00031 
00032 //# Includes
00033 #include <lattices/Lattices/LCBox.h>
00034 #include <lattices/Lattices/PagedArray.h>
00035 
00036 
00037 namespace casa { //# NAMESPACE CASA - BEGIN
00038 
00039 // <summary>
00040 // Class to define a rectangular mask as a region
00041 // </summary>
00042 
00043 // <use visibility=export>
00044 
00045 // <reviewed reviewer="" date="" tests="">
00046 // </reviewed>
00047 
00048 // <prerequisite>
00049 //   <li> <linkto class=LCRegion>LCRegion</linkto>
00050 // </prerequisite>
00051 
00052 // <synopsis> 
00053 // The LCPagedMask class is a specialization of class
00054 // <linkto class=LCRegion>LCRegion</linkto>.
00055 // </synopsis> 
00056 
00057 // <example>
00058 // <srcblock>
00059 // </srcblock>
00060 // </example>
00061 
00062 // <todo asof="1997/11/11">
00063 // </todo>
00064 
00065 class LCPagedMask: public LCRegionSingle
00066 {
00067 public:
00068     LCPagedMask();
00069 
00070     // Construct a PagedMask object for (part of) a lattice.
00071     // The box defines the position of the mask.
00072     // The default mask shape is the lattice shape.
00073     // <group>
00074     LCPagedMask (const TiledShape& latticeShape, const String& tableName);
00075     LCPagedMask (const TiledShape& maskShape, const LCBox& box,
00076                  const String& tableName);
00077     LCPagedMask (PagedArray<Bool>& mask, const LCBox& box);
00078     // </group>
00079 
00080     // Copy constructor (copy semantics).
00081     LCPagedMask (const LCPagedMask& other);
00082 
00083     // Destructor
00084     virtual ~LCPagedMask();
00085 
00086     // Assignment (reference semantics).
00087     LCPagedMask& operator= (const LCPagedMask& other);
00088 
00089     // Comparison
00090     virtual Bool operator==(const LCRegion& other) const;
00091 
00092     // Make a copy of the derived object.
00093     virtual LCRegion* cloneRegion() const;
00094 
00095     // This function is used by the LatticeIterator class to generate an
00096     // iterator of the correct type for this Lattice. Not recommended
00097     // for general use. 
00098     virtual LatticeIterInterface<Bool>* makeIter
00099                                 (const LatticeNavigator& navigator,
00100                                  Bool useRef) const;
00101 
00102     // Returns the maximum recommended number of pixels for a cursor.
00103     // This is the number of pixels in a tile. 
00104     virtual uInt advisedMaxPixels() const;
00105 
00106     // Help the user pick a cursor for most efficient access.
00107     virtual IPosition doNiceCursorShape (uInt maxPixels) const;
00108 
00109     // Maximum size - not necessarily all used. In pixels.
00110     virtual uInt maximumCacheSize() const;
00111 
00112     // Set the maximum (allowed) cache size as indicated.
00113     virtual void setMaximumCacheSize (uInt howManyPixels);
00114 
00115     // Set the cache size as to "fit" the indicated path.
00116     virtual void setCacheSizeFromPath (const IPosition& sliceShape,
00117                                        const IPosition& windowStart,
00118                                        const IPosition& windowLength,
00119                                        const IPosition& axisPath);
00120     
00121     // Set the actual cache size for this Array to be be big enough for the
00122     // indicated number of tiles. This cache is not shared with PagedArrays
00123     // in other rows and is always clipped to be less than the maximum value
00124     // set using the setMaximumCacheSize member function.
00125     // tiles. Tiles are cached using a first in first out algorithm. 
00126     virtual void setCacheSizeInTiles (uInt howManyTiles);
00127 
00128     // Clears and frees up the caches, but the maximum allowed cache size is 
00129     // unchanged from when setCacheSize was called
00130     virtual void clearCache();
00131 
00132     // Report on cache success.
00133     virtual void showCacheStatistics (ostream& os) const;
00134 
00135     // Handle deletion of the region by deleting the associated table.
00136     virtual void handleDelete();
00137 
00138     // Handle renaming the region by renaming the associated table.
00139     // If overwrite=False, an exception will be thrown if a table with the
00140     // new name already exists.
00141     virtual void handleRename (const String& newName, Bool overwrite);
00142 
00143     // Handle the (un)locking.
00144     // <group>
00145     virtual Bool lock (FileLocker::LockType, uInt nattempts);
00146     virtual void unlock();
00147     virtual Bool hasLock (FileLocker::LockType) const;
00148     // </group>
00149 
00150     // Resynchronize the PagedArray object with the lattice file.
00151     // This function is only useful if no read-locking is used, ie.
00152     // if the table lock option is UserNoReadLocking or AutoNoReadLocking.
00153     // In that cases the table system does not acquire a read-lock, thus
00154     // does not synchronize itself automatically.
00155     virtual void resync();
00156 
00157     // Flush the data (but do not unlock).
00158     virtual void flush();
00159 
00160     // Temporarily close the lattice.
00161     // It will be reopened automatically on the next access.
00162     virtual void tempClose();
00163 
00164     // Explicitly reopen the temporarily closed lattice.
00165     virtual void reopen();
00166 
00167     // Get the class name (to store in the record).
00168     static String className();
00169 
00170     // Region type. Returns class name.
00171     virtual String type() const;
00172 
00173     // Convert the (derived) object to a record.
00174     virtual TableRecord toRecord (const String& tableName) const;
00175 
00176     // Convert correct object from a record.
00177     static LCPagedMask* fromRecord (const TableRecord&,
00178                                     const String& tablename);
00179 
00180     // An LCPagedMask is writable if the underlying PagedArray is.
00181     virtual Bool isWritable() const;
00182 
00183 protected:
00184     // Construct another LCPagedMask (for e.g. another lattice) by moving
00185     // this one. It recalculates the bounding mask.
00186     // A positive translation value indicates "to right".
00187     virtual LCRegion* doTranslate (const Vector<Float>& translateVector,
00188                                    const IPosition& newLatticeShape) const;
00189 
00190 private:
00191     // Create the object from a record (for an existing mask).
00192     LCPagedMask (PagedArray<Bool>& mask,
00193                  const IPosition& blc,
00194                  const IPosition& latticeShape);
00195 
00196 
00197     LCBox            itsBox;
00198     PagedArray<Bool> itsMask;
00199 };
00200 
00201 
00202 
00203 } //# NAMESPACE CASA - END
00204 
00205 #endif