casa
$Rev:20696$
|
00001 //# BaseTabIter.h: Base class for table iterator 00002 //# Copyright (C) 1994,1995,1996,1997,1999 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: BaseTabIter.h 20997 2010-11-17 07:05:29Z gervandiepen $ 00027 00028 #ifndef TABLES_BASETABITER_H 00029 #define TABLES_BASETABITER_H 00030 00031 //# Includes 00032 #include <casa/aips.h> 00033 #include <tables/Tables/Table.h> 00034 #include <casa/Utilities/Compare.h> 00035 #include <casa/Containers/Block.h> 00036 00037 namespace casa { //# NAMESPACE CASA - BEGIN 00038 00039 //# Forward Declarations 00040 class TableColumn; 00041 class RefTable; 00042 class String; 00043 00044 00045 // <summary> 00046 // Base class for table iterator 00047 // </summary> 00048 00049 // <use visibility=local> 00050 00051 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests=""> 00052 // </reviewed> 00053 00054 // <prerequisite> 00055 //# Classes you should understand before using this one. 00056 // <li> BaseTable 00057 // <li> TableIterator 00058 // </prerequisite> 00059 00060 // <etymology> 00061 // BaseTableIterator is the base class for the classes doing 00062 // the actual iterating through a table. 00063 // </etymology> 00064 00065 // <synopsis> 00066 // BaseTableIterator is the base class for the table iterators. 00067 // It is a letter class of the envelope TableIterator. 00068 // Currently there are no classes derived from BaseTableIterator, 00069 // since it can do all the work itself. However, in the future 00070 // this need not to be true anymore. 00071 // 00072 // BaseTableIterator iterates by sorting the table in the required 00073 // order and then creating a RefTable for each step containing the 00074 // rows for that iteration step. Each iteration step assembles the 00075 // rows with equal key values. 00076 // </synopsis> 00077 00078 //# <todo asof="$DATE:$"> 00079 //# A List of bugs, limitations, extensions or planned refinements. 00080 //# </todo> 00081 00082 00083 class BaseTableIterator 00084 { 00085 public: 00086 00087 // Create the table iterator to iterate through the given 00088 // columns in the given order. The given compare objects 00089 // will be used for the sort and to compare if values are equal. 00090 // If a comare object is null, the default ObjCompare<T> will be used. 00091 BaseTableIterator (BaseTable*, const Block<String>& columnNames, 00092 const Block<CountedPtr<BaseCompare> >&, 00093 const Block<Int>& orders, 00094 int option); 00095 00096 // Clone this iterator. 00097 BaseTableIterator* clone() const; 00098 00099 virtual ~BaseTableIterator(); 00100 00101 // Reset the iterator (i.e. restart iteration). 00102 virtual void reset(); 00103 00104 // Return the next group. 00105 virtual BaseTable* next(); 00106 00107 protected: 00108 BaseTable* sortTab_p; //# Table sorted in iteration order 00109 uInt lastRow_p; //# last row used from reftab 00110 uInt nrkeys_p; //# nr of columns in group 00111 Block<void*> lastVal_p; //# last value per column 00112 Block<void*> curVal_p; //# current value per column 00113 PtrBlock<BaseColumn*> colPtr_p; //# pointer to column objects 00114 Block<CountedPtr<BaseCompare> > cmpObj_p; //# comparison object per column 00115 00116 // Copy constructor (to be used by clone) 00117 BaseTableIterator (const BaseTableIterator&); 00118 00119 private: 00120 // Assignment is not needed, because the assignment operator in 00121 // the envelope class TableIterator has reference semantics. 00122 // Declaring it private, makes it unusable. 00123 BaseTableIterator& operator= (const BaseTableIterator&); 00124 }; 00125 00126 00127 00128 } //# NAMESPACE CASA - END 00129 00130 #endif