casacore
Functions
casacore::TableUtil Namespace Reference

The TableUtil namespace contains several convenience functions operating on Table objects. More...

Functions

Table openTable (const String &tableName, Table::TableOption=Table::Old, const TSMOption &=TSMOption())
 Try to open a table. More...
 
Table openTable (const String &tableName, const TableLock &lockOptions, Table::TableOption=Table::Old, const TSMOption &=TSMOption())
 
Table createTable (const String &tableName, const TableDesc &, Table::TableOption, Table::TableType=Table::Plain, const StorageOption &=StorageOption(), const Record &dmInfo=Record(), const TableLock &lockOptions=TableLock(), rownr_t nrrow=0, Bool initialize=False, Table::EndianFormat=Table::AipsrcEndian, const TSMOption &=TSMOption())
 Create a table with the given name and description. More...
 
Table createSubTable (Table &parent, const String &subtableName, const TableDesc &desc, Table::TableOption, const StorageOption &=StorageOption(), const Record &dmInfo=Record(), const TableLock &lockOptions=TableLock(), rownr_t nrrow=0, Bool initialize=False, Table::EndianFormat=Table::AipsrcEndian, const TSMOption &=TSMOption())
 
Bool canDeleteTable (const String &tableName, Bool checkSubTables=False)
 Can the table be deleted? If true, function deleteTable can safely be called. More...
 
Bool canDeleteTable (String &message, const String &tableName, Bool checkSubTables=False, Bool splitColons=True)
 
Bool canDeleteSubTable (String &message, const Table &parent, const String &subtableName, Bool checkSubTables=False)
 
void deleteTable (const String &tableName, Bool checkSubTables=False)
 Delete the table. More...
 
void deleteSubTable (Table &parent, const String &subtableName, Bool checkSubTables=False)
 
rownr_t getLayout (TableDesc &desc, const String &tableName)
 Return the layout of a table (i.e. More...
 
TableInfo tableInfo (const String &tableName)
 Get the table info of the table with the given name. More...
 
String getFullName (const String &tableName)
 Get the full name (absolute path) of the given table name, which can be a subtable specification using ::. More...
 
std::pair< Table, StringfindParentTable (const String &fullName, const TableLock &lockOptions=TableLock(), Table::TableOption option=Table::Old, const TSMOption &tsmOption=TSMOption())
 Find the parent table of the last subtable in a table name containing :: to indicate subtables. More...
 

Detailed Description

The TableUtil namespace contains several convenience functions operating on Table objects.

They make it very convenient to open, close or delete main tables and subtables.

The function openTable makes it possible to open a subtable of a table in a convenient way, even if the table is only a reference to another table (e.g., a selection). The name can be given with colons as 'maintab::subtab1::subtab2' meaning that subtab2 is opened and returned. Of course, it can also be used to open a main table such as 'my.tab'.

Similar to openTable, the function createTable can be used to create a (sub)table, possibly using the :: notation.
deleteTable is similar to delete a (sub)table.

Function Documentation

◆ canDeleteSubTable()

Bool casacore::TableUtil::canDeleteSubTable ( String message,
const Table parent,
const String subtableName,
Bool  checkSubTables = False 
)

◆ canDeleteTable() [1/2]

Bool casacore::TableUtil::canDeleteTable ( const String tableName,
Bool  checkSubTables = False 
)

Can the table be deleted? If true, function deleteTable can safely be called.

If not, message contains the reason why (e.g. 'table is not writable'). It checks if the table is writable, is not open in this process and is not open in another process. If splitColons=True the table name can contain :: to denote subtables.
If checkSubTables is set, it also checks if a subtable is not open in another process.
canDeleteSubTable can be used to check a subtable of the given parent.

◆ canDeleteTable() [2/2]

Bool casacore::TableUtil::canDeleteTable ( String message,
const String tableName,
Bool  checkSubTables = False,
Bool  splitColons = True 
)

◆ createSubTable()

Table casacore::TableUtil::createSubTable ( Table parent,
const String subtableName,
const TableDesc desc,
Table::TableOption  ,
const StorageOption = StorageOption(),
const Record dmInfo = Record(),
const TableLock lockOptions = TableLock(),
rownr_t  nrrow = 0,
Bool  initialize = False,
Table::EndianFormat  = Table::AipsrcEndian,
const TSMOption = TSMOption() 
)

◆ createTable()

Table casacore::TableUtil::createTable ( const String tableName,
const TableDesc ,
Table::TableOption  ,
Table::TableType  = Table::Plain,
const StorageOption = StorageOption(),
const Record dmInfo = Record(),
const TableLock lockOptions = TableLock(),
rownr_t  nrrow = 0,
Bool  initialize = False,
Table::EndianFormat  = Table::AipsrcEndian,
const TSMOption = TSMOption() 
)

Create a table with the given name and description.

Datamanager information can be given in the Record. The table name can be given with the :: notation meaning that a subtable of the previous part is created. Depending on the TableOption, that subtable can or cannot exist yet. It defines the subtable keyword in the parent table.
An exception is thrown if one of the parts cannot be opened.

Example

Create the ANT subtable of an MS with some description and create the table keyword ANT in sel.ms referring to the subtable. It is replaced if already existing (not if TableOption::NewNoReplace is given).

Table tab(Table::createTable ("sel.ms::ANT", someDesc, TableOption::New));
Table createTable(const String &tableName, const TableDesc &, Table::TableOption, Table::TableType=Table::Plain, const StorageOption &=StorageOption(), const Record &dmInfo=Record(), const TableLock &lockOptions=TableLock(), rownr_t nrrow=0, Bool initialize=False, Table::EndianFormat=Table::AipsrcEndian, const TSMOption &=TSMOption())
Create a table with the given name and description.

◆ deleteSubTable()

void casacore::TableUtil::deleteSubTable ( Table parent,
const String subtableName,
Bool  checkSubTables = False 
)

◆ deleteTable()

void casacore::TableUtil::deleteTable ( const String tableName,
Bool  checkSubTables = False 
)

Delete the table.

An exception is thrown if the table cannot be deleted because its is not writable or because it is still open in this or another process.
If checkSubTables is set, it is also checked if a subtable is used in another process.
deleteSubTable can be used to delete a subtable of the given parent.

◆ findParentTable()

std::pair<Table,String> casacore::TableUtil::findParentTable ( const String fullName,
const TableLock lockOptions = TableLock(),
Table::TableOption  option = Table::Old,
const TSMOption tsmOption = TSMOption() 
)

Find the parent table of the last subtable in a table name containing :: to indicate subtables.

It returns the Table object of that parent table and the name of the last subtable. An empty Table is returned if the table name does not contain subtable names. In case of an error, an exception is thrown.

◆ getFullName()

String casacore::TableUtil::getFullName ( const String tableName)

Get the full name (absolute path) of the given table name, which can be a subtable specification using ::.

◆ getLayout()

rownr_t casacore::TableUtil::getLayout ( TableDesc desc,
const String tableName 
)

Return the layout of a table (i.e.

description and #rows). This function has the advantage that only the minimal amount of information required is read from the table, thus it is faster than a normal table open. The table name can be a subtable using ::.
The number of rows is returned. The description of the table is stored in desc (its contents will be overwritten).
An exception is thrown if the table does not exist.

◆ openTable() [1/2]

Table casacore::TableUtil::openTable ( const String tableName,
const TableLock lockOptions,
Table::TableOption  = Table::Old,
const TSMOption = TSMOption() 
)

◆ openTable() [2/2]

Table casacore::TableUtil::openTable ( const String tableName,
Table::TableOption  = Table::Old,
const TSMOption = TSMOption() 
)

Try to open a table.

The name of the table can contain subtable names using :: as separator. In this way it is possible to directly open a subtable of a RefTable or ConcatTable, which is not possible if the table name is specified with slashes.
The open process is as follows:

  • It is tried to open the table with the given name.
  • If unsuccessful, the name is split into its parts using :: The first part is the main table which will be opened temporarily. The other parts are the successive subtable names (usually one). Each subtable is opened by looking it up in the keywords of the table above. The final subtable is returned.


An exception is thrown if the table cannot be opened.

Example

Open the ANTENNA subtable of an MS which might be a selection of a real MS.

Table tab(Table::openTable ("sel.ms::ANTENNA");
Table openTable(const String &tableName, Table::TableOption=Table::Old, const TSMOption &=TSMOption())
Try to open a table.

◆ tableInfo()

TableInfo casacore::TableUtil::tableInfo ( const String tableName)

Get the table info of the table with the given name.

An empty object is returned if the table is unknown. The table name can be a subtable using ::.