casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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>
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 comare 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.
97  BaseTableIterator* clone() const;
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 to
110  // 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
virtual void reset()
Reset the iterator (i.e.
Block< void * > lastVal_p
Definition: BaseTabIter.h:132
Block< void * > curVal_p
Definition: BaseTabIter.h:133
BaseTableIterator * clone() const
Clone this iterator.
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.
Base class for table iterator.
Definition: BaseTabIter.h:83
Referenced counted pointer for constant data.
Definition: VisModelData.h:42
Abstract base class for tables.
Definition: BaseTable.h:103
virtual BaseTable * next()
Return the next group.
Block< CountedPtr< BaseCompare > > cmpObj_p
Definition: BaseTabIter.h:121
A drop-in replacement for Block&lt;T*&gt;.
Definition: WProjectFT.h:54
virtual void copyState(const BaseTableIterator &)
PtrBlock< BaseColumn * > colPtr_p
Definition: BaseTabIter.h:120
simple 1-D array
String: the storage and methods of handling collections of characters.
Definition: String.h:223
BaseTableIterator & operator=(const BaseTableIterator &)
Assignment is not needed, because the assignment operator in the envelope class TableIterator has ref...
const String & keyChangeAtLastNext() const
Report Name of slowest sort column that changed to terminate the most recent call to next() Enables c...
Definition: BaseTabIter.h:113
unsigned int uInt
Definition: aipstype.h:51
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42