28 #ifndef TABLES_TABLE_H
29 #define TABLES_TABLE_H
33 #include <casacore/casa/aips.h>
34 #include <casacore/tables/Tables/BaseTable.h>
35 #include <casacore/tables/Tables/TableLock.h>
36 #include <casacore/tables/Tables/RowNumbers.h>
37 #include <casacore/tables/DataMan/TSMOption.h>
38 #include <casacore/casa/Arrays/ArrayFwd.h>
39 #include <casacore/casa/Containers/Record.h>
40 #include <casacore/casa/Utilities/DataType.h>
41 #include <casacore/casa/Utilities/Sort.h>
58 template<
class T>
class Block;
59 template<
class T>
class CountedPtr;
478 {
return (baseTabPtr_p == 0 ?
True : baseTabPtr_p->isNull()); }
516 Int maxVal=25)
const;
1012 __attribute__ ((deprecated ("Now use TableUtil::
openTable")));
1018 __attribute__ ((deprecated ("Now use TableUtil::
openTable")));
1022 __attribute__ ((deprecated ("Now use TableUtil::
canDeleteTable")));
1026 __attribute__ ((deprecated ("Now use TableUtil::
canDeleteTable")));
1030 __attribute__ ((deprecated ("Now use TableUtil::
deleteTable")));
1033 __attribute__ ((deprecated ("Now use TableUtil::
getLayout")));
1036 __attribute__ ((deprecated ("Now use TableUtil::
tableInfo")));
1051 uInt lastModCounter_p;
1090 void showColumnInfo (ostream& os, const
TableDesc&,
uInt maxNameLength,
1097 {
return baseTabPtr_p->root() == other.baseTabPtr_p->root(); }
1100 { baseTabPtr_p->reopenRW(); }
1102 { baseTabPtr_p->flush (fsync, recursive); }
1104 { baseTabPtr_p->resync(); }
1107 {
return baseTabPtr_p->storageOption(); }
1109 {
return baseTabPtr_p->isMultiUsed(checkSubTables); }
1111 {
return baseTabPtr_p->lockOptions(); }
1113 {
return baseTabPtr_p->lock (type, nattempts); }
1120 { baseTabPtr_p->unlock(); }
1122 {
return baseTabPtr_p->hasLock (type); }
1129 {
return baseTabPtr_p == baseTabPtr_p->root(); }
1132 {
return baseTabPtr_p->isWritable(); }
1134 {
return baseTabPtr_p->isColumnWritable (columnName); }
1136 {
return baseTabPtr_p->isColumnWritable (columnIndex); }
1139 {
return baseTabPtr_p->isColumnStored (columnName); }
1141 {
return baseTabPtr_p->isColumnStored (columnIndex); }
1144 { baseTabPtr_p->rename (newName, option); }
1165 { baseTabPtr_p->markForDelete (
True,
""); }
1167 { baseTabPtr_p->unmarkForDelete(
True,
""); }
1169 {
return baseTabPtr_p->isMarkedForDelete(); }
1172 {
return baseTabPtr_p->nrow(); }
1173 inline BaseTable* Table::baseTablePtr()
const
1174 {
return baseTabPtr_p; }
1176 {
return baseTabPtr_p->tableDesc(); }
1178 {
return baseTabPtr_p->keywordSet(); }
1181 {
return baseTabPtr_p->tableInfo(); }
1183 {
return baseTabPtr_p->tableInfo(); }
1185 { baseTabPtr_p->flushTableInfo(); }
1188 {
return baseTabPtr_p->tableName(); }
1190 {
return TableType(baseTabPtr_p->tableType()); }
1192 {
return baseTabPtr_p->tableOption(); }
1195 {
return baseTabPtr_p->canAddRow(); }
1197 {
return baseTabPtr_p->canRemoveRow(); }
1199 {
return baseTabPtr_p->canRemoveColumn (columnNames); }
1201 {
return baseTabPtr_p->canRenameColumn (columnName); }
1204 { baseTabPtr_p->addRow (nrrow, initialize); }
1206 { baseTabPtr_p->removeRow (rownr); }
1208 { baseTabPtr_p->removeRow (rownrs); }
1210 { baseTabPtr_p->addColumn (columnDesc, addToParent); }
1214 { baseTabPtr_p->addColumn (columnDesc, dataManager, byName, addToParent); }
1217 { baseTabPtr_p->addColumn (columnDesc, dataManager, addToParent); }
1220 { baseTabPtr_p->addColumn (
tableDesc, dataManager, addToParent); }
1224 { baseTabPtr_p->removeColumn (columnNames); }
1226 { baseTabPtr_p->renameColumn (newName, oldName); }
1228 { baseTabPtr_p->renameHypercolumn (newName, oldName); }
1231 Bool byColumn)
const
1233 return baseTabPtr_p->findDataManager (name, byColumn);
1242 { baseTabPtr_p->showStructure (os, showDataMans, showColumns,
1243 showSubTables, sortColumns, cOrder); }
Referenced counted pointer for constant data.
Abstract base class for a data manager.
LockType
Define the possible lock types.
@ Write
Acquire a write lock.
@ Read
Acquire a read lock.
Create a new table - define shapes, data managers, etc.
String: the storage and methods of handling collections of characters.
Abstract base class for a node in a table column expression tree.
LockOption
Define the possible table locking options.
static Bool isOpened(const String &tableName)
Is the table used (i.e.
Table(SetupNewTable &, const TableLock &lockOptions, rownr_t nrrow=0, Bool initialize=False, EndianFormat=Table::AipsrcEndian, const TSMOption &=TSMOption())
Table(SetupNewTable &, TableType, rownr_t nrrow=0, Bool initialize=False, EndianFormat=Table::AipsrcEndian, const TSMOption &=TSMOption())
void copy(const String &newName, TableOption, Bool noRows=False) const
Copy the table and all its subtables.
Bool hasLock(FileLocker::LockType=FileLocker::Write) const
Has this process the read or write lock, thus can the table be read or written safely?
const TableLock & lockOptions() const
Get the locking options.
void unlock()
Unlock the table.
void renameHypercolumn(const String &newName, const String &oldName)
Table(const Block< Table > &tables, const Block< String > &subTables=Block< String >(), const String &subDirName=String())
Create a table object as the virtual concatenation of one or more of existing tables.
Bool isMarkedForDelete() const
Test if the table is marked for delete.
TableType tableType() const
Get the table type.
Table(const String &tableName, const String &tableDescName, const TableLock &lockOptions, TableOption=Table::Old, const TSMOption &=TSMOption())
Table sort(const Block< String > &columnNames, const Block< CountedPtr< BaseCompare > > &compareObjects, const Block< Int > &sortOrders, int=Sort::ParSort) const
Sort on multiple columns.
int tableOption() const
Get the table option.
void ScratchCallback(const String &name, Bool isScratch, const String &oldName)
Define the signature of the function being called when the state of a scratch table changes (i....
Bool isNull() const
Test if the object is null, i.e.
Table sort(const String &columnName, int=Sort::Ascending, int=Sort::ParSort) const
Sort a table on one or more columns of scalars.
Table(const String &tableName, const String &tableDescName, TableOption=Table::Old, const TSMOption &=TSMOption())
Table & operator=(const Table &)
Assignment (reference semantics).
Bool isColumnWritable(const String &columnName) const
Test if the given column is writable.
static Bool isNativeDataType(DataType dtype)
Test if the given data type is native to the table system.
void unmarkForDelete()
Unmark the table for delete.
Table operator()(const TableExprNode &, rownr_t maxRow=0, rownr_t offset=0) const
Select rows from a table using an select expression consisting of TableExprNode objects.
const TableDesc & tableDesc() const
Get the table description.
Table(MPI_Comm mpiComm, SetupNewTable &, TableType, const TableLock &lockOptions, rownr_t nrrow=0, Bool initialize=False, EndianFormat=Table::AipsrcEndian, const TSMOption &=TSMOption())
TableRecord & rwKeywordSet()
Get read/write access to the table keyword set.
static String fileName(const String &tableName)
Make the table file name.
void closeSubTables() const
Close all open subtables.
Bool isSameRoot(const Table &other) const
Is the root table of this table the same as that of the other one?
DataManager * findDataManager(const String &name, Bool byColumn=False) const
Find the data manager with the given name or for the given column name.
static ScratchCallback * setScratchCallback(ScratchCallback *)
Set the pointer to the ScratchCallback function.
void renameColumn(const String &newName, const String &oldName)
Rename a column.
Table(MPI_Comm mpiComm, SetupNewTable &, rownr_t nrrow=0, Bool initialize=False, EndianFormat=Table::AipsrcEndian, const TSMOption &=TSMOption())
Table(TableType, EndianFormat=Table::AipsrcEndian, const TSMOption &=TSMOption())
Make a new empty table (plain (scratch) or memory type).
const String & tableName() const
Get the table name.
Table(const Block< String > &tableNames, const Block< String > &subTables, const TableLock &lockOptions, TableOption=Table::Old, const TSMOption &=TSMOption())
Bool canRemoveRow() const
Test if it is possible to remove a row from this table.
RowNumbers rowNumbers() const
Get a vector of row numbers in the root table of rows in this table.
EndianFormat
Define the possible endian formats in which table data can be stored.
@ AipsrcEndian
use endian format defined in the aipsrc variable table.endianformat If undefined, it defaults to Loca...
@ LocalEndian
store data in the endian format of the machine used
@ BigEndian
store table data in big endian (e.g.
@ LittleEndian
store table data in little endian (e.g.
static uInt nAutoLocks()
Determine the number of locked tables opened with the AutoLock option (Locked table means locked for ...
TableOption
Define the possible options how a table can be opened.
@ Scratch
new table, which gets marked for delete
@ Update
update existing table
@ NewNoReplace
create table (may not exist)
rownr_t nrow() const
Get the number of rows.
static Bool isWritable(const String &tableName, bool throwIf=False)
Test if a table with the given name exists and is writable.
Table(SetupNewTable &, TableLock::LockOption, rownr_t nrrow=0, Bool initialize=False, EndianFormat=Table::AipsrcEndian, const TSMOption &=TSMOption())
void flushTableInfo() const
Write the TableInfo object.
Bool canAddRow() const
Test if it is possible to add a row to this table.
Bool lock(FileLocker::LockType=FileLocker::Write, uInt nattempts=0)
Try to lock the table for read or write access (default is write).
Bool hasDataChanged()
Determine if column or keyword table data have changed (or is being changed) since the last time this...
Table operator&(const Table &) const
Do logical operations on a table.
static Bool isReadable(const String &tableName, bool throwIf=False)
Test if a table with the given name exists and is readable.
void rename(const String &newName, TableOption)
Rename the table and all its subtables.
friend AipsIO & operator<<(AipsIO &, const Table &)
Write a table to AipsIO (for TypedKeywords<Table>).
TableExprNode key(const String &keywordName) const
Create a TableExprNode object for a column or for a keyword in the table keyword set.
void flush(Bool fsync=False, Bool recursive=False)
Flush the table, i.e.
Bool canRemoveColumn(const String &columnName) const
Test if columns can be removed.
void markForDelete()
Mark the table for delete.
static void relinquishAutoLocks(Bool all=False)
Unlock locked tables opened with the AutoLock option.
Bool isColumnStored(const String &columnName) const
Test if the given column is stored (otherwise it is virtual).
TableExprNode nodeRownr(rownr_t origin=0) const
Create a TableExprNode object for the rownumber function.
const StorageOption & storageOption() const
Get the storage option used for the table.
Table copyToMemoryTable(const String &name, Bool noRows=False) const
Make a copy of a table to a MemoryTable object.
Table(SetupNewTable &, TableType, const TableLock &lockOptions, rownr_t nrrow=0, Bool initialize=False, EndianFormat=Table::AipsrcEndian, const TSMOption &=TSMOption())
void removeColumn(const String &columnName)
Remove columns.
void showStructure(std::ostream &, Bool showDataMans=True, Bool showColumns=True, Bool showSubTables=False, Bool sortColumns=False, Bool cOrder=False) const
Show the structure of the table.
const TableRecord & keywordSet() const
Get readonly access to the table keyword set.
TableExprNode nodeRandom() const
Create a TableExprNode object for the rand function.
Table operator!() const
Take complement.
Table(const String &tableName, TableOption=Table::Old, const TSMOption &=TSMOption())
Create a table object for an existing table.
Table(MPI_Comm mpiComm, SetupNewTable &, TableLock::LockOption, rownr_t nrrow=0, Bool initialize=False, EndianFormat=Table::AipsrcEndian, const TSMOption &=TSMOption())
Table operator^(const Table &) const
Xor with another table.
void getTableKeyword(AipsIO &, Bool openWritable)
Read a table from AipsIO (for TableKeywords).
void removeRow(rownr_t rownr)
Remove the given row(s).
Table operator|(const Table &) const
Union with another table.
void throwIfNull() const
Throw an exception if the object is null, i.e.
friend AipsIO & operator>>(AipsIO &, Table &)
Read a table from AipsIO (for TypedKeywords<Table>).
Bool isMultiUsed(Bool checkSubTables=False) const
Is the table used (i.e.
Bool isWritable() const
Test if this table is opened as writable.
Table::EndianFormat endianFormat() const
Get the endian format in which the table is stored.
void resync()
Resynchronize the Table object with the table file.
Bool canRenameColumn(const String &columnName) const
Test if a column can be renamed.
void reopenRW()
Try to reopen the table for read/write access.
TableDesc actualTableDesc() const
Table(MPI_Comm mpiComm, SetupNewTable &, const TableLock &lockOptions, rownr_t nrrow=0, Bool initialize=False, EndianFormat=Table::AipsrcEndian, const TSMOption &=TSMOption())
TableType
Define the possible table types.
@ Plain
plain table (stored on disk)
const TableInfo & tableInfo() const
Get access to the TableInfo object.
Table sort(const Block< String > &columnNames, const Block< Int > &sortOrders, int=Sort::ParSort) const
Sort on multiple columns.
void deepCopy(const String &newName, TableOption, Bool valueCopy=False, EndianFormat=AipsrcEndian, Bool noRows=False) const
virtual ~Table()
The destructor flushes (i.e.
void addRow(rownr_t nrrow=1, Bool initialize=False)
Add one or more rows at the end of the table.
Table(const Table &)
Copy constructor (reference semantics).
Bool isRootTable() const
Test if this table is the root table (ie.
Table(MPI_Comm mpiComm, TableType, EndianFormat=Table::AipsrcEndian, const TSMOption &=TSMOption())
TableExprNode col(const String &columnName) const
Table(const Block< String > &tableNames, const Block< String > &subTables=Block< String >(), TableOption=Table::Old, const TSMOption &=TSMOption(), const String &subDirName=String())
Table sort(const Block< String > &columnNames, int=Sort::Ascending, int=Sort::ParSort) const
Sort on multiple columns.
Table()
Create a null Table object (i.e.
TableExprNode keyCol(const String &name, const Vector< String > &fieldNames) const
Table(const String &tableName, const TableLock &lockOptions, TableOption=Table::Old, const TSMOption &=TSMOption())
static Vector< String > nonWritableFiles(const String &tableName)
Find the non-writable files in a table.
Table operator-(const Table &) const
Subtract another table.
Table(SetupNewTable &, rownr_t nrrow=0, Bool initialize=False, EndianFormat=Table::AipsrcEndian, const TSMOption &=TSMOption())
Make a table object for a new table, which can thereafter be used for reading and writing.
static Vector< String > getLockedTables(FileLocker::LockType=FileLocker::Read, int lockOption=-1)
Get the names of tables locked in this process.
Table project(const Block< String > &columnNames) const
Project the given columns (i.e.
RowNumbers rowNumbers(const Table &that, Bool tryFast=False) const
Get a vector of row numbers in that table of rows in this table.
void addColumn(const ColumnDesc &columnDesc, Bool addToParent=True)
Add a column to the table.
Block< String > getPartNames(Bool recursive=False) const
Get the names of the tables this table consists of.
void showKeywordSets(std::ostream &, Bool showTabKey, Bool showColKey, Int maxVal) const
Show the table and/or column keywords of this table.
Table(MPI_Comm mpiComm, SetupNewTable &, TableType, rownr_t nrrow=0, Bool initialize=False, EndianFormat=Table::AipsrcEndian, const TSMOption &=TSMOption())
void showKeywords(std::ostream &, Bool showSubTables=False, Bool showTabKey=True, Bool showColKey=False, Int maxVal=25) const
Show the table and/or column keywords, possibly also of all subtables.
Record dataManagerInfo() const
Return all data managers used and the columns served by them.
Table openTable(const String &tableName, Table::TableOption=Table::Old, const TSMOption &=TSMOption())
Try to open a table.
Bool canDeleteTable(const String &tableName, Bool checkSubTables=False)
Can the table be deleted? If true, function deleteTable can safely be called.
rownr_t getLayout(TableDesc &desc, const String &tableName)
Return the layout of a table (i.e.
void deleteTable(const String &tableName, Bool checkSubTables=False)
Delete the table.
this file contains all the compiler specific defines
LatticeExprNode mask(const LatticeExprNode &expr)
This function returns the mask of the given expression.
bool Bool
Define the standard types used by Casacore.
LatticeExprNode all(const LatticeExprNode &expr)
uInt64 rownr_t
Define the type of a row number in a table.