casacore
BaseTabIter.h
Go to the documentation of this file.
1 //# BaseTabIter.h: Base class for table iterator
2 //# Copyright (C) 1994,1995,1996,1997,1999
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 TABLES_BASETABITER_H
29 #define TABLES_BASETABITER_H
30 
31 //# Includes
32 #include <casacore/casa/aips.h>
33 #include <casacore/tables/Tables/Table.h>
34 #include <casacore/casa/Utilities/Compare.h>
35 #include <casacore/casa/Containers/Block.h>
36 
37 namespace casacore { //# NAMESPACE CASACORE - BEGIN
38 
39 //# Forward Declarations
40 class TableColumn;
41 class RefTable;
42 class String;
43 
44 
45 // <summary>
46 // Base class for table iterator
47 // </summary>
48 
49 // <use visibility=local>
50 
51 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
52 // </reviewed>
53 
54 // <prerequisite>
55 //# Classes you should understand before using this one.
56 // <li> BaseTable
57 // <li> TableIterator
58 // </prerequisite>
59 
60 // <etymology>
61 // BaseTableIterator is the base class for the classes doing
62 // the actual iterating through a table.
63 // </etymology>
64 
65 // <synopsis>
66 // BaseTableIterator is the base class for the table iterators.
67 // It is a letter class of the envelope TableIterator.
68 // Currently there are no classes derived from BaseTableIterator,
69 // since it can do all the work itself. However, in the future
70 // this need not to be true anymore.
71 //
72 // BaseTableIterator iterates by sorting the table in the required
73 // order and then creating a RefTable for each step containing the
74 // rows for that iteration step. Each iteration step assembles the
75 // rows with equal key values.
76 // </synopsis>
77 
78 //# <todo asof="$DATE:$">
79 //# A List of bugs, limitations, extensions or planned refinements.
80 //# </todo>
81 
82 
84 {
85 public:
86 
87  // Create the table iterator to iterate through the given
88  // columns in the given order. The given compare objects
89  // will be used for the sort and to compare if values are equal.
90  // If a compare object is null, the default ObjCompare<T> will be used.
91  BaseTableIterator (BaseTable*, const Block<String>& columnNames,
93  const Block<Int>& orders,
94  int option);
95 
96  // Clone this iterator.
98 
99  virtual ~BaseTableIterator();
100 
101  // Reset the iterator (i.e. restart iteration).
102  virtual void reset();
103 
104  // Return the next group.
105  virtual BaseTable* next();
106 
107  virtual void copyState(const BaseTableIterator &);
108 
109  // Report Name of slowest sort column that changed (according to the
110  // comparison function) to terminate the most recent call to next()
111  // Enables clients to sense iteration boundary properties
112  // and organize associated iterations
113  inline const String& keyChangeAtLastNext() const { return keyChangeAtLastNext_p; };
114 
115 protected:
116  BaseTable* sortTab_p; //# Table sorted in iteration order
117  uInt lastRow_p; //# last row used from reftab
118  uInt nrkeys_p; //# nr of columns in group
119  String keyChangeAtLastNext_p; //# name of column that terminated most recent next()
120  PtrBlock<BaseColumn*> colPtr_p; //# pointer to column objects
121  Block<CountedPtr<BaseCompare> > cmpObj_p; //# comparison object per column
122 
123  // Copy constructor (to be used by clone)
125 
126 private:
127  // Assignment is not needed, because the assignment operator in
128  // the envelope class TableIterator has reference semantics.
129  // Declaring it private, makes it unusable.
131 
132  Block<void*> lastVal_p; //# last value per column
133  Block<void*> curVal_p; //# current value per column
134 };
135 
136 
137 
138 } //# NAMESPACE CASACORE - END
139 
140 #endif
casacore::BaseTableIterator
Definition: BaseTabIter.h:84
casacore::BaseTableIterator::operator=
BaseTableIterator & operator=(const BaseTableIterator &)
Assignment is not needed, because the assignment operator in the envelope class TableIterator has ref...
casacore::PtrBlock
A drop-in replacement for Block<T*>.
Definition: Block.h:814
casacore::BaseTableIterator::curVal_p
Block< void * > curVal_p
Definition: BaseTabIter.h:133
casacore::BaseTableIterator::BaseTableIterator
BaseTableIterator(const BaseTableIterator &)
Copy constructor (to be used by clone)
casacore::CountedPtr
Referenced counted pointer for constant data.
Definition: CountedPtr.h:81
casacore::BaseTableIterator::BaseTableIterator
BaseTableIterator(BaseTable *, const Block< String > &columnNames, const Block< CountedPtr< BaseCompare > > &, const Block< Int > &orders, int option)
Create the table iterator to iterate through the given columns in the given order.
casacore::BaseTable
Definition: BaseTable.h:104
casacore::BaseTableIterator::reset
virtual void reset()
Reset the iterator (i.e.
casacore::BaseTableIterator::lastRow_p
uInt lastRow_p
Definition: BaseTabIter.h:117
casacore::BaseTableIterator::clone
BaseTableIterator * clone() const
Clone this iterator.
casacore::BaseTableIterator::lastVal_p
Block< void * > lastVal_p
Definition: BaseTabIter.h:132
casacore::BaseTableIterator::nrkeys_p
uInt nrkeys_p
Definition: BaseTabIter.h:118
casacore::BaseTableIterator::sortTab_p
BaseTable * sortTab_p
Definition: BaseTabIter.h:113
casacore::uInt
unsigned int uInt
Definition: aipstype.h:51
casacore
this file contains all the compiler specific defines
Definition: mainpage.dox:28
casacore::BaseTableIterator::keyChangeAtLastNext
const String & keyChangeAtLastNext() const
Report Name of slowest sort column that changed (according to the comparison function) to terminate t...
Definition: BaseTabIter.h:113
casacore::BaseTableIterator::keyChangeAtLastNext_p
String keyChangeAtLastNext_p
Definition: BaseTabIter.h:119
casacore::BaseTableIterator::next
virtual BaseTable * next()
Return the next group.
casacore::BaseTableIterator::cmpObj_p
Block< CountedPtr< BaseCompare > > cmpObj_p
Definition: BaseTabIter.h:121
casacore::BaseTableIterator::copyState
virtual void copyState(const BaseTableIterator &)
casacore::String
String: the storage and methods of handling collections of characters.
Definition: String.h:223
casacore::Block
simple 1-D array
Definition: Block.h:200
casacore::BaseTableIterator::colPtr_p
PtrBlock< BaseColumn * > colPtr_p
Definition: BaseTabIter.h:120
casacore::BaseTableIterator::~BaseTableIterator
virtual ~BaseTableIterator()