casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Table.h
Go to the documentation of this file.
00001 //# Table.h: Main interface classes to tables
00002 //# Copyright (C) 1994,1995,1996,1997,1998,1999,2000,2001,2002,2003
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 receied 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: Table.h 21298 2012-12-07 14:53:03Z gervandiepen $
00027 
00028 #ifndef TABLES_TABLE_H
00029 #define TABLES_TABLE_H
00030 
00031 
00032 //# Includes
00033 #include <casa/aips.h>
00034 #include <tables/Tables/BaseTable.h>
00035 #include <tables/Tables/TableLock.h>
00036 #include <tables/Tables/TSMOption.h>
00037 #include <casa/Utilities/DataType.h>
00038 #include <casa/Utilities/Sort.h>
00039 
00040 namespace casa { //# NAMESPACE CASA - BEGIN
00041 
00042 //# Forward Declarations
00043 class SetupNewTable;
00044 class TableDesc;
00045 class ColumnDesc;
00046 class TableRecord;
00047 class Record;
00048 class TableExprNode;
00049 class DataManager;
00050 class IPosition;
00051 template<class T> class Vector;
00052 template<class T> class Block;
00053 template<class T> class CountedPtr;
00054 
00055 
00056 // <summary>
00057 // Main interface class to a read/write table
00058 // </summary>
00059 
00060 // <use visibility=export>
00061 
00062 // <reviewed reviewer="TPPR" date="08.11.94" tests="tTable.cc">
00063 // </reviewed>
00064 
00065 // <prerequisite>
00066 //# Classes you should understand before using this one.
00067 //   <li> <linkto class=SetupNewTable>SetupNewTable</linkto>
00068 //   <li> <linkto class=TableDesc>TableDesc</linkto>
00069 //   <li> <linkto class=TableColumn>TableColumn</linkto>
00070 //   <li> <linkto class=ScalarColumn>ScalarColumn</linkto>
00071 //   <li> <linkto class=ArrayColumn>ArrayColum</linkto>
00072 //   <li> <linkto class=TableLock>TableLock</linkto>
00073 // </prerequisite>
00074 
00075 // <synopsis>
00076 // Class Table can be used to create a new table or to access an existing
00077 // table in read/write or readonly mode.
00078 //
00079 // To access the data in a Table, objects have to be created
00080 // to access the columns. These objects are TableColumn,
00081 // ScalarColumn<T> and ArrayColumn<T>, which can be created
00082 // via their constructors.
00083 // Furthermore the Table has a TableRecord object for holding keywords
00084 // which can be read or written using the appropriate functions.
00085 //
00086 // To open an existing table, a simple Table constructor can be used.
00087 // The possible construct options are:
00088 // <ul>
00089 //   <li> Old            readonly table (default option)
00090 //   <li> Update         update existing table
00091 //   <li> Delete         delete table
00092 // </ul>
00093 // The function <src>openTable</src> makes it possible to open a subtable
00094 // of a table in a convenient way, even if the table is only a reference
00095 // to another table (e.g., a selection).
00096 //
00097 // Creating a new table requires more work, because columns have
00098 // to be bound to storage managers or virtual column engines.
00099 // Class SetupNewTable is needed for this purpose. The Tables module
00100 // documentation explains in more detail how to create a table.
00101 // When creating a table, it can be specified which endian format to use.
00102 // By default it uses the format specified in the aipsrc variable
00103 // <code>table.endianformat</code> which defaults to
00104 // <code>Table::LocalEndian</code> (thus the endian format of the
00105 // machine being used).
00106 //
00107 // It is possible to create a Table object as the virtual concatenation of
00108 // Tables having identical table descriptions. Subtables of those tables
00109 // can optionally be concatenated as well.
00110 // E.g. if a MeasurementSet is partioned in time, this mechanism makes it
00111 // possible to view it as a single table. Furthermore, a subtable like
00112 // SYSCAL can be concatenated as well, while the other subtables are identical
00113 // in all partitions and are taken from the first table only.
00114 //
00115 // Other Table objects can be created from a Table using
00116 // the select, project and sort functions. The result in so-called
00117 // reference tables. In this way a subset of a table can be created and
00118 // can be read/written in the same way as a normal Table. Writing has the
00119 // effect that the underlying table gets written.
00120 // </synopsis>
00121 
00122 // <example>
00123 // <srcblock>
00124 // // Open a table to be updated.
00125 // Table myTable ("theTable", Table::Update);
00126 // // Write the column containing the scalar RA.
00127 // ScalarColumn<double> raColumn(myTable, "RA");
00128 // uInt nrrow = myTable.nrow();
00129 // for (uInt i=0; i<nrrow; i++) {
00130 //    raColumn.put (i, i+10);    // Put value i+10 into row i
00131 // }
00132 // </srcblock>
00133 // </example>
00134 
00135 // <motivation>
00136 // Table is the envelope for the underlying counted referenced
00137 // classes derived from BaseTable. In this way no pointers have
00138 // to be used to get polymorphism.
00139 // </motivation>
00140 
00141 // <todo asof="$DATE:$">
00142 //# A List of bugs, limitations, extensions or planned refinements.
00143 //   <li> add, remove, rename columns.
00144 //   <li> virtual concatenation of tables (if still necessary).
00145 //   <li> maybe an isAttached function.
00146 // </todo>
00147 
00148 
00149 class Table
00150 {
00151 friend class TableColumn;
00152 friend class BaseTable;
00153 friend class PlainTable;
00154 friend class MemoryTable;
00155 friend class RefTable;
00156 friend class ConcatTable;
00157 friend class TableIterator;
00158 friend class RODataManAccessor;
00159 friend class TableExprNode;
00160 friend class TableExprNodeRep;
00161 
00162 public:
00163     // Define the possible options how a table can be opened.
00164     enum TableOption {
00165         // existing table
00166         Old=1,
00167         // create table
00168         New,
00169         // create table (may not exist)
00170         NewNoReplace,
00171         // new table, which gets marked for delete
00172         Scratch,
00173         // update existing table
00174         Update,
00175         // delete table
00176         Delete
00177     };
00178 
00179     // Define the possible table types.
00180     enum TableType {
00181         // plain table (stored on disk)
00182         Plain,
00183         // table held in memory
00184         Memory
00185     };
00186 
00187     // Define the possible endian formats in which table data can be stored.
00188     enum EndianFormat {
00189         // store table data in big endian (e.g. SUN) format
00190         BigEndian=1,
00191         // store table data in little endian (e.g. Intel) format
00192         LittleEndian,
00193         // store data in the endian format of the machine used
00194         LocalEndian,
00195         // use endian format defined in the aipsrc variable table.endianformat
00196         // If undefined, it defaults to LocalEndian.
00197         AipsrcEndian
00198     };
00199 
00200 
00201     // Define the signature of the function being called when the state
00202     // of a scratch table changes (i.e. created, closed, renamed,
00203     // (un)markForDelete).
00204     // <br>- <src>isScratch=True</src> indicates that a scratch table
00205     // is created (<src>oldName</src> is empty) or renamed
00206     // (<src>oldName</src> is not empty).
00207     // <br>- <src>isScratch=False</src> indicates that a scratch table
00208     // with name <src>name</src> is not scratch anymore (because it is
00209     // closed or because its state is set to non-scratch).
00210     typedef void ScratchCallback (const String& name, Bool isScratch,
00211                                   const String& oldName);
00212 
00213     // Set the pointer to the ScratchCallback function.
00214     // It returns the current value of the pointer.
00215     // This function is called when changing the state of a table
00216     // (i.e. create, close, rename, (un)markForDelete).
00217     static ScratchCallback* setScratchCallback (ScratchCallback*);
00218 
00219 
00220     // Create a null Table object (i.e. a NullTable is attached).
00221     // The sole purpose of this constructor is to allow construction
00222     // of an array of Table objects.
00223     // The assignment operator can be used to make a null object
00224     // reference a proper table.
00225     Table();
00226 
00227     // Create a table object for an existing table.
00228     // The only options allowed are Old, Update, and Delete.
00229     // If the name of a table description is given, it is checked
00230     // if the table has that description.
00231     // Locking options can be given (see class
00232     // <linkto class=TableLock>TableLock</linkto>.
00233     // If the table with this name was already opened in this process,
00234     // the existing and new locking options are merged using
00235     // <src>TableLock::merge</src>.
00236     // The default locking mechanism is DefaultLocking. If the table
00237     // is not open yet, it comes to AutoLocking with an inspection interval
00238     // of 5 seconds. Otherwise DefaultLocking keeps the locking options
00239     // of the already open table.
00240     // <group>
00241     explicit Table (const String& tableName, TableOption = Table::Old,
00242                     const TSMOption& = TSMOption());
00243     Table (const String& tableName, const TableLock& lockOptions,
00244            TableOption = Table::Old, const TSMOption& = TSMOption());
00245     Table (const String& tableName, const String& tableDescName,
00246            TableOption = Table::Old, const TSMOption& = TSMOption());
00247     Table (const String& tableName, const String& tableDescName,
00248            const TableLock& lockOptions, TableOption = Table::Old,
00249            const TSMOption& = TSMOption());
00250     // </group>
00251 
00252     // Make a new empty table (plain (scratch) or memory type).
00253     // Columns should be added to make it a real one.
00254     // Note that the endian format is only relevant for plain tables.
00255     explicit Table (TableType, EndianFormat = Table::AipsrcEndian,
00256                     const TSMOption& = TSMOption());
00257 
00258     // Make a table object for a new table, which can thereafter be used
00259     // for reading and writing.
00260     // If there are unbound columns, default storage managers an/ord virtual
00261     // column engines will be created and bound to those columns.
00262     // Create the table with the given nr of rows. If a storage manager
00263     // is used which does not allow addition of rows, the number of rows
00264     // in the table must already be given here.
00265     // Optionally the rows can be initialized with the default
00266     // values as defined in the column descriptions.
00267     // Locking options can be given (see class
00268     // <linkto class=TableLock>TableLock</linkto>.
00269     // The default locking mechanism is AutoLocking with a default
00270     // inspection interval of 5 seconds.
00271     // <br>The data will be stored in the given endian format.
00272     // <group>
00273     explicit Table (SetupNewTable&, uInt nrrow = 0, Bool initialize = False,
00274                     EndianFormat = Table::AipsrcEndian,
00275                     const TSMOption& = TSMOption());
00276     Table (SetupNewTable&, TableType,
00277            uInt nrrow = 0, Bool initialize = False,
00278            EndianFormat = Table::AipsrcEndian, const TSMOption& = TSMOption());
00279     Table (SetupNewTable&, TableType, const TableLock& lockOptions,
00280            uInt nrrow = 0, Bool initialize = False,
00281            EndianFormat = Table::AipsrcEndian, const TSMOption& = TSMOption());
00282     Table (SetupNewTable&, TableLock::LockOption,
00283            uInt nrrow = 0, Bool initialize = False,
00284            EndianFormat = Table::AipsrcEndian, const TSMOption& = TSMOption());
00285     Table (SetupNewTable&, const TableLock& lockOptions,
00286            uInt nrrow = 0, Bool initialize = False,
00287            EndianFormat = Table::AipsrcEndian, const TSMOption& = TSMOption());
00288     // </group>
00289 
00290     // Create a table object as the virtual concatenation of
00291     // one or more of existing tables. The descriptions of all those tables
00292     // must be exactly the same.
00293     // <br>The keywordset of the virtual table is the set of the first table
00294     // including its subtables. However, it is possible to specify the names
00295     // of the subtables that have to be concantenated as well.
00296     // <br>In this way a concatenation of multiple MS-s can be made, where it
00297     // can be specified that, say, the SYSCAL table has to be concatenated too.
00298     // <br> When a concatenated table is written and if a non-empty
00299     // <src>subDirName</src> is given, the tables to be concatenated will be
00300     // moved to that subdirectory in the directory of the concatenated table.
00301     // This option is mainly used by the MSS structure used in CASA.
00302     // <br>
00303     // The only open options allowed are Old and Update.
00304     // Locking options can be given (see class
00305     // <linkto class=TableLock>TableLock</linkto>.
00306     // They apply to all underlying tables.
00307     // If a table was already opened in this process,
00308     // the existing and new locking options are merged using
00309     // <src>TableLock::merge</src>.
00310     // The default locking mechanism is DefaultLocking. If the table
00311     // is not open yet, it comes to AutoLocking with an inspection interval
00312     // of 5 seconds. Otherwise DefaultLocking keeps the locking options
00313     // of the already open table.
00314     // <group>
00315     explicit Table (const Block<Table>& tables,
00316                     const Block<String>& subTables = Block<String>(),
00317                     const String& subDirName = String());
00318     explicit Table (const Block<String>& tableNames,
00319                     const Block<String>& subTables = Block<String>(),
00320                     TableOption = Table::Old, const TSMOption& = TSMOption(),
00321                     const String& subDirName = String());
00322     Table (const Block<String>& tableNames,
00323            const Block<String>& subTables,
00324            const TableLock& lockOptions,
00325            TableOption = Table::Old, const TSMOption& = TSMOption());
00326     // </group>
00327 
00328     // Copy constructor (reference semantics).
00329     Table (const Table&);
00330 
00331     // The destructor flushes (i.e. writes) the table if it is opened
00332     // for output and not marked for delete.
00333     // It will flush if the destructor is called due to an exception,
00334     // because the Table object may not be correct.
00335     // Of course, in that case the flush function could be called explicitly.
00336     ~Table();
00337 
00338     // Assignment (reference semantics).
00339     Table& operator= (const Table&);
00340 
00341     // Try to open a table. The name of the table can contain subtable names
00342     // using :: as separator. In this way it is possible to directly open a
00343     // subtable of a RefTable or ConcatTable, which is not possible if the
00344     // table name is specified with slashes.
00345     // <br>The open process is as follows:
00346     // <ul>
00347     //  <li> It is tried to open the table with the given name.
00348     //  <li> If unsuccessful, the name is split into its parts using ::
00349     //       The first part is the main table which will be opened temporarily.
00350     //       The other parts are the successive subtable names (usually one).
00351     //       Each subtable is opened by looking it up in the keywords of the
00352     //       table above. The final subtable is returned.
00353     // </ul>
00354     // <br>An exception is thrown if the table cannot be opened.
00355     // <example>
00356     // Open the ANTENNA subtable of an MS which might be a selection of
00357     // a real MS.
00358     // <srcblock>
00359     // Table tab(Table::openTable ("sel.ms::ANTENNA");
00360     // </srcblock>
00361     // </example>
00362     // <group>
00363     static Table openTable (const String& tableName,
00364                             TableOption = Table::Old,
00365                             const TSMOption& = TSMOption());
00366     static Table openTable (const String& tableName,
00367                             const TableLock& lockOptions,
00368                             TableOption = Table::Old,
00369                             const TSMOption& = TSMOption());
00370     // </group>
00371 
00372     // Get the names of the tables this table consists of.
00373     // For a plain table it returns its name,
00374     // for a RefTable the name of the parent, and
00375     // for a ConcatTable the names of all its parts.
00376     // <br>Note that a part can be any type of table (e.g. a ConcatTable).
00377     // The recursive switch tells how to deal with that.
00378     Block<String> getPartNames (Bool recursive=False) const;
00379 
00380     // Is the root table of this table the same as that of the other one?
00381     Bool isSameRoot (const Table& other) const;
00382 
00383     // Can the table be deleted?
00384     // If true, function deleteTable can safely be called.
00385     // If not, message contains the reason why (e.g. 'table is not writable').
00386     // It checks if the table is writable, is not open in this process
00387     // and is not open in another process.
00388     // <br>If <src>checkSubTables</src> is set, it also checks if
00389     // a subtable is not open in another process.
00390     // <group>
00391     static Bool canDeleteTable (const String& tableName,
00392                                 Bool checkSubTables=False);
00393     static Bool canDeleteTable (String& message, const String& tableName,
00394                                 Bool checkSubTables=False);
00395     // </group>
00396 
00397     // Delete the table.
00398     // An exception is thrown if the table cannot be deleted because
00399     // its is not writable or because it is still open in this or
00400     // another process.
00401     // <br>If <src>checkSubTables</src> is set, it is also checked if
00402     // a subtable is used in another process.
00403     static void deleteTable (const String& tableName,
00404                              Bool checkSubTables=False);
00405 
00406     // Close all open subtables.
00407     void closeSubTables() const;
00408 
00409     // Try to reopen the table for read/write access.
00410     // An exception is thrown if the table is not writable.
00411     // Nothing is done if the table is already open for read/write.
00412     void reopenRW();
00413 
00414     // Get the endian format in which the table is stored.
00415     Table::EndianFormat endianFormat() const;
00416 
00417     // Is the table used (i.e. open) in this process.
00418     static Bool isOpened (const String& tableName);
00419 
00420     // Is the table used (i.e. open) in another process.
00421     // If <src>checkSubTables</src> is set, it is also checked if
00422     // a subtable is used in another process.
00423     Bool isMultiUsed (Bool checkSubTables=False) const;
00424 
00425     // Get the locking options.
00426     const TableLock& lockOptions() const;
00427 
00428     // Has this process the read or write lock, thus can the table
00429     // be read or written safely?
00430     // <group>
00431     Bool hasLock (FileLocker::LockType = FileLocker::Write) const;
00432     Bool hasLock (Bool write) const;
00433     // </group>
00434 
00435     // Try to lock the table for read or write access (default is write).
00436     // The number of attempts (default = forever) can be specified when
00437     // acquiring the lock does not succeed immediately. If nattempts>1,
00438     // the system waits 1 second between each attempt, so nattempts
00439     // is more or less equal to a wait period in seconds.
00440     // The return value is false if acquiring the lock failed.
00441     // If <src>PermanentLocking</src> is in effect, a lock is already
00442     // present, so nothing will be done.
00443     // <group>
00444     Bool lock (FileLocker::LockType = FileLocker::Write, uInt nattempts = 0);
00445     Bool lock (Bool write, uInt nattempts = 0);
00446     // </group>
00447 
00448     // Unlock the table. This will also synchronize the table data,
00449     // thus force the data to be written to disk.
00450     // If <src>PermanentLocking</src> is in effect, nothing will be done.
00451     void unlock();
00452 
00453     // Determine the number of locked tables opened with the AutoLock option
00454     // (Locked table means locked for read and/or write).
00455     static uInt nAutoLocks();
00456 
00457     // Unlock locked tables opened with the AutoLock option.
00458     // If <src>all=True</src> all such tables will be unlocked.
00459     // If <src>all=False</src> only tables requested by another process
00460     // will be unlocked.
00461     static void relinquishAutoLocks (Bool all = False);
00462 
00463     // Get the names of tables locked in this process.
00464     // By default all locked tables are given (note that a write lock
00465     // implies a read lock), but it is possible to select on lock type
00466     // FileLocker::Write and on option (TableLock::AutoLocking,
00467     // TableLock::ReadLocking, or TableLock::PermanentLocking).
00468     static Vector<String> getLockedTables(FileLocker::LockType=FileLocker::Read,
00469                                           int lockOption=-1);
00470 
00471     // Determine if column or keyword table data have changed
00472     // (or is being changed) since the last time this function was called.
00473     Bool hasDataChanged();
00474 
00475     // Flush the table, i.e. write out the buffers. If <src>sync=True</src>,
00476     // it is ensured that all data are physically written to disk.
00477     // Nothing will be done if the table is not writable.
00478     // At any time a flush can be executed, even if the table is marked
00479     // for delete.
00480     // If the table is marked for delete, the destructor will remove
00481     // files written by intermediate flushes.
00482     // Note that if necessary the destructor will do an implicit flush,
00483     // unless it is executed due to an exception.
00484     // <br>If <src>fsync=True</src> the file contents are fsync-ed to disk,
00485     // thus ensured that the system buffers are actually written to disk.
00486     // <br>If <src>recursive=True</src> all subtables are flushed too.
00487     void flush (Bool fsync=False, Bool recursive=False);
00488 
00489     // Resynchronize the Table object with the table file.
00490     // This function is only useful if no read-locking is used, ie.
00491     // if the table lock option is UserNoReadLocking or AutoNoReadLocking.
00492     // In that cases the table system does not acquire a read-lock, thus
00493     // does not synchronize itself automatically.
00494     void resync();
00495 
00496     // Test if the object is null, i.e. does not reference a proper table.
00497     // This is the case if the default constructor is used.
00498     Bool isNull() const
00499       { return (baseTabPtr_p == 0  ?  True : baseTabPtr_p->isNull()); }
00500 
00501     // Throw an exception if the object is null, i.e.
00502     // if function isNull() is True.
00503     void throwIfNull() const;
00504 
00505     // Test if the given data type is native to the table system.
00506     // If not, a virtual column engine is needed to store data with that type.
00507     // With the function DataType::whatType it can be used in a templated
00508     // function like:
00509     // <srcblock>
00510     //     if (Table::isNativeDataType (whatType(static_cast<T*>(0)))) {
00511     // </srcblock>
00512     static Bool isNativeDataType (DataType dtype);
00513 
00514     // Make the table file name.
00515     static String fileName (const String& tableName);
00516 
00517     // Test if a table with the given name exists and is readable.
00518     // If not, an exception is thrown if <src>throwIf==True</src>.
00519     static Bool isReadable (const String& tableName, bool throwIf=False);
00520 
00521     // Return the layout of a table (i.e. description and #rows).
00522     // This function has the advantage that only the minimal amount of
00523     // information required is read from the table, thus it is much
00524     // faster than a normal table open.
00525     // <br> The number of rows is returned. The description of the table
00526     // is stored in desc (its contents will be overwritten).
00527     // <br> An exception is thrown if the table does not exist.
00528     static uInt getLayout (TableDesc& desc, const String& tableName);
00529 
00530     // Get the table info of the table with the given name.
00531     // An empty object is returned if the table is unknown.
00532     static TableInfo tableInfo (const String& tableName);
00533 
00534     // Show the structure of the table.
00535     // It shows the columns (with types), the data managers, and the subtables.
00536     // Optionally the columns can be sorted alphabetically.
00537     void showStructure (std::ostream&,
00538                         Bool showDataMans=True,
00539                         Bool showColumns=True,
00540                         Bool showSubTables=False,
00541                         Bool sortColumns=False) const;
00542 
00543     // Test if a table with the given name exists and is writable.
00544     static Bool isWritable (const String& tableName, bool throwIf=False);
00545 
00546     // Find the non-writable files in a table.
00547     static Vector<String> nonWritableFiles (const String& tableName);
00548 
00549     // Test if this table is the root table (ie. if it is not the subset
00550     // of another table).
00551     Bool isRootTable() const;
00552 
00553     // Test if this table is opened as writable.
00554     Bool isWritable() const;
00555 
00556     // Test if the given column is writable.
00557     // <group>
00558     Bool isColumnWritable (const String& columnName) const;
00559     Bool isColumnWritable (uInt columnIndex) const;
00560     // </group>
00561 
00562     // Test if the given column is stored (otherwise it is virtual).
00563     // <group>
00564     Bool isColumnStored (const String& columnName) const;
00565     Bool isColumnStored (uInt columnIndex) const;
00566     // </group>
00567 
00568     // Get readonly access to the table keyword set.
00569     // If UserLocking is used, it will automatically acquire
00570     // and release a read lock if the table is not locked.
00571     const TableRecord& keywordSet() const;
00572 
00573     // Get read/write access to the table keyword set.
00574     // This requires that the table is locked (or it gets locked
00575     // if using AutoLocking mode).
00576     TableRecord& rwKeywordSet();
00577 
00578     // Get access to the TableInfo object.
00579     // <group>
00580     const TableInfo& tableInfo() const;
00581     TableInfo& tableInfo();
00582     // </group>
00583 
00584     // Write the TableInfo object.
00585     // Usually this is not necessary, because it is done automatically
00586     // when the table gets written (by table destructor or flush function).
00587     // This function is only useful if the table info has to be written
00588     // before the table gets written (e.g. when another process reads
00589     // the table while it gets filled).
00590     void flushTableInfo() const;
00591 
00592     // Get the table description.
00593     // This can be used to get nr of columns, etc..
00594     // <src>tableDesc()</src> gives the table description used when
00595     // constructing the table, while <src>actualTableDesc()</src> gives the
00596     // actual description, thus with the actual data managers used.
00597     // <group>
00598     const TableDesc& tableDesc() const;
00599     TableDesc actualTableDesc() const;
00600     // </group>
00601 
00602     // Return all data managers used and the columns served by them.
00603     // The info is returned in a record. It contains a subrecord per
00604     // data manager. Each subrecord contains the following fields:
00605     // <dl>
00606     //  <dt> TYPE
00607     //  <dd> a string giving the type of the data manager.
00608     //  <dt> NAME
00609     //  <dd> a string giving the name of the data manager.
00610     //  <dt> COLUMNS
00611     //  <dd> a vector of strings giving the columns served by the data manager.
00612     // </dl>
00613     // Data managers may return some additional fields (e.g. BUCKETSIZE).
00614     Record dataManagerInfo() const;
00615 
00616     // Get the table name.
00617     const String& tableName() const;
00618 
00619     // Rename the table and all its subtables.
00620     // The following options can be given:
00621     // <dl>
00622     // <dt> Table::Update
00623     // <dd> A table with this name must already exists, which will be
00624     //      overwritten. When succesfully renamed, the table is unmarked
00625     //      for delete (if necessary).
00626     // <dt> Table::New
00627     // <dd> If a table with this name exists, it will be overwritten.
00628     //      When succesfully renamed, the table is unmarked
00629     //      for delete (if necessary).
00630     // <dt> Table::NewNoReplace
00631     // <dd> If a table with this name already exists, an exception
00632     //      is thrown. When succesfully renamed, the table
00633     //      is unmarked for delete (if necessary).
00634     // <dt> Table::Scratch
00635     // <dd> Same as Table::New, but followed by markForDelete().
00636     // </dl>
00637     // The scratchCallback function is called when needed.
00638     void rename (const String& newName, TableOption);
00639 
00640     // Copy the table and all its subtables.
00641     // Especially for RefTables <src>copy</src> and <src>deepCopy</src> behave
00642     // differently. <src>copy</src> makes a bitwise copy of the table, thus
00643     // the result is still a RefTable. On the other hand <src>deepCopy</src>
00644     // makes a physical copy of all referenced table rows and columns, thus
00645     // the result is a PlainTable.
00646     // <br>For PlainTables <src>deepCopy</src> is the same as <src>copy</src>
00647     // unless <src>valueCopy==True</src> is given. In that case the values
00648     // are copied which takes longer, but reorganizes the data files to get
00649     // rid of gaps in the data. Also if specific DataManager info is given
00650     // or if no rows have to be copied, a deep copy is made.
00651     // <br>The following options can be given:
00652     // <dl>
00653     // <dt> Table::New
00654     // <dd> If a table with this name exists, it will be overwritten.
00655     // <dt> Table::NewNoReplace
00656     // <dd> If a table with this name already exists, an exception
00657     //      is thrown.
00658     // <dt> Table::Scratch
00659     // <dd> Same as Table::New, but followed by markForDelete().
00660     // </dl>
00661     // <group>
00662     // The new table gets the given endian format. Note that the endian option
00663     // is only used if a true deep copy of a table is made.
00664     // <br>When making a deep copy, it is possible to specify the data managers
00665     // using the <src>dataManagerInfo</src> argument.
00666     // See <src>getDataManagerInfo</src> for more info about that record.
00667     // <br>If <src>noRows=True</src> no rows are copied. Also no rows are
00668     // copied in all subtables. It is useful if one wants to make a copy
00669     // of only the Table structure.
00670     void copy (const String& newName, TableOption, Bool noRows=False) const;
00671     void deepCopy (const String& newName,
00672                    TableOption, Bool valueCopy=False,
00673                    EndianFormat=AipsrcEndian,
00674                    Bool noRows=False) const;
00675     void deepCopy (const String& newName, const Record& dataManagerInfo,
00676                    TableOption, Bool valueCopy=False,
00677                    EndianFormat=AipsrcEndian,
00678                    Bool noRows=False) const;
00679     // </group>
00680 
00681     // Make a copy of a table to a MemoryTable object.
00682     // Use the given name for the memory table.
00683     Table copyToMemoryTable (const String& name, Bool noRows=False) const;
00684 
00685     // Get the table type.
00686     TableType tableType() const;
00687 
00688     // Get the table option.
00689     int tableOption() const;
00690 
00691     // Mark the table for delete.
00692     // This means that the underlying table gets deleted when it is
00693     // actually destructed.
00694     // The scratchCallback function is called when needed.
00695     void markForDelete();
00696 
00697     // Unmark the table for delete.
00698     // This means the underlying table does not get deleted when destructed.
00699     // The scratchCallback function is called when needed.
00700     void unmarkForDelete();
00701 
00702     // Test if the table is marked for delete.
00703     Bool isMarkedForDelete() const;
00704     
00705     // Get the number of rows.
00706     // It is unsynchronized meaning that it will not check if another
00707     // process updated the table, thus possible increased the number of rows.
00708     // If one wants to take that into account, he should acquire a
00709     // read-lock (using the lock function) before using nrow().
00710     uInt nrow() const;
00711 
00712     // Test if it is possible to add a row to this table.
00713     // It is possible if all storage managers used for the table
00714     // support it.
00715     Bool canAddRow() const;
00716 
00717     // Add one or more rows at the end of the table.
00718     // This will fail for tables not supporting addition of rows.
00719     // Optionally the rows can be initialized with the default
00720     // values as defined in the column descriptions.
00721     void addRow (uInt nrrow = 1, Bool initialize = False);
00722 
00723     // Test if it is possible to remove a row from this table.
00724     // It is possible if all storage managers used for the table
00725     // support it.
00726     Bool canRemoveRow() const;
00727 
00728     // Remove the given row(s).
00729     // The latter form can be useful with the select and rowNumbers functions
00730     // to remove some selected rows from the table.
00731     // <br>It will fail for tables not supporting removal of rows.
00732     // <note role=warning>
00733     // The following code fragments do NOT have the same result:
00734     // <srcblock>
00735     //    tab.removeRow (10);      // remove row 10
00736     //    tab.removeRow (20);      // remove row 20, which was 21
00737     //    Vector<uInt> vec(2);
00738     //    vec(0) = 10;
00739     //    vec(1) = 20;
00740     //    tab.removeRow (vec);     // remove row 10 and 20
00741     // </srcblock>
00742     // because in the first fragment removing row 10 turns the former
00743     // row 21 into row 20.
00744     // </note>
00745     // <group>
00746     void removeRow (uInt rownr);
00747     void removeRow (const Vector<uInt>& rownrs);
00748     // </group>
00749 
00750     // Create a TableExprNode object for a column or for a keyword
00751     // in the table keyword set.
00752     // This can be used in selecting rows from a table using
00753     // <src>operator()</src> described below.
00754     // <br>The functions taking the fieldNames vector are meant for
00755     // the cases where the keyword or column contains records.
00756     // The fieldNames indicate which field to take from that record
00757     // (which can be a record again, etc.).
00758     // <group name=keycol>
00759     TableExprNode key (const String& keywordName) const;
00760     TableExprNode key (const Vector<String>& fieldNames) const;
00761     TableExprNode col (const String& columnName) const;
00762     TableExprNode col (const String& columnName,
00763                        const Vector<String>& fieldNames) const;
00764     TableExprNode keyCol (const String& name,
00765                           const Vector<String>& fieldNames) const;
00766     // </group>
00767 
00768     // Create a TableExprNode object for the rownumber function.
00769     // 'origin' Indicates which rownumber is the first.
00770     // C++ uses origin = 0 (default)
00771     // Glish and TaQL both use origin = 1
00772     TableExprNode nodeRownr (uInt origin=0) const;
00773 
00774     // Create a TableExprNode object for the rand function.
00775     TableExprNode nodeRandom () const;
00776 
00777     // Select rows from a table using an select expression consisting
00778     // of TableExprNode objects.
00779     // Basic TableExprNode objects can be created with the functions
00780     // <linkto file="Table.h#keycol">key</linkto> and especially
00781     // <linkto file="Table.h#keycol">col</linkto>.
00782     // Composite TableExprNode objects, representing an expression,
00783     // can be created by applying operations (like == and +)
00784     // to the basic ones. This is described in class
00785     // <linkto class="TableExprNode:description">TableExprNode</linkto>.
00786     // For example:
00787     // <srcblock>
00788     //    Table result = tab(tab.col("columnName") > 10);
00789     // </srcblock>
00790     // All rows for which the expression is true, will be selected and
00791     // "stored" in the result.
00792     // You need to include ExprNode.h for this purpose.
00793     // <br>If <src>maxRow>0</src>, the selection process will stop
00794     // when <src>maxRow</src> matching rows are found.
00795     // <br>The TableExprNode argument can be empty (null) meaning that only
00796     // the <src>maxRow</src> argument is taken into account.
00797     Table operator() (const TableExprNode&, uInt maxRow=0) const;
00798 
00799     // Select rows using a vector of row numbers.
00800     // This can, for instance, be used to select the same rows as
00801     // were selected in another table (using the rowNumbers function).
00802     // <srcblock>
00803     //     Table result = thisTable (otherTable.rowNumbers());
00804     // </srcblock>
00805     Table operator() (const Vector<uInt>& rownrs) const;
00806 
00807     // Select rows using a mask block.
00808     // The length of the block must match the number of rows in the table.
00809     // If an element in the mask is True, the corresponding row will be
00810     // selected.
00811     Table operator() (const Block<Bool>& mask) const;
00812 
00813     // Project the given columns (i.e. select the columns).
00814     Table project (const Block<String>& columnNames) const;
00815 
00816     //# Virtually concatenate all tables in this column.
00817     //# The column cells must contain tables with the same description.
00818 //#//    Table concatenate (const String& columnName) const;
00819 
00820     // Do logical operations on a table.
00821     // It can be used for row-selected or projected (i.e. column-selected)
00822     // tables. The tables involved must come from the same root table or
00823     // be the root table themselves.
00824     // <group>
00825     // Intersection with another table.
00826     Table operator& (const Table&) const;
00827     // Union with another table.
00828     Table operator| (const Table&) const;
00829     // Subtract another table.
00830     Table operator- (const Table&) const;
00831     // Xor with another table.
00832     Table operator^ (const Table&) const;
00833     // Take complement.
00834     Table operator! () const;
00835     // </group>
00836 
00837     // Sort a table on one or more columns of scalars.
00838     // Per column a compare function can be provided. By default
00839     // the standard compare function defined in Compare.h will be used.
00840     // Default sort order is ascending.
00841     // Default sorting algorithm is the heapsort.
00842     // <group>
00843     // Sort on one column.
00844     Table sort (const String& columnName,
00845                 int = Sort::Ascending,
00846                 int = Sort::HeapSort) const;
00847     // Sort on multiple columns. The principal column has to be the
00848     // first element in the Block of column names.
00849     Table sort (const Block<String>& columnNames,
00850                 int = Sort::Ascending,
00851                 int = Sort::HeapSort) const;
00852     // Sort on multiple columns. The principal column has to be the
00853     // first element in the Block of column names.
00854     // The order can be given per column.
00855     Table sort (const Block<String>& columnNames,
00856                 const Block<Int>& sortOrders,
00857                 int = Sort::HeapSort) const;
00858     // Sort on multiple columns. The principal column has to be the
00859     // first element in the Block of column names.
00860     // The order can be given per column.
00861     // Provide some special comparisons via CountedPtrs of compare objects.
00862     // A null CountedPtr means using the standard compare object
00863     // from class <linkto class="ObjCompare:description">ObjCompare</linkto>.
00864     Table sort (const Block<String>& columnNames,
00865                 const Block<CountedPtr<BaseCompare> >& compareObjects,
00866                 const Block<Int>& sortOrders,
00867                 int = Sort::HeapSort) const;
00868     // </group>
00869 
00870     // Get a vector of row numbers in the root table of rows in this table.
00871     // In case the table is a subset of the root table, this tells which
00872     // rows of the root table are part of the subset.
00873     // In case the table is the root table itself, the result is a vector
00874     // containing the row numbers 0 .. #rows-1.
00875     // <br>Note that in general it is better to use the next
00876     // <src>rowNumbers(Table)</src> function.
00877     Vector<uInt> rowNumbers() const;
00878 
00879     // Get a vector of row numbers in that table of rows in this table.
00880     // In case the table is a subset of that table, this tells which
00881     // rows of that table are part of the subset.
00882     // In case the table is that table itself, the result is a vector
00883     // containing the row numbers 0 .. #rows-1.
00884     // <note role=caution>This function is in principle meant for cases
00885     // where this table is a subset of that table. However, it can be used
00886     // for any table. In that case the returned vector contains a very high
00887     // number (max_uint) for rows in this table not part of that table.
00888     // In that way they are invalid if used elsewhere.
00889     // <br>In the general case creating the row number vector can be slowish,
00890     // because it has to do two mappings. However, if this table is a subset
00891     // of that table and if they are in the same order, the mapping can be done
00892     // in a more efficient way. The argument <src>tryFast</src> can be used to
00893     // tell the function to try a fast conversion first. If that cannot be done,
00894     // it reverts to the slower way at the expense of an unsuccessful fast
00895     // attempt.
00896     // </note>
00897     // <srcblock>
00898     // Table tab("somename");
00899     // Table subset = tab(some_select_expression);
00900     // Vector<uInt> rownrs = subset.rowNumbers(tab);
00901     // </srcblock>
00902     // Note that one cannot be sure that table "somename" is the root
00903     // (i.e. original) table. It may also be a subset of another table.
00904     // In the latter case doing
00905     // <br> <src>    Vector<uInt> rownrs = subset.rowNumbers()</src>
00906     // does not give the row numbers in <src>tab</src>, but in the root table
00907     // (which is probably not what you want).
00908   Vector<uInt> rowNumbers (const Table& that, Bool tryFast=False) const;
00909 
00910     // Add a column to the table.
00911     // The data manager used for the column depend on the function used.
00912     // Exceptions are thrown if the column already exist or if the
00913     // table is not writable.
00914     // <br>If this table is a reference table (result of selection) and if
00915     // <src>addToParent=True</src> the column is also added to the parent
00916     // table.
00917     // <group>
00918     // Use the first appropriate existing storage manager.
00919     // If there is none, a data manager is created using the default
00920     // data manager in the column description.
00921     void addColumn (const ColumnDesc& columnDesc,
00922                     Bool addToParent = True);
00923     // Use an existing data manager with the given name or type.
00924     // If the flag byName is True, a name is given, otherwise a type.
00925     // If a name is given, an exception is thrown if the data manager is
00926     // unknown or does not allow addition of columns.
00927     // If a type is given, a storage manager of the given type will be
00928     // created if there is no such data manager allowing addition of rows.
00929     void addColumn (const ColumnDesc& columnDesc,
00930                     const String& dataManager, Bool byName,
00931                     Bool addToParent = True);
00932     // Use the given data manager (which is a new one).
00933     void addColumn (const ColumnDesc& columnDesc,
00934                     const DataManager& dataManager,
00935                     Bool addToParent = True);
00936     // </group>
00937 
00938     // Add a bunch of columns using the given new data manager.
00939     // All columns and possible hypercolumn definitions in the given table
00940     // description will be copied and added to the table.
00941     // This can be used in case of specific data managers which need to
00942     // be created with more than one column (e.g. the tiled hypercube
00943     // storage managers).
00944     // <br>The data manager can be given directly or by means of a record
00945     // describing the data manager in the standard way with the fields
00946     // TYPE, NAME, and SPEC. The record can contain those fields itself
00947     // or it can contain a single subrecord with those fields.
00948     // <br>If this table is a reference table (result of selection) and if
00949     // <src>addToParent=True</src> the columns are also added to the parent
00950     // table.
00951     // <group>
00952     void addColumn (const TableDesc& tableDesc,
00953                     const DataManager& dataManager,
00954                     Bool addToParent = True);
00955     void addColumn (const TableDesc& tableDesc,
00956                     const Record& dataManagerInfo,
00957                     Bool addToParent = True);
00958     // </group>
00959 
00960     // Test if columns can be removed.
00961     // It can if the columns exist and if the data manager it is using
00962     // supports removal of columns or if all columns from a data manager
00963     // would be removed..
00964     // <br>You can always remove columns from a reference table.
00965     // <group>
00966     Bool canRemoveColumn (const String& columnName) const;
00967     Bool canRemoveColumn (const Vector<String>& columnNames) const;
00968     // </group>
00969 
00970     // Remove columns.
00971     // <br>When removing columns from a reference table, the columns
00972     // are NOT removed from the underlying table.
00973     // <group>
00974     void removeColumn (const String& columnName);
00975     void removeColumn (const Vector<String>& columnName);
00976     // </group>
00977 
00978     // Test if a column can be renamed.
00979     Bool canRenameColumn (const String& columnName) const;
00980 
00981     // Rename a column.
00982     // An exception is thrown if the old name does not exist or
00983     // if the name already exists.
00984     // <note role=caution>
00985     // Renaming a column should be done with care, because other
00986     // columns may be referring this column. Also a hypercolumn definition
00987     // might be using the old name.
00988     // Finally if may also invalidate persistent selections of a table,
00989     // because the reference table cannot find the column anymore.
00990     // </note>
00991     void renameColumn (const String& newName, const String& oldName);
00992 
00993     void renameHypercolumn (const String& newName, const String& oldName);
00994 
00995     // Write a table to AipsIO (for <src>TypedKeywords<Table></src>).
00996     // This will only write the table name.
00997     friend AipsIO& operator<< (AipsIO&, const Table&);
00998 
00999     // Read a table from AipsIO (for <src>TypedKeywords<Table></src>).
01000     // This will read the table name and open the table as writable
01001     // if the table file is writable, otherwise as readonly.
01002     friend AipsIO& operator>> (AipsIO&, Table&);
01003 
01004     // Read a table from AipsIO (for <src>TableKeywords</src>).
01005     // This will read the table name and open the table as writable
01006     // if the switch is set and if the table file is writable.
01007     // otherwise it is opened as readonly.
01008     void getTableKeyword (AipsIO&, Bool openWritable);
01009 
01010     // Write a table to ostream (for <src>TypedKeywords<Table></src>).
01011     // This only shows its name and number of columns and rows.
01012     friend ostream& operator<< (ostream&, const Table&);
01013 
01014     // Find the data manager with the given name or for the given column name.
01015     DataManager* findDataManager (const String& name,
01016                                   Bool byColumn=False) const;
01017 
01018 
01019 protected:
01020     BaseTable*  baseTabPtr_p;                 //# ptr to table representation
01021     //# The isCounted_p flag is normally true.
01022     //# Only for internally used Table objects (i.e. in the DataManager)
01023     //# this flag is False, otherwise a mutual dependency would exist.
01024     //# The DataManager has a Table object, which gets deleted by the
01025     //# DataManager destructor. The DataManager gets deleted by the
01026     //# PlainTable destructor, which gets called when the last Table
01027     //# object gets destructed. That would never be the case if this
01028     //# internally used Table object was counted.
01029     Bool        isCounted_p;
01030     //# Counter of last call to hasDataChanged.
01031     uInt        lastModCounter_p;
01032     //# Pointer to the ScratchCallback function.
01033     static ScratchCallback* scratchCallback_p;
01034 
01035 
01036     // Construct a Table object from a BaseTable*.
01037     // By default the object gets counted.
01038     Table (BaseTable*, Bool countIt = True);
01039 
01040     // Open an existing table.
01041     void open (const String& name, const String& type, int tableOption,
01042                const TableLock& lockOptions, const TSMOption& tsmOpt);
01043 
01044 
01045 private:
01046     // Construct a BaseTable object from the table file.
01047     static BaseTable* makeBaseTable (const String& name, const String& type,
01048                                      int tableOption,
01049                                      const TableLock& lockOptions,
01050                                      const TSMOption& tsmOpt,
01051                                      Bool addToCache, uInt locknr);
01052 
01053 
01054     // Get the pointer to the underlying BaseTable.
01055     // This is needed for some friend classes.
01056     BaseTable* baseTablePtr() const;
01057 
01058     // Look in the cache if the table is already open.
01059     // If so, check if table option matches.
01060     // If needed reopen the table for read/write and merge the lock options.
01061     BaseTable* lookCache (const String& name, int tableOption,
01062                           const TableLock& tableInfo);
01063 
01064     // Try if v1 is a subset of v2 and fill rows with its indices in v2.
01065     // Return False if not a proper subset.
01066     Bool fastRowNumbers (const Vector<uInt>& v1, const Vector<uInt>& v2,
01067                          Vector<uInt>& rows) const;
01068 
01069     // Show the info of the given columns.
01070     // Sort the columns if needed.
01071     void showColumnInfo (ostream& os, const TableDesc&, uInt maxNameLength,
01072                          const Array<String>& columnNames, Bool sort) const;
01073 };
01074 
01075 
01076 
01077 inline Bool Table::isSameRoot (const Table& other) const
01078     { return baseTabPtr_p->root() == other.baseTabPtr_p->root(); }
01079 
01080 inline void Table::reopenRW()
01081     { baseTabPtr_p->reopenRW(); }
01082 inline void Table::flush (Bool fsync, Bool recursive)
01083     { baseTabPtr_p->flush (fsync, recursive); }
01084 inline void Table::resync()
01085     { baseTabPtr_p->resync(); }
01086 
01087 inline Bool Table::isMultiUsed(Bool checkSubTables) const
01088     { return baseTabPtr_p->isMultiUsed(checkSubTables); }
01089 inline const TableLock& Table::lockOptions() const
01090     { return baseTabPtr_p->lockOptions(); }
01091 inline Bool Table::lock (FileLocker::LockType type, uInt nattempts)
01092     { return baseTabPtr_p->lock (type, nattempts); }
01093 inline Bool Table::lock (Bool write, uInt nattempts)
01094 {
01095     return baseTabPtr_p->lock (write ? FileLocker::Write : FileLocker::Read,
01096                                nattempts);
01097 }
01098 inline void Table::unlock()
01099     { baseTabPtr_p->unlock(); }
01100 inline Bool Table::hasLock (FileLocker::LockType type) const
01101     { return baseTabPtr_p->hasLock (type); }
01102 inline Bool Table::hasLock (Bool write) const
01103 {
01104     return baseTabPtr_p->hasLock (write ? FileLocker::Write : FileLocker::Read);
01105 }
01106 
01107 inline Bool Table::isRootTable() const
01108     { return baseTabPtr_p == baseTabPtr_p->root(); }
01109 
01110 inline Bool Table::isWritable() const
01111     { return baseTabPtr_p->isWritable(); }
01112 inline Bool Table::isColumnWritable (const String& columnName) const
01113     { return baseTabPtr_p->isColumnWritable (columnName); }
01114 inline Bool Table::isColumnWritable (uInt columnIndex) const
01115     { return baseTabPtr_p->isColumnWritable (columnIndex); }
01116 
01117 inline Bool Table::isColumnStored (const String& columnName) const
01118     { return baseTabPtr_p->isColumnStored (columnName); }
01119 inline Bool Table::isColumnStored (uInt columnIndex) const
01120     { return baseTabPtr_p->isColumnStored (columnIndex); }
01121 
01122 inline void Table::rename (const String& newName, TableOption option)
01123     { baseTabPtr_p->rename (newName, option); }
01124 inline void Table::deepCopy (const String& newName,
01125                              const Record& dataManagerInfo,
01126                              TableOption option,
01127                              Bool valueCopy,
01128                              EndianFormat endianFormat,
01129                              Bool noRows) const
01130     { baseTabPtr_p->deepCopy (newName, dataManagerInfo, option, valueCopy,
01131                               endianFormat, noRows); }
01132 inline void Table::markForDelete()
01133     { baseTabPtr_p->markForDelete (True, ""); }
01134 inline void Table::unmarkForDelete()
01135     { baseTabPtr_p->unmarkForDelete(True, ""); }
01136 inline Bool Table::isMarkedForDelete() const
01137     { return baseTabPtr_p->isMarkedForDelete(); }
01138 
01139 inline uInt Table::nrow() const
01140     { return baseTabPtr_p->nrow(); }
01141 inline BaseTable* Table::baseTablePtr() const
01142     { return baseTabPtr_p; }
01143 inline const TableDesc& Table::tableDesc() const
01144     { return baseTabPtr_p->tableDesc(); }
01145 inline const TableRecord& Table::keywordSet() const
01146     { return baseTabPtr_p->keywordSet(); }
01147 
01148 inline TableInfo Table::tableInfo (const String& tableName)
01149     { return BaseTable::tableInfo (tableName); }
01150 inline const TableInfo& Table::tableInfo() const
01151     { return baseTabPtr_p->tableInfo(); }
01152 inline TableInfo& Table::tableInfo()
01153     { return baseTabPtr_p->tableInfo(); }
01154 inline void Table::flushTableInfo() const
01155     { baseTabPtr_p->flushTableInfo(); }
01156 
01157 inline const String& Table::tableName() const
01158     { return baseTabPtr_p->tableName(); }
01159 inline Table::TableType Table::tableType() const
01160     { return TableType(baseTabPtr_p->tableType()); }
01161 inline int Table::tableOption() const
01162     { return baseTabPtr_p->tableOption(); }
01163 
01164 inline Bool Table::canAddRow() const
01165     { return baseTabPtr_p->canAddRow(); }
01166 inline Bool Table::canRemoveRow() const
01167     { return baseTabPtr_p->canRemoveRow(); }
01168 inline Bool Table::canRemoveColumn (const Vector<String>& columnNames) const
01169     { return baseTabPtr_p->canRemoveColumn (columnNames); }
01170 inline Bool Table::canRenameColumn (const String& columnName) const
01171     { return baseTabPtr_p->canRenameColumn (columnName); }
01172 
01173 inline void Table::addRow (uInt nrrow, Bool initialize)
01174     { baseTabPtr_p->addRow (nrrow, initialize); }
01175 inline void Table::removeRow (uInt rownr)
01176     { baseTabPtr_p->removeRow (rownr); }
01177 inline void Table::removeRow (const Vector<uInt>& rownrs)
01178     { baseTabPtr_p->removeRow (rownrs); }
01179 inline void Table::addColumn (const ColumnDesc& columnDesc, Bool addToParent)
01180     { baseTabPtr_p->addColumn (columnDesc, addToParent); }
01181 inline void Table::addColumn (const ColumnDesc& columnDesc,
01182                               const String& dataManager, Bool byName,
01183                               Bool addToParent)
01184     { baseTabPtr_p->addColumn (columnDesc, dataManager, byName, addToParent); }
01185 inline void Table::addColumn (const ColumnDesc& columnDesc,
01186                               const DataManager& dataManager, Bool addToParent)
01187     { baseTabPtr_p->addColumn (columnDesc, dataManager, addToParent); }
01188 inline void Table::addColumn (const TableDesc& tableDesc,
01189                               const DataManager& dataManager, Bool addToParent)
01190     { baseTabPtr_p->addColumn (tableDesc, dataManager, addToParent); }
01191 inline void Table::addColumn (const TableDesc& tableDesc,
01192                               const Record& dataManagerInfo, Bool addToParent)      { baseTabPtr_p->addColumns (tableDesc, dataManagerInfo, addToParent); }
01193 inline void Table::removeColumn (const Vector<String>& columnNames)
01194     { baseTabPtr_p->removeColumn (columnNames); }
01195 inline void Table::renameColumn (const String& newName, const String& oldName)
01196     { baseTabPtr_p->renameColumn (newName, oldName); }
01197 inline void Table::renameHypercolumn (const String& newName, const String& oldName)
01198     { baseTabPtr_p->renameHypercolumn (newName, oldName); }
01199 
01200 inline DataManager* Table::findDataManager (const String& name,
01201                                             Bool byColumn) const
01202 {
01203   return baseTabPtr_p->findDataManager (name, byColumn);
01204 }
01205 
01206 inline void Table::showStructure (std::ostream& os,
01207                                   Bool showDataMans,
01208                                   Bool showColumns,
01209                                   Bool showSubTables,
01210                                   Bool sortColumns) const
01211     { baseTabPtr_p->showStructure (os, showDataMans, showColumns,
01212                                    showSubTables, sortColumns); }
01213 
01214 
01215 
01216 } //# NAMESPACE CASA - END
01217 
01218 #endif