casacore
BaseTable.h
Go to the documentation of this file.
1 //# BaseTable.h: Abstract base class for tables
2 //# Copyright (C) 1994,1995,1996,1997,1998,2000,2001,2002,2003
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_BASETABLE_H
29 #define TABLES_BASETABLE_H
30 
31 
32 //# Includes
33 #include <casacore/casa/aips.h>
34 #include <casacore/tables/Tables/TableInfo.h>
35 #include <casacore/tables/Tables/TableDesc.h>
36 #include <casacore/tables/Tables/StorageOption.h>
37 #include <casacore/casa/Utilities/Compare.h>
38 #include <casacore/casa/Utilities/CountedPtr.h>
39 #include <casacore/casa/BasicSL/String.h>
40 #include <casacore/casa/IO/FileLocker.h>
41 
42 namespace casacore { //# NAMESPACE CASACORE - BEGIN
43 
44 //# Forward Declarations
45 class RefTable;
46 // class TableDesc; !Forward declaration not recognized SGI compiler
47 class TableLock;
48 class BaseColumn;
49 class ColumnDesc;
50 class TableRecord;
51 class Record;
52 class TableExprNode;
53 class BaseTableIterator;
54 class DataManager;
55 class IPosition;
56 template<class T> class Vector;
57 template<class T> class Block;
58 template<class T> class PtrBlock;
59 class AipsIO;
60 
61 
62 // <summary>
63 // Abstract base class for tables
64 // </summary>
65 
66 // <use visibility=local>
67 
68 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
69 // </reviewed>
70 
71 // <prerequisite>
72 //# Classes you should understand before using this one.
73 // <li> Table
74 // <li> Sort
75 // <li> TableExprNode
76 // </prerequisite>
77 
78 // <etymology>
79 // BaseTable is the (abstract) base class for different kind of tables.
80 // </etymology>
81 
82 // <synopsis>
83 // BaseTables defines many virtual functions, which are actually
84 // implemented in the underlying table classes like PlainTable and
85 // RefTable. Other functions like sort and select are implemented
86 // in BaseTable itself.
87 //
88 // The functions in BaseTable and its derived classes can only be
89 // used by the table system classes. All user access is via the
90 // envelope class Table, which references (counted) BaseTable.
91 // </synopsis>
92 
93 // <todo asof="$DATE:$">
94 //# A List of bugs, limitations, extensions or planned refinements.
95 // <li> Implement function renameColumn, removeColumn.
96 // </todo>
97 
98 
99 class BaseTable
100 {
101 public:
102 
103  // Initialize the object.
104  BaseTable (const String& tableName, int tableOption, uInt nrrow);
105 
106  virtual ~BaseTable();
107 
108  // Link to this BaseTable object (i.e. increase reference count).
109  void link();
110 
111  // Unlink from a BaseTable.
112  // Delete it if no more references.
113  static void unlink (BaseTable*);
114 
115  // Is the table a null table?
116  // By default it is not.
117  virtual Bool isNull() const;
118 
119  // Reopen the table for read/write.
120  virtual void reopenRW() = 0;
121 
122  // Is the table stored in big or little endian format?
123  virtual Bool asBigEndian() const = 0;
124 
125  // Get the storage option used for the table.
126  virtual const StorageOption& storageOption() const = 0;
127 
128  // Is the table in use (i.e. open) in another process?
129  // If <src>checkSubTables</src> is set, it is also checked if
130  // a subtable is used in another process.
131  virtual Bool isMultiUsed(Bool checkSubTables) const = 0;
132 
133  // Get the locking info.
134  virtual const TableLock& lockOptions() const = 0;
135 
136  // Merge the given lock info with the existing one.
137  virtual void mergeLock (const TableLock& lockOptions) = 0;
138 
139  // Has this process the read or write lock, thus can the table
140  // be read or written safely?
141  virtual Bool hasLock (FileLocker::LockType) const = 0;
142 
143  // Try to lock the table for read or write access.
144  virtual Bool lock (FileLocker::LockType, uInt nattempts) = 0;
145 
146  // Unlock the table. This will also synchronize the table data,
147  // thus force the data to be written to disk.
148  virtual void unlock() = 0;
149 
150  // Flush the table, i.e. write it to disk.
151  virtual void flush (Bool fsync, Bool recursive) = 0;
152 
153  // Resync the Table object with the table file.
154  virtual void resync() = 0;
155 
156  // Get the modify counter.
157  virtual uInt getModifyCounter() const = 0;
158 
159  // Set the table to being changed. By default it does nothing.
160  virtual void setTableChanged();
161 
162  // Do not write the table (used in in case of exceptions).
163  void doNotWrite()
164  { noWrite_p = True; }
165 
166  // Test if this table is writable.
167  // This tells if values can be put into a column.
168  virtual Bool isWritable() const = 0;
169 
170  // Test if the given column is writable.
171  // <group>
172  Bool isColumnWritable (const String& columnName) const;
173  Bool isColumnWritable (uInt columnIndex) const;
174  // </group>
175 
176  // Test if the given column is stored (otherwise it is virtual).
177  // <group>
178  Bool isColumnStored (const String& columnName) const;
179  Bool isColumnStored (uInt columnIndex) const;
180  // </group>
181 
182  // Get the table name.
183  const String& tableName() const
184  { return name_p; }
185 
186  // Get the names of the tables this table consists of.
187  // The default implementation adds the name of this table to the block.
188  virtual void getPartNames (Block<String>& names, Bool recursive) const;
189 
190  // Rename the table.
191  // The following options can be given:
192  // <dl>
193  // <dt> Table::Update
194  // <dd> A table with this name must already exists, which will be
195  // overwritten. When succesfully renamed, the table is unmarked
196  // for delete (if necessary).
197  // <dt> Table::New
198  // <dd> When a table with this name exists, it will be overwritten.
199  // When succesfully renamed, the table is unmarked
200  // for delete (if necessary).
201  // <dt> Table::NewNoReplace
202  // <dd> When a table with this name already exists, an exception
203  // is thrown. When succesfully renamed, the table
204  // is unmarked for delete (if necessary).
205  // <dt> Table::Scratch
206  // <dd> Same as Table::New, but followed by markForDelete().
207  // </dl>
208  // The rename function in this base class renames the table file.
209  // In a derived class (e.g. PlainTable) the function should also
210  // be implemented to rename subtables in its keywords.
211  virtual void rename (const String& newName, int tableOption);
212 
213  // Copy the table and all its subtables.
214  // The default implementation of deepCopy is to call copy.
215  // The following options can be given:
216  // <dl>
217  // <dt> Table::New
218  // <dd> When a table with this name exists, it will be overwritten.
219  // <dt> Table::NewNoReplace
220  // <dd> When a table with this name already exists, an exception
221  // is thrown.
222  // <dt> Table::Scratch
223  // <dd> Same as Table::New, but followed by markForDelete().
224  // </dl>
225  // <group>
226  virtual void copy (const String& newName, int tableOption) const;
227  virtual void deepCopy (const String& newName,
228  const Record& dataManagerInfo,
229  const StorageOption&,
230  int tableOption,
231  Bool valueCopy,
232  int endianFormat,
233  Bool noRows) const;
234  // </group>
235 
236  // Get the table type.
237  // By default it returns Table::Plain.
238  virtual int tableType() const;
239 
240  // Get the table option.
241  int tableOption() const
242  { return option_p; }
243 
244  // Mark the table for delete.
245  // This means that the underlying table gets deleted when it is
246  // actually destructed.
247  // The scratchCallback function is called when needed.
248  void markForDelete (Bool callback, const String& oldName);
249 
250  // Unmark the table for delete.
251  // This means the underlying table does not get deleted when destructed.
252  // The scratchCallback function is called when needed.
253  void unmarkForDelete (Bool callback, const String& oldName);
254 
255  // Test if the table is marked for delete.
257  { return delete_p; }
258 
259  // Get the table description.
260  const TableDesc& tableDesc() const
261  { return (tdescPtr_p == 0 ? makeTableDesc() : *tdescPtr_p); }
262 
263  // Get the actual table description.
264  virtual TableDesc actualTableDesc() const = 0;
265 
266  // Get the data manager info.
267  virtual Record dataManagerInfo() const = 0;
268 
269  // Show the table structure (implementation of Table::showStructure).
270  void showStructure (std::ostream&,
271  Bool showDataMan,
272  Bool showColumns,
273  Bool showSubTables,
274  Bool sortColumns,
275  Bool cOrder);
276 
277  // Get readonly access to the table keyword set.
278  virtual TableRecord& keywordSet() = 0;
279 
280  // Get read/write access to the table keyword set.
281  // This requires that the table is locked (or it gets locked
282  // when using AutoLocking mode).
283  virtual TableRecord& rwKeywordSet() = 0;
284 
285  // Get access to the TableInfo object.
287  { return info_p; }
288 
289  // Get the table info of the table with the given name.
290  // An empty object is returned when the table is unknown.
291  static TableInfo tableInfo (const String& tableName);
292 
293  // Write the TableInfo object.
294  virtual void flushTableInfo();
295 
296  // Get number of rows.
297  uInt nrow() const
298  { return nrrow_p; }
299 
300  // Get a column object using its index.
301  virtual BaseColumn* getColumn (uInt columnIndex) const = 0;
302 
303  // Get a column object using its name.
304  virtual BaseColumn* getColumn (const String& columnName) const = 0;
305 
306  // Test if it is possible to add a row to this table.
307  virtual Bool canAddRow() const;
308 
309  // Add one or more rows and possibly initialize them.
310  // This will fail for tables not supporting addition of rows.
311  virtual void addRow (uInt nrrow = 1, Bool initialize = True);
312 
313  // Test if it is possible to remove a row from this table.
314  virtual Bool canRemoveRow() const;
315 
316  // Remove rows.
317  // This will fail for tables not supporting removal of rows.
318  // <note role=tip>
319  // The following code fragments do NOT have the same result:
320  // <srcblock>
321  // tab.removeRow (10); // remove row 10
322  // tab.removeRow (20); // remove row 20, which was 21
323  //
324  // Vector<uInt> vec(2);
325  // vec(0) = 10;
326  // vec(1) = 20;
327  // tab.removeRow (vec); // remove row 10 and 20
328  // </srcblock>
329  // because in the first fragment removing row 10 turns the former
330  // row 21 into row 20.
331  // </note>
332  // <group>
333  virtual void removeRow (uInt rownr);
334  void removeRow (const Vector<uInt>& rownrs);
335  // </group>
336 
337  // Find the data manager with the given name or for the given column.
338  virtual DataManager* findDataManager (const String& name,
339  Bool byColumn) const = 0;
340 
341  // Select rows using the given expression (which can be null).
342  // Skip first <src>offset</src> matching rows.
343  // Return at most <src>maxRow</src> matching rows.
344  BaseTable* select (const TableExprNode&, uInt maxRow, uInt offset);
345 
346  // Select maxRow rows and skip first offset rows. maxRow=0 means all.
347  BaseTable* select (uInt maxRow, uInt offset);
348 
349  // Select rows using a vector of row numbers.
350  BaseTable* select (const Vector<uInt>& rownrs);
351 
352  // Select rows using a mask block.
353  // The length of the block must match the number of rows in the table.
354  // If True, the corresponding row will be selected.
355  BaseTable* select (const Block<Bool>& mask);
356 
357  // Project the given columns (i.e. select the columns).
358  BaseTable* project (const Block<String>& columnNames);
359 
360  //# Virtually concatenate all tables in this column.
361  //# The column cells must contain tables with the same description.
362 //#// BaseTable* concatenate (const String& columnName);
363 
364  // Do logical operations on a table.
365  // <group>
366  // intersection with another table
368  // union with another table
370  // subtract another table
372  // xor with another table
374  // take complement
375  BaseTable* tabNot ();
376  // </group>
377 
378  // Sort a table on one or more columns of scalars.
379  BaseTable* sort (const Block<String>& columnNames,
380  const Block<CountedPtr<BaseCompare> >& compareObjects,
381  const Block<Int>& sortOrder, int sortOption);
382 
383  // Create an iterator.
384  BaseTableIterator* makeIterator (const Block<String>& columnNames,
386  const Block<Int>& orders, int option);
387 
388  // Add one or more columns to the table.
389  // The default implementation throws an "invalid operation" exception.
390  // <group>
391  virtual void addColumn (const ColumnDesc& columnDesc, Bool addToParent);
392  virtual void addColumn (const ColumnDesc& columnDesc,
393  const String& dataManager, Bool byName,
394  Bool addToParent);
395  virtual void addColumn (const ColumnDesc& columnDesc,
396  const DataManager& dataManager, Bool addToParent);
397  virtual void addColumn (const TableDesc& tableDesc,
398  const DataManager& dataManager, Bool addToParent);
399  // </group>
400 
401  // Add one or more columns to the table.
402  // The data manager to use is described in the record.
403  void addColumns (const TableDesc& tableDesc, const Record& dmInfo,
404  Bool addToParent);
405 
406  // Test if columns can be removed.
407  virtual Bool canRemoveColumn (const Vector<String>& columnNames) const = 0;
408 
409  // Remove columns.
410  virtual void removeColumn (const Vector<String>& columnNames) = 0;
411 
412  // Check if the set of columns can be removed.
413  // It checks if columns have not been specified twice and it
414  // checks if they exist.
415  // If the flag is set an exception is thrown if errors are found.
416  Bool checkRemoveColumn (const Vector<String>& columnNames,
417  Bool throwException) const;
418 
419  // Test if a column can be renamed.
420  virtual Bool canRenameColumn (const String& columnName) const = 0;
421 
422  // Rename a column.
423  virtual void renameColumn (const String& newName,
424  const String& oldName) = 0;
425 
426  // Rename a hypercolumn.
427  virtual void renameHypercolumn (const String& newName,
428  const String& oldName) = 0;
429 
430  // Get a vector of row numbers.
431  // By default it returns the row numbers 0..nrrow()-1.
432  // It needs to be implemented for RefTable only.
433  virtual Vector<uInt> rowNumbers() const;
434 
435  // Get pointer to root table (i.e. parent of a RefTable).
436  // Default it is this table.
437  // It is meant for the reference tables after a select or sort which
438  // can then still name their parent as the root.
439  virtual BaseTable* root();
440 
441  // Tell if the table is in row order.
442  // By default it is, since normally a table is always in row order.
443  // It is meant for RefTable-s, where the rows can be in
444  // another (sorted) order.
445  virtual Bool rowOrder() const;
446 
447  // By the default the table cannot return the storage of rownrs.
448  // That can only be done by a RefTable, where it is implemented.
449  virtual Vector<uInt>* rowStorage();
450 
451  // Adjust the row numbers to be the actual row numbers in the
452  // root table. This is, for instance, used when a RefTable is sorted.
453  // Optionally it also determines if the resulting rows are in order.
454  virtual Bool adjustRownrs (uInt nrrow, Vector<uInt>& rownrs,
455  Bool determineOrder) const;
456 
457  // Do the actual sort.
458  // The default implementation is suitable for almost all cases.
459  // Only in RefTable a smarter implementation is provided.
462  const Block<Int>& sortOrder,
463  int sortOption);
464 
465  // Create a RefTable object.
466  RefTable* makeRefTable (Bool rowOrder, uInt initialNrrow);
467 
468  // Check if the row number is valid.
469  // It throws an exception if out of range.
470  void checkRowNumber (uInt rownr) const
471  { if (rownr >= nrrow_p + nrrowToAdd_p) checkRowNumberThrow (rownr); }
472 
473  // Get the table's trace-id.
474  int traceId() const
475  { return itsTraceId; }
476 
477 
478 protected:
479  uInt nrlink_p; //# #references to this table
480  uInt nrrow_p; //# #rows in this table
481  uInt nrrowToAdd_p; //# #rows to be added
482  TableDesc* tdescPtr_p; //# Pointer to table description
483  String name_p; //# table name
484  int option_p; //# Table constructor option
485  Bool noWrite_p; //# False = do not write the table
486  Bool delete_p; //# True = delete when destructed
487  TableInfo info_p; //# Table information (type, etc.)
488  Bool madeDir_p; //# True = table dir has been created
489  int itsTraceId; //# table-id for TableTrace tracing
490 
491 
492  // Do the callback for scratch tables (if callback is set).
493  void scratchCallback (Bool isScratch, const String& oldName) const;
494 
495  // Create the table directory when needed (and possible).
496  // When the file already exists, check if it is a directory.
497  // It returns True when it actually created the directory.
498  Bool makeTableDir();
499 
500  // Make a true deep copy of the table.
501  void trueDeepCopy (const String& newName,
502  const Record& dataManagerInfo,
503  const StorageOption&,
504  int tableOption,
505  int endianFormat,
506  Bool noRows) const;
507 
508  // Prepare for copying or renaming a table.
509  // It checks if the target table already exists and removes it
510  // when necessary.
511  void prepareCopyRename (const String& newName, int tableOption) const;
512 
513  // Rename the subtables (used by rename function).
514  virtual void renameSubTables (const String& newName,
515  const String& oldName);
516 
517  // Check if the table already exists.
518  // Throw an exception if so.
519  void throwIfTableExists();
520 
521  // Test if the table is opened for write.
522  Bool openedForWrite() const;
523 
524  // Start writing a table. It does a putstart and writes <src>nrrow_p</src>.
525  // It should be ended by calling <src>writeEnd</src>.
526  void writeStart (AipsIO&, Bool bigEndian);
527 
528  // End writing a table.
529  void writeEnd (AipsIO&);
530 
531  // Should the table be written.
532  // This flag is False if an exception was thrown.
534  { return noWrite_p; }
535 
536  // Read the TableInfo object.
537  void getTableInfo();
538 
539 private:
540  // Copy constructor is forbidden, because copying a table requires
541  // some more knowledge (like table name of result).
542  // Declaring it private, makes it unusable.
543  BaseTable (const BaseTable&);
544 
545  // Assignment is forbidden, because copying a table requires
546  // some more knowledge (like table name of result).
547  // Declaring it private, makes it unusable.
548  BaseTable& operator= (const BaseTable&);
549 
550  // Show a possible extra table structure header.
551  // It is used by e.g. RefTable to show which table is referenced.
552  virtual void showStructureExtra (std::ostream&) const;
553 
554  // Show the info of the given columns.
555  // Sort the columns if needed.
556  void showColumnInfo (ostream& os, const TableDesc&, uInt maxNameLength,
557  const Array<String>& columnNames, Bool sort,
558  Bool cOrder) const;
559 
560  // Throw an exception for checkRowNumber.
561  void checkRowNumberThrow (uInt rownr) const;
562 
563  // Check if the tables combined in a logical operation have the
564  // same root.
565  void logicCheck (BaseTable* that);
566 
567  // Get the rownrs of the table in ascending order to be
568  // used in the logical operation on the table.
569  uInt logicRows (uInt*& rownrs, Bool& allocated);
570 
571  // Make an empty table description.
572  // This is used if one asks for the description of a NullTable.
573  // Creating an empty TableDesc in the NullTable takes too much time.
574  // Furthermore it causes static initialization order problems.
575  const TableDesc& makeTableDesc() const;
576 
577  // Make the name absolute.
578  // It first checks if the name contains valid characters (not only . and /).
579  String makeAbsoluteName (const String& name) const;
580 };
581 
582 
583 
584 
585 } //# NAMESPACE CASACORE - END
586 
587 #endif
BaseTable * select(const TableExprNode &, uInt maxRow, uInt offset)
Select rows using the given expression (which can be null).
void scratchCallback(Bool isScratch, const String &oldName) const
Do the callback for scratch tables (if callback is set).
virtual void renameHypercolumn(const String &newName, const String &oldName)=0
Rename a hypercolumn.
const String & tableName() const
Get the table name.
Definition: BaseTable.h:183
TableInfo info_p
Definition: BaseTable.h:487
Bool openedForWrite() const
Test if the table is opened for write.
virtual const StorageOption & storageOption() const =0
Get the storage option used for the table.
virtual DataManager * findDataManager(const String &name, Bool byColumn) const =0
Find the data manager with the given name or for the given column.
const TableDesc & tableDesc() const
Get the table description.
Definition: BaseTable.h:260
virtual Bool rowOrder() const
Tell if the table is in row order.
virtual void copy(const String &newName, int tableOption) const
Copy the table and all its subtables.
LatticeExprNode mask(const LatticeExprNode &expr)
This function returns the mask of the given expression.
virtual void mergeLock(const TableLock &lockOptions)=0
Merge the given lock info with the existing one.
AipsIO is the object persistency mechanism of Casacore.
Definition: AipsIO.h:168
virtual Bool canRenameColumn(const String &columnName) const =0
Test if a column can be renamed.
void prepareCopyRename(const String &newName, int tableOption) const
Prepare for copying or renaming a table.
int traceId() const
Get the table&#39;s trace-id.
Definition: BaseTable.h:474
virtual void reopenRW()=0
Reopen the table for read/write.
Handle class for a table column expression tree.
Definition: ExprNode.h:614
BaseTable * tabXor(BaseTable *)
xor with another table
Envelope class for the description of a table column.
Definition: ColumnDesc.h:131
void checkRowNumber(uInt rownr) const
Check if the row number is valid.
Definition: BaseTable.h:470
virtual const TableLock & lockOptions() const =0
Get the locking info.
virtual void addRow(uInt nrrow=1, Bool initialize=True)
Add one or more rows and possibly initialize them.
void unmarkForDelete(Bool callback, const String &oldName)
Unmark the table for delete.
Base class for table iterator.
Definition: BaseTabIter.h:83
BaseTable * tabOr(BaseTable *)
union with another table
virtual uInt getModifyCounter() const =0
Get the modify counter.
virtual TableDesc actualTableDesc() const =0
Get the actual table description.
BaseTable * tabSub(BaseTable *)
subtract another table
Bool shouldNotWrite() const
Should the table be written.
Definition: BaseTable.h:533
virtual void rename(const String &newName, int tableOption)
Rename the table.
void getTableInfo()
Read the TableInfo object.
virtual Bool lock(FileLocker::LockType, uInt nattempts)=0
Try to lock the table for read or write access.
virtual void renameSubTables(const String &newName, const String &oldName)
Rename the subtables (used by rename function).
void writeEnd(AipsIO &)
End writing a table.
uInt logicRows(uInt *&rownrs, Bool &allocated)
Get the rownrs of the table in ascending order to be used in the logical operation on the table...
Bool checkRemoveColumn(const Vector< String > &columnNames, Bool throwException) const
Check if the set of columns can be removed.
int tableOption() const
Get the table option.
Definition: BaseTable.h:241
Bool makeTableDir()
Create the table directory when needed (and possible).
void markForDelete(Bool callback, const String &oldName)
Mark the table for delete.
String makeAbsoluteName(const String &name) const
Make the name absolute.
Options defining how table files are organized.
Definition: StorageOption.h:71
RefTable * makeRefTable(Bool rowOrder, uInt initialNrrow)
Create a RefTable object.
virtual void getPartNames(Block< String > &names, Bool recursive) const
Get the names of the tables this table consists of.
virtual BaseTable * root()
Get pointer to root table (i.e.
virtual Vector< uInt > * rowStorage()
By the default the table cannot return the storage of rownrs.
BaseTableIterator * makeIterator(const Block< String > &columnNames, const Block< CountedPtr< BaseCompare > > &, const Block< Int > &orders, int option)
Create an iterator.
BaseTable & operator=(const BaseTable &)
Assignment is forbidden, because copying a table requires some more knowledge (like table name of res...
void checkRowNumberThrow(uInt rownr) const
Throw an exception for checkRowNumber.
Referenced counted pointer for constant data.
Definition: CountedPtr.h:86
Abstract base class for tables.
Definition: BaseTable.h:99
Class for a table as a view of another table.
Definition: RefTable.h:104
Bool isMarkedForDelete() const
Test if the table is marked for delete.
Definition: BaseTable.h:256
virtual void deepCopy(const String &newName, const Record &dataManagerInfo, const StorageOption &, int tableOption, Bool valueCopy, int endianFormat, Bool noRows) const
virtual BaseTable * doSort(PtrBlock< BaseColumn *> &, const Block< CountedPtr< BaseCompare > > &, const Block< Int > &sortOrder, int sortOption)
Do the actual sort.
virtual TableRecord & rwKeywordSet()=0
Get read/write access to the table keyword set.
virtual int tableType() const
Get the table type.
static void unlink(BaseTable *)
Unlink from a BaseTable.
void showColumnInfo(ostream &os, const TableDesc &, uInt maxNameLength, const Array< String > &columnNames, Bool sort, Bool cOrder) const
Show the info of the given columns.
virtual void removeColumn(const Vector< String > &columnNames)=0
Remove columns.
uInt nrow() const
Get number of rows.
Definition: BaseTable.h:297
BaseTable * tabAnd(BaseTable *)
Do logical operations on a table.
virtual void unlock()=0
Unlock the table.
A hierarchical collection of named fields of various types.
Definition: Record.h:180
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
virtual Bool isWritable() const =0
Test if this table is writable.
virtual void removeRow(uInt rownr)
Remove rows.
BaseTable * project(const Block< String > &columnNames)
Project the given columns (i.e.
Bool isColumnStored(const String &columnName) const
Test if the given column is stored (otherwise it is virtual).
Bool isColumnWritable(const String &columnName) const
Test if the given column is writable.
void logicCheck(BaseTable *that)
Check if the tables combined in a logical operation have the same root.
Table type, subtype and further info.
Definition: TableInfo.h:130
virtual BaseColumn * getColumn(uInt columnIndex) const =0
Get a column object using its index.
Class to hold table lock options.
Definition: TableLock.h:65
void trueDeepCopy(const String &newName, const Record &dataManagerInfo, const StorageOption &, int tableOption, int endianFormat, Bool noRows) const
Make a true deep copy of the table.
A drop-in replacement for Block<T*>.
Definition: Block.h:861
virtual void resync()=0
Resync the Table object with the table file.
A hierarchical collection of named fields of various types.
Definition: TableRecord.h:182
template <class T, class U> class vector;
Definition: Array.h:169
simple 1-D array
Definition: ArrayIO.h:47
virtual Bool canRemoveColumn(const Vector< String > &columnNames) const =0
Test if columns can be removed.
BaseTable * sort(const Block< String > &columnNames, const Block< CountedPtr< BaseCompare > > &compareObjects, const Block< Int > &sortOrder, int sortOption)
Sort a table on one or more columns of scalars.
virtual Bool isNull() const
Is the table a null table? By default it is not.
Abstract base class for a data manager.
Definition: DataManager.h:222
virtual Bool canRemoveRow() const
Test if it is possible to remove a row from this table.
virtual Record dataManagerInfo() const =0
Get the data manager info.
BaseTable * tabNot()
take complement
virtual void flushTableInfo()
Write the TableInfo object.
void writeStart(AipsIO &, Bool bigEndian)
Start writing a table.
virtual Bool adjustRownrs(uInt nrrow, Vector< uInt > &rownrs, Bool determineOrder) const
Adjust the row numbers to be the actual row numbers in the root table.
virtual void flush(Bool fsync, Bool recursive)=0
Flush the table, i.e.
String: the storage and methods of handling collections of characters.
Definition: String.h:223
virtual Bool isMultiUsed(Bool checkSubTables) const =0
Is the table in use (i.e.
void addColumns(const TableDesc &tableDesc, const Record &dmInfo, Bool addToParent)
Add one or more columns to the table.
virtual void renameColumn(const String &newName, const String &oldName)=0
Rename a column.
virtual Vector< uInt > rowNumbers() const
Get a vector of row numbers.
Define the structure of a Casacore table.
Definition: TableDesc.h:186
virtual void addColumn(const ColumnDesc &columnDesc, Bool addToParent)
Add one or more columns to the table.
void showStructure(std::ostream &, Bool showDataMan, Bool showColumns, Bool showSubTables, Bool sortColumns, Bool cOrder)
Show the table structure (implementation of Table::showStructure).
TableDesc * tdescPtr_p
Definition: BaseTable.h:482
LockType
Define the possible lock types.
Definition: FileLocker.h:95
virtual void showStructureExtra(std::ostream &) const
Show a possible extra table structure header.
void link()
Link to this BaseTable object (i.e.
const TableDesc & makeTableDesc() const
Make an empty table description.
const Bool True
Definition: aipstype.h:43
virtual Bool canAddRow() const
Test if it is possible to add a row to this table.
virtual Bool asBigEndian() const =0
Is the table stored in big or little endian format?
virtual Bool hasLock(FileLocker::LockType) const =0
Has this process the read or write lock, thus can the table be read or written safely?
this file contains all the compiler specific defines
Definition: mainpage.dox:28
TableInfo & tableInfo()
Get access to the TableInfo object.
Definition: BaseTable.h:286
virtual void setTableChanged()
Set the table to being changed.
void doNotWrite()
Do not write the table (used in in case of exceptions).
Definition: BaseTable.h:163
unsigned int uInt
Definition: aipstype.h:51
BaseTable(const String &tableName, int tableOption, uInt nrrow)
Initialize the object.
void throwIfTableExists()
Check if the table already exists.
Abstract base class for a table column.
Definition: BaseColumn.h:98
virtual TableRecord & keywordSet()=0
Get readonly access to the table keyword set.