casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
TableIndexProxy.h
Go to the documentation of this file.
00001 //# TableIndexProxy.h: Proxy for table index access
00002 //# Copyright (C) 2002,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: TableIndexProxy.h 20551 2009-03-25 00:11:33Z Malte.Marquarding $
00027 
00028 #ifndef TABLES_TABLEINDEXPROXY_H
00029 #define TABLES_TABLEINDEXPROXY_H
00030 
00031 
00032 //# Includes
00033 #include <casa/aips.h>
00034 #include <tables/Tables/ColumnsIndex.h>
00035 #include <tables/Tables/ColumnsIndexArray.h>
00036 
00037 
00038 namespace casa { //# NAMESPACE CASA - BEGIN
00039 
00040 //# Forward Declarations
00041 class TableProxy;
00042 
00043 
00044 // <summary>
00045 // Proxy for table index access.
00046 // </summary>
00047 
00048 // <use visibility=export>
00049 
00050 // <reviewed reviewer="Paul Shannon" date="1995/09/15" tests="tgtable.g" demos="">
00051 // </reviewed>
00052 
00053 // <prerequisite>
00054 //# Classes you should understand before using this one.
00055 //   <li> class ColumnsIndex
00056 //   <li> class ColumnsIndexArray
00057 // </prerequisite>
00058 
00059 // <synopsis> 
00060 // TableIndexProxy gives access to indexed access to tables, both for
00061 // scalar columns and array columns.
00062 // It is primarily meant to be used in classes that wrap access to it
00063 // from scripting languages (like Glish and Python).
00064 // However, it can also be used directly from other C++ code.
00065 //
00066 // A TableIndexProxy object is usually created by class
00067 // <linkto class=TableProxy>TableProxy</linkto>.
00068 // </synopsis>
00069 
00070 class TableIndexProxy
00071 {
00072 public:
00073   // Construct for the given columns in the table.
00074   TableIndexProxy (const TableProxy& table,
00075                    const Vector<String>& columnNames, Bool noSort);
00076 
00077   // Copy constructor.
00078   TableIndexProxy (const TableIndexProxy&);
00079 
00080   ~TableIndexProxy();
00081 
00082   // Are all keys in the index unique?
00083   Bool isUnique() const;
00084 
00085   // Return the names of the columns forming the index.
00086   Vector<String> columnNames() const;
00087 
00088   // Something has changed in the table, so the index has to be recreated.
00089   // An empty vector means that all columns have changed, otherwise
00090   // only the given columns.
00091   void setChanged (const Vector<String>& columnNames);
00092 
00093   // Find the row number matching the key. All keys have to be unique,
00094   // otherwise an exception is thrown.
00095   // If no match is found, -1 is returned.
00096   Int getRowNumber (const Record& key);
00097 
00098   // Find the row numbers matching the key. It should be used instead
00099   // of <src>getRowNumber</src> if the same key can exist multiple times.
00100   Vector<Int> getRowNumbers (const Record& key);
00101 
00102   // Find the row numbers matching the key range. The boolean arguments
00103   // tell if the lower and upper key are part of the range.
00104   Vector<Int> getRowNumbersRange (const Record& lower, const Record& upper,
00105                                   Bool lowerInclusive, Bool upperInclusive);
00106 
00107 private:
00108   // Assignment is forbidden.
00109   TableIndexProxy& operator= (const TableIndexProxy&);
00110 
00111 
00112   ColumnsIndex*      scaIndex_p;
00113   ColumnsIndexArray* arrIndex_p;
00114 };
00115 
00116 
00117 } //# NAMESPACE CASA - END
00118 
00119 
00120 #endif