casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TableIterProxy.h
Go to the documentation of this file.
1 //# TableIterProxy.h: Proxy for table iterator access
2 //# Copyright (C) 1994,1995,1996,1999,2005
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_TABLEITERPROXY_H
29 #define TABLES_TABLEITERPROXY_H
30 
31 
32 //# Includes
33 #include <casacore/casa/aips.h>
36 
37 namespace casacore { //# NAMESPACE CASACORE - BEGIN
38 
39 //# Forward Declarations
40 class TableProxy;
41 
42 
43 // <summary>
44 // Proxy for table iterator access.
45 // </summary>
46 
47 // <use visibility=export>
48 
49 // <reviewed reviewer="Paul Shannon" date="1995/09/15" tests="tgtable.g" demos="">
50 // </reviewed>
51 
52 // <prerequisite>
53 //# Classes you should understand before using this one.
54 // <li> class TableIterator
55 // </prerequisite>
56 
57 // <etymology>
58 // TableIterProxy holds a TableIterator object for the table
59 // glish client.
60 // </etymology>
61 
62 // <synopsis>
63 // TableIterProxy gives access to the table iterator functionality.
64 // It is primarily meant to be used in classes that wrap access to it
65 // from scripting languages (like Glish and Python).
66 // However, it can also be used directly from other C++ code.
67 //
68 // A TableIterProxy object is usually created by class
69 // <linkto class=TableProxy>TableProxy</linkto>.
70 // </synopsis>
71 
72 // <example>
73 // <srcblock>
74 // // Get a table proxy.
75 // TableProxy proxy("sometable");
76 // Vector<String> columns(1, "SOMECOL");
77 // TableIterProxy tgi (proxy, columns, "a", "q");
78 // TableProxy subTable;
79 // // Iterate through the table.
80 // while (tgi.next (subTable)) {
81 // ..use Table object subTable.table()
82 // }
83 // </srcblock>
84 // </example>
85 
87 {
88 public:
89  // Default constructor initializes to not open.
90  // This constructor is only needed for the Block container.
92 
93  // Construct iterator for the given table column(s).
94  // Order and sortType are case-insentive strings and only the first
95  // character in it is important.
96  // <br>order[0]=a means ascending; d means descending.
97  // <br>sortType[0]=q means quicksort, i means insertion sort,
98  // n means nosort, h means heapsort, otherwise parsort
99  // <br>For each column an iteration interval can be given making it possible
100  // to iterate in e.g. time chunks of 1 minute. Not given or zero means
101  // no interval is given for that column, thus a normal comparison is done.
102  // It can only be used for numerical columns (not complex).
103  // However, if for a string column the interbval is set to non-zero, it
104  // means that case-insensitive comparison will be used.
105  TableIterProxy (const TableProxy& tab, const Vector<String>& columns,
106  const String& order, const String& sortType,
107  const Vector<Double>& intervals = Vector<Double>());
108 
109  // Copy constructor (copy semantics).
111 
112  ~TableIterProxy();
113 
114  // Assignment (copy semantics).
116 
117  // Is the internal iterator object null?
118  Bool isNull() const
119  { return iter_p.isNull(); }
120 
121  // Get the TableIterator object.
122  const TableIterator& iterator() const
123  { return iter_p; }
124 
125  // Get the next subtable and return it in the TableProxy argument.
126  // When no more subtables are available, it returns False.
127  Bool nextPart (TableProxy& table);
128 
129  // Iterate to the next part (for Python use).
130  // An IterError exception is thrown at the end of the loop.
131  TableProxy next();
132 
133  // Reset the iterator (for Python use).
134  void reset();
135 
136 
137 private:
138  // Make an iterator where iteration intervals may have been given.
139  void makeStepIter (const Table& tab,
140  const Block<String>& columns,
141  const Vector<Double>& iterSteps,
142  TableIterator::Order order,
143  TableIterator::Option sortType);
144 
145  //# Data members
147  Bool firstTime_p; //# True = first time
148 };
149 
150 
151 } //# NAMESPACE CASACORE - END
152 
153 
154 #endif
void reset()
Reset the iterator (for Python use).
A 1-D Specialization of the Array class.
Proxy for table iterator access.
Main interface class to a read/write table.
Definition: Table.h:153
Iterate through a Table.
Definition: TableIter.h:117
TableIterProxy & operator=(const TableIterProxy &)
Assignment (copy semantics).
High-level interface to tables.
Definition: TableProxy.h:103
Order
Define the possible iteration orders.
Definition: TableIter.h:122
TableIterProxy()
Default constructor initializes to not open.
Option
Define the possible sorts.
Definition: TableIter.h:124
TableProxy next()
Iterate to the next part (for Python use).
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
Bool isNull() const
Is the internal iterator object null?
Bool isNull() const
Test if the object is null, i.e.
Definition: TableIter.h:188
void makeStepIter(const Table &tab, const Block< String > &columns, const Vector< Double > &iterSteps, TableIterator::Order order, TableIterator::Option sortType)
Make an iterator where iteration intervals may have been given.
simple 1-D array
Bool nextPart(TableProxy &table)
Get the next subtable and return it in the TableProxy argument.
String: the storage and methods of handling collections of characters.
Definition: String.h:223
const TableIterator & iterator() const
Get the TableIterator object.
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42