00001 //# PagedArrIter.h: A concrete iterator for use with PagedArray's. 00002 //# Copyright (C) 1994,1995,1996,1997,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_PAGEDARRITER_H 00029 #define LATTICES_PAGEDARRITER_H 00030 00031 //# Includes 00032 #include <casacore/casa/aips.h> 00033 #include <casacore/lattices/Lattices/LatticeIterInterface.h> 00034 #include <casacore/lattices/Lattices/PagedArray.h> 00035 00036 00037 namespace casacore { //# NAMESPACE CASACORE - BEGIN 00038 00039 // <summary> 00040 // A read/write Lattice iterator for PagedArrays. 00041 // </summary> 00042 00043 // <use visibility=local> 00044 00045 // <reviewed reviewer="Peter Barnes" date="1999/10/30" tests="tLatticeIterator.cc" demos="dPagedArray.cc"> 00046 // </reviewed> 00047 00048 // <prerequisite> 00049 // <li> <linkto class="PagedArray">PagedArray</linkto> 00050 // <li> <linkto class="LatticeIterator">LatticeIterator</linkto> 00051 // <li> <linkto class="LatticeIterInterface">LatticeIterInterface 00052 // </linkto> 00053 // <li> letter/envelope schemes, eg. Coplien, "Advanced C++", ch 5.5 00054 // </prerequisite> 00055 00056 // <etymology> 00057 // The PagedArrIter class name is a contraction of Paged Array Iterator 00058 // and reflects its role as the methods for iterating through Lattices which 00059 // are resident on disk. 00060 // </etymology> 00061 00062 // <synopsis> 00063 // This class is not meant for general use. Instead class 00064 // <linkto class="LatticeIterator">LatticeIterator</linkto> should be used 00065 // to iterate through a <src>PagedArray</src> or any other 00066 // <linkto class="Lattice">Lattice</linkto> object 00067 // (like a <linkto class="ArrayLattice">ArrayLattice</linkto>). 00068 // <p> 00069 // PagedArrIter is derived from LatticeIterInterface and implements 00070 // the iterator for a <linkto class=PagedArray>PagedArray</linkto> 00071 // object. This iterator is somewhat special because it sets the 00072 // PagedArray cache size at the start of an iteration. 00073 // </synopsis> 00074 00075 // <motivation> 00076 // For for each derivation of Lattice to make as efficient an iterator as 00077 // possible. 00078 // The letter/envelope scheme allowed us to hide the special bits in 00079 // classes like the one you see here. 00080 // </motivation> 00081 00082 // <templating arg=T> 00083 // <li> Restricted to the type of the PagedArray argument in the 00084 // constructors 00085 // </templating> 00086 00087 //# <todo asof="1997/01/31"> 00088 //# <li> 00089 //# </todo> 00090 00091 00092 template <class T> class PagedArrIter : public LatticeIterInterface<T> 00093 { 00094 friend class PagedArray<T>; 00095 00096 //# Make members of parent class known. 00097 protected: 00098 using LatticeIterInterface<T>::rewriteData; 00099 using LatticeIterInterface<T>::itsNavPtr; 00100 00101 protected: 00102 // Construct the Iterator with the supplied data, and iteration strategy 00103 PagedArrIter (const PagedArray<T>& data, const LatticeNavigator& method, 00104 Bool useRef); 00105 00106 // The copy constructor uses reference sematics for the PagedArray and 00107 // copy semantics for the cursor and Navigator. This way the newly 00108 // constructed PagedArrIter can independently iterate through the same 00109 // data set. (with the same cursor shape etc.) 00110 PagedArrIter (const PagedArrIter<T>& other); 00111 00112 // Destructor (cleans up dangling references and releases cursor memory) 00113 virtual ~PagedArrIter(); 00114 00115 // The assignment operator uses reference sematics for the PagedArray and 00116 // copy semantics for the cursor and Navigator. This way the 00117 // PagedArrIter objects share the same data set but independently iterate 00118 // with cursors of the same size. 00119 PagedArrIter<T>& operator= (const PagedArrIter<T>& other); 00120 00121 // Clone the object. 00122 virtual LatticeIterInterface<T>* clone() const; 00123 00124 private: 00125 // Setup the cache in the tiled storage manager. 00126 void setupTileCache(); 00127 00128 00129 // reference to the PagedArray 00130 PagedArray<T> itsData; 00131 }; 00132 00133 00134 00135 } //# NAMESPACE CASACORE - END 00136 00137 #ifndef CASACORE_NO_AUTO_TEMPLATES 00138 #include <casacore/lattices/Lattices/PagedArrIter.tcc> 00139 #endif //# CASACORE_NO_AUTO_TEMPLATES 00140 #endif