casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
TableIterProxy.h
Go to the documentation of this file.
00001 //# TableIterProxy.h: Proxy for table iterator access
00002 //# Copyright (C) 1994,1995,1996,1999,2005
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: TableIterProxy.h 20551 2009-03-25 00:11:33Z Malte.Marquarding $
00027 
00028 #ifndef TABLES_TABLEITERPROXY_H
00029 #define TABLES_TABLEITERPROXY_H
00030 
00031 
00032 //# Includes
00033 #include <casa/aips.h>
00034 #include <tables/Tables/TableIter.h>
00035 
00036 namespace casa { //# NAMESPACE CASA - BEGIN
00037 
00038 //# Forward Declarations
00039 class TableProxy;
00040 
00041 
00042 // <summary>
00043 // Proxy for table iterator access.
00044 // </summary>
00045 
00046 // <use visibility=export>
00047 
00048 // <reviewed reviewer="Paul Shannon" date="1995/09/15" tests="tgtable.g" demos="">
00049 // </reviewed>
00050 
00051 // <prerequisite>
00052 //# Classes you should understand before using this one.
00053 //   <li> class TableIterator
00054 // </prerequisite>
00055 
00056 // <etymology>
00057 // TableIterProxy holds a TableIterator object for the table
00058 // glish client.
00059 // </etymology>
00060 
00061 // <synopsis> 
00062 // TableIterProxy gives access to the table iterator functionality.
00063 // It is primarily meant to be used in classes that wrap access to it
00064 // from scripting languages (like Glish and Python).
00065 // However, it can also be used directly from other C++ code.
00066 //
00067 // A TableIterProxy object is usually created by class
00068 // <linkto class=TableProxy>TableProxy</linkto>.
00069 // </synopsis>
00070 
00071 // <example>
00072 // <srcblock>
00073 //    // Get a table proxy.
00074 //    TableProxy proxy("sometable");
00075 //    Vector<String> columns(1, "SOMECOL");
00076 //    TableIterProxy tgi (proxy, columns, "a", "q");
00077 //    TableProxy subTable;
00078 //    // Iterate through the table.
00079 //    while (tgi.next (subTable)) {
00080 //       ..use Table object subTable.table()
00081 //    }
00082 // </srcblock>
00083 // </example>
00084 
00085 class TableIterProxy
00086 {
00087 public:
00088   // Default constructor initializes to not open.
00089   // This constructor is only needed for the Block container.
00090   TableIterProxy();
00091 
00092   // Construct for the given table column(s).
00093   // Order and sortType are case-insentive strings and only the first
00094   // character in it is important.
00095   // order[0]=a means ascending; d means descending.
00096   // sortType[0]=q means quicksort, i means insertion sort,
00097   //             n means nosort, otherwise heapsort.
00098   TableIterProxy (const TableProxy& tab, const Vector<String>& columns,
00099                   const String& order, const String& sortType);
00100 
00101   // Copy constructor (copy semantics).
00102   TableIterProxy (const TableIterProxy&);
00103 
00104   ~TableIterProxy();
00105 
00106   // Assignment (copy semantics).
00107   TableIterProxy& operator= (const TableIterProxy&);
00108 
00109   // Is the internal iterator object null?
00110   Bool isNull() const
00111     { return iter_p.isNull(); }
00112 
00113   // Get the TableIterator object.
00114   const TableIterator& iterator() const
00115     { return iter_p; }
00116 
00117   // Get the next subtable and return it in the TableProxy argument.
00118   // When no more subtables are available, it returns False.
00119   Bool nextPart (TableProxy& table);
00120 
00121   // Iterate to the next part (for Python use).
00122   // An IterError exception is thrown at the end of the loop.
00123   TableProxy next();
00124 
00125   // Reset the iterator (for Python use).
00126   void reset();
00127 
00128 
00129 private:
00130   TableIterator iter_p;
00131   Bool          firstTime_p;           //# True = first time
00132 };
00133 
00134 
00135 } //# NAMESPACE CASA - END
00136 
00137 
00138 #endif