Loading...
Searching...
No Matches
casacore::SetupNewTable Class Reference
tables package (libcasa_tables) » Tables_module

Create a new table - define shapes, data managers, etc. More...

`#include <SetupNewTab.h>`

## Public Member Functions

| SetupNewTable (const String &tableName, const String &tableDescName, Table::TableOption, const StorageOption &=StorageOption())
| Create a new table using the table description with the given name.
| SetupNewTable (const String &tableName, const TableDesc &, Table::TableOption, const StorageOption &=StorageOption())
| Create a new table using the given table description.
| SetupNewTable (const SetupNewTable &)
| Copy constructor (reference semantics).
| ~SetupNewTable ()
SetupNewTable & | operator= (const SetupNewTable &)
| Assignment (reference semantics).
const String & | name () const
| Get the name of the table.
int | option () const
| Get the table create option.
const StorageOption & | storageOption () const
| Get the storage option.
Bool | isMarkedForDelete () const
| Test if the table is marked for delete.
const TableDesc & | tableDesc () const
| Get the table description.
void | adjustHypercolumns (const std::map< String, String > &old2new, Bool keepUnknown)
| Adjust the hypercolumn definitions.
void | bindColumn (const String &columnName, const DataManager &dm)
| Bind a column to the given data manager.
void | bindColumn (const String &columnName, const String &otherColumn)
| Bind a column to the given data manager of the other column.
void | bindGroup (const String &columnGroup, const DataManager &dm, Bool rebind=False)
| Bind a group of columns to the given data manager.
void | bindAll (const DataManager &dm, Bool rebind=False)
| Bind all columns to the given data manager.
void | bindCreate (const Record &spec)
| Create data managers and bind the columns using the specifications in the given record (which is obtained using Table::dataManagerInfo()).
void | setShapeColumn (const String &columnName, const IPosition &shape)
| Define the shape of fixed shaped arrays in a column.
Bool | isUsed () const
| Test if object is already in use.

## Private Member Functions

const std::shared_ptr< ColumnSet > & | columnSetPtr () const
| Get pointer to column set.
const std::shared_ptr< TableDesc > & | tableDescPtr () const
| Get pointer to table description.
void | setInUse ()
| Set object to in use by a (Plain)Table object.
void | handleUnbound ()
| Make a data manager for all unbound columns.

## Private Attributes

std::shared_ptr< SetupNewTableRep > | newTable_p
| Actual object.

## Friends

class | PlainTable
class | MemoryTable

## Detailed Description

Create a new table - define shapes, data managers, etc.

### Intended use:

Public interface

### Review Status

Reviewed By:
  bglenden
Date Reviewed:
  12AUG94
Test programs:
  None

### Prerequisite

- TableDesc and related classes like ArrayColumnDesc
- DataManager
- Table

### Etymology

SetupNewTable is a class to setup a new table.

### Synopsis

Constructing a new table is a two stage process. First a SetupNewTable object has to be created. Thereafter its columns have to be bound defining how they have to be stored or calculated. Columns have to be bound to a data manager (e.g. a storage manager or a virtual column engine).. Once the required columns are bound, the actual Table object can be created. At this stage, still unbound columns will be bound to the default data managers. The Table object can be used to write data, etc.

The construct options for SetupNewTable are defined in class Table. The possible options are:

- New creates a new table file. The Table destructor will write the table into the file.
- NewNoReplace as option New, but an exception will be thrown if the table file already exists.
- Scratch creates a temporary table. It will be lost when the Table object gets destructed.

More information is provided in the Tables module documentation.

### Example

Table makeIt(const TableDesc &td) { // 1
SetupNewTable maker("test.table", td, Table::New); // 2
maker.setShapeColumn("SomeArray", IPosition(2,10,10)); // 3
maker.setShapeColumn("AnotherArray", IPosition(1,100)); // 4
StManAipsIO sm1; // 5
StManKarma sm2; // 6
maker.bindAll(sm1); // 7
maker.bindColumn("SomeCol", sm2); // 8
maker.bindColumn("AnotherCol", sm2); // 9
return Table(maker, 1000); // 1000 row table // 10
} // 11
casacore::IPosition
Definition IPosition.h:117
casacore::SetupNewTable::SetupNewTable
SetupNewTable(const String &tableName, const String &tableDescName, Table::TableOption, const StorageOption &=StorageOption())
Create a new table using the table description with the given name.
casacore::StManAipsIO
AipsIO table storage manager class.
Definition StManAipsIO.h:192
casacore::TableDesc
Definition TableDesc.h:189
casacore::Table
Definition Table.h:157
casacore::Table::New
@ New
create table
Definition Table.h:175

This code illustrates a simple function that creates a Table starting from a Table descriptor. I

1. Declare the function makeIt which, given a TableDesc, returns a table.
2. Create the SetupNewTable object "maker". We want the new table to be named "test.table", its rows columns and keywords come from the TableDesc "td", and this table is to be created unconditionally, that is, it will overwrite an existing table of the same name. Alternative options are given in the synopsis.
4. Give direct arrays declared in the table descriptor (but not necessarily given a shape) a defined shape; 10x10 for the first array, 100 long vector for the second. If all direct arrays do not have a shape, an error will occur when the table is actually constructed.
6. Declare two data (storage) managers. AipsIO keeps a whole column in memory, Karma does I/O to keep a subsection in memory at once. A powerful feature of Casacore tables is that different columns may be bound to different data managers, which have different properties.
7. Define the default data manager. AipsIO in this case. Note that this statement and statement 5 are actually not needed. When the Table constructor finds some unbound columns, it will construct the default data manager for them and bind them. A default data manager can be defined in the column description and defaults to AipsIO.
9. Override the default for some particular columns.
10. Create and return a 1000 row table. With the Karma storage manager the table size must be defined at construction since new rows can't be added or deleted. If AipsIO was the only storage manager, the size wouldn't need to be defined since rows can be added with AipsIO.

### Motivation

In principle, SetupNewTab isn't necessary as what we are doing is logically just constructing a Table, so it could be done in the Table constructor. However such a process can be an involved one - binding multiple data managers and filling in the shapes of direct arrays - so separating the process makes it much clearer what is going on.

### To Do

- full implementation of tiling

Definition at line 336 of file SetupNewTab.h.

## Constructor & Destructor Documentation

## SetupNewTable() [1/3]

casacore::SetupNewTable::SetupNewTable | ( | const String & | tableName,
|  | const String & | tableDescName,
|  | Table::TableOption | ,
|  | const StorageOption & | = StorageOption() )

Create a new table using the table description with the given name.

The description will be read from a file.

Referenced by operator=(), and SetupNewTable().

## SetupNewTable() [2/3]

casacore::SetupNewTable::SetupNewTable | ( | const String & | tableName,
|  | const TableDesc & | ,
|  | Table::TableOption | ,
|  | const StorageOption & | = StorageOption() )

Create a new table using the given table description.

## SetupNewTable() [3/3]

casacore::SetupNewTable::SetupNewTable | ( | const SetupNewTable & |  | ) |

Copy constructor (reference semantics).

References SetupNewTable().

## ~SetupNewTable()

casacore::SetupNewTable::~SetupNewTable | ( |  | ) |

## Member Function Documentation

## adjustHypercolumns()

void casacore::SetupNewTable::adjustHypercolumns | ( | const std::map< String, String > & | old2new,
|  | Bool | keepUnknown )

inline

Adjust the hypercolumn definitions.

It renames and/or removes columns as necessary.

Definition at line 381 of file SetupNewTab.h.

References newTable_p.

## bindAll()

void casacore::SetupNewTable::bindAll | ( | const DataManager & | dm,
|  | Bool | rebind = False )

inline

Bind all columns to the given data manager.

The flag rebind tells if the binding of an already bound column will be overwritten. It cannot be used anymore once the SetupNewTable object is used to construct a Table object.

Definition at line 414 of file SetupNewTab.h.

References casacore::False, and newTable_p.

## bindColumn() [1/2]

void casacore::SetupNewTable::bindColumn | ( | const String & | columnName,
|  | const DataManager & | dm )

inline

Bind a column to the given data manager.

If already bound, the binding will be overwritten. It cannot be used anymore once the SetupNewTable object is used to construct a Table object.

Definition at line 389 of file SetupNewTab.h.

References newTable_p.

## bindColumn() [2/2]

void casacore::SetupNewTable::bindColumn | ( | const String & | columnName,
|  | const String & | otherColumn )

inline

Bind a column to the given data manager of the other column.

If the other column is not bound, nothing will be done. If columnName is already bound, the binding will be overwritten. It cannot be used anymore once the SetupNewTableRep object is used to construct a Table object.

Definition at line 397 of file SetupNewTab.h.

References newTable_p.

## bindCreate()

void casacore::SetupNewTable::bindCreate | ( | const Record & | spec | ) |

inline

Create data managers and bind the columns using the specifications in the given record (which is obtained using Table::dataManagerInfo()).

Definition at line 419 of file SetupNewTab.h.

References newTable_p, and casacore::Record().

## bindGroup()

void casacore::SetupNewTable::bindGroup | ( | const String & | columnGroup,
|  | const DataManager & | dm,
|  | Bool | rebind = False )

inline

Bind a group of columns to the given data manager.

The flag rebind tells if the binding of an already bound column will be overwritten. It cannot be used anymore once the SetupNewTable object is used to construct a Table object.

Definition at line 405 of file SetupNewTab.h.

References casacore::False, and newTable_p.

## columnSetPtr()

const std::shared_ptr< ColumnSet > & casacore::SetupNewTable::columnSetPtr | ( |  | ) | const

inline private

Get pointer to column set.

This function is used by PlainTable.

Definition at line 445 of file SetupNewTab.h.

References newTable_p.

## handleUnbound()

void casacore::SetupNewTable::handleUnbound | ( |  | ) |

inline private

Make a data manager for all unbound columns.

Definition at line 459 of file SetupNewTab.h.

References newTable_p.

## isMarkedForDelete()

Bool casacore::SetupNewTable::isMarkedForDelete | ( |  | ) | const

inline

Test if the table is marked for delete.

Definition at line 372 of file SetupNewTab.h.

References newTable_p.

## isUsed()

Bool casacore::SetupNewTable::isUsed | ( |  | ) | const

inline

Test if object is already in use.

Definition at line 436 of file SetupNewTab.h.

References newTable_p.

## name()

const String & casacore::SetupNewTable::name | ( |  | ) | const

inline

Get the name of the table.

Definition at line 360 of file SetupNewTab.h.

References newTable_p.

## operator=()

SetupNewTable & casacore::SetupNewTable::operator= | ( | const SetupNewTable & |  | ) |

Assignment (reference semantics).

References SetupNewTable().

## option()

int casacore::SetupNewTable::option | ( |  | ) | const

inline

Get the table create option.

Definition at line 364 of file SetupNewTab.h.

References newTable_p.

## setInUse()

void casacore::SetupNewTable::setInUse | ( |  | ) |

inline private

Set object to in use by a (Plain)Table object.

This function is used by PlainTable.

Definition at line 455 of file SetupNewTab.h.

References newTable_p.

## setShapeColumn()

void casacore::SetupNewTable::setShapeColumn | ( | const String & | columnName,
|  | const IPosition & | shape )

inline

Define the shape of fixed shaped arrays in a column.

The shape of those arrays has to be known before the table can be constructed. It has to be defined via this function, if it was not already defined in the column description. If only the dimensionality was defined in the column description, the shape's dimensionality must match it. Calling this function for an non-fixed shaped array results in an exception. It cannot be used anymore once the SetupNewTable object is used to construct a Table object.

Definition at line 432 of file SetupNewTab.h.

References newTable_p, and casacore::shape().

## storageOption()

const StorageOption & casacore::SetupNewTable::storageOption | ( |  | ) | const

inline

Get the storage option.

Definition at line 368 of file SetupNewTab.h.

References newTable_p.

## tableDesc()

const TableDesc & casacore::SetupNewTable::tableDesc | ( |  | ) | const

inline

Get the table description.

Definition at line 376 of file SetupNewTab.h.

References newTable_p.

## tableDescPtr()

const std::shared_ptr< TableDesc > & casacore::SetupNewTable::tableDescPtr | ( |  | ) | const

inline private

Get pointer to table description.

This function is used by PlainTable.

Definition at line 450 of file SetupNewTab.h.

References newTable_p.

## Friends And Related Symbol Documentation

## MemoryTable

friend class MemoryTable

friend

Definition at line 339 of file SetupNewTab.h.

References MemoryTable.

Referenced by MemoryTable.

## PlainTable

friend class PlainTable

friend

Definition at line 338 of file SetupNewTab.h.

References PlainTable.

Referenced by PlainTable.

## Member Data Documentation

## newTable_p

std::shared_ptr<SetupNewTableRep> casacore::SetupNewTable::newTable_p

private

Actual object.

Definition at line 441 of file SetupNewTab.h.

Referenced by adjustHypercolumns(), bindAll(), bindColumn(), bindColumn(), bindCreate(), bindGroup(), columnSetPtr(), handleUnbound(), isMarkedForDelete(), isUsed(), name(), option(), setInUse(), setShapeColumn(), storageOption(), tableDesc(), and tableDescPtr().

The documentation for this class was generated from the following file:

- tables/Tables/SetupNewTab.h