casacore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Friends | List of all members
casacore::TableColumn Class Reference

Read/write access to a table column. More...

#include <TableColumn.h>

Inheritance diagram for casacore::TableColumn:
casacore::ArrayColumnBase casacore::ScalarColumn< T > casacore::ScalarColumn< Bool > casacore::ScalarColumn< casacore::String > casacore::ScalarColumn< casacore::TableRecord > casacore::ScalarColumn< Double > casacore::ScalarColumn< Float > casacore::ScalarColumn< Int > casacore::ScalarColumn< uInt > casacore::ScalarColumn< VirtualType >

Public Member Functions

 TableColumn ()
 The default constructor creates a null object, i.e. More...
 
 TableColumn (const Table &, const String &columnName)
 Construct the object for a column in the table using its name. More...
 
 TableColumn (const Table &, uInt columnIndex)
 Construct the object for a column in the table using its index. More...
 
 TableColumn (const TableColumn &)
 Copy constructor (reference semantics). More...
 
virtual ~TableColumn ()
 
TableColumnoperator= (const TableColumn &)
 Assignment has reference semantics. More...
 
virtual TableColumnclone () const
 Clone the object. More...
 
void reference (const TableColumn &)
 Change the reference to another column. More...
 
void attach (const Table &table, const String &columnName)
 Attach a column to the object. More...
 
void attach (const Table &table, uInt columnIndex)
 
Bool isNull () const
 Test if the object is null, i.e. More...
 
void throwIfNull () const
 Throw an exception if the object is null, i.e. More...
 
Bool isWritable () const
 Test if the column can be written to, thus if the column and the underlying table can be written to. More...
 
Bool isWritableAtAll () const
 Test if the column is writable at all (virtual columns might not be). More...
 
void checkWritable () const
 Check if the column is writable and throw an exception if not. More...
 
const TableRecordkeywordSet () const
 Get readonly access to the column keyword set. More...
 
TableRecordrwKeywordSet ()
 Get read/write access to the column keyword set. More...
 
const ColumnDesccolumnDesc () const
 Get const access to the column description. More...
 
Table table () const
 Get the Table object this column belongs to. More...
 
rownr_t nrow () const
 Get the number of rows in the column. More...
 
Bool canChangeShape () const
 Can the shape of an already existing non-FixedShape array be changed? This depends on the storage manager. More...
 
uInt ndimColumn () const
 Get the global #dimensions of an array (ie. More...
 
IPosition shapeColumn () const
 Get the global shape of an array (ie. More...
 
Bool isDefined (rownr_t rownr) const
 Test if the given cell contains a defined value. More...
 
Bool hasContent (rownr_t rownr=0) const
 Does the column has content in the given row (default is the first row)? It has if it is defined and does not contain an empty array. More...
 
uInt ndim (rownr_t rownr) const
 Get the #dimensions of an array in a particular cell. More...
 
IPosition shape (rownr_t rownr) const
 Get the shape of an array in a particular cell. More...
 
IPosition tileShape (rownr_t rownr) const
 Get the tile shape of an array in a particular cell. More...
 
void getScalar (rownr_t rownr, Bool &value) const
 Get the value of a scalar in the given row. More...
 
void getScalar (rownr_t rownr, uChar &value) const
 
void getScalar (rownr_t rownr, Short &value) const
 
void getScalar (rownr_t rownr, uShort &value) const
 
void getScalar (rownr_t rownr, Int &value) const
 
void getScalar (rownr_t rownr, uInt &value) const
 
void getScalar (rownr_t rownr, Int64 &value) const
 
void getScalar (rownr_t rownr, float &value) const
 
void getScalar (rownr_t rownr, double &value) const
 
void getScalar (rownr_t rownr, Complex &value) const
 
void getScalar (rownr_t rownr, DComplex &value) const
 
void getScalar (rownr_t rownr, String &value) const
 
Bool asBool (rownr_t rownr) const
 Get the value from the row and convert it to the required type. More...
 
uChar asuChar (rownr_t rownr) const
 
Short asShort (rownr_t rownr) const
 
uShort asuShort (rownr_t rownr) const
 
Int asInt (rownr_t rownr) const
 
uInt asuInt (rownr_t rownr) const
 
Int64 asInt64 (rownr_t rownr) const
 
float asfloat (rownr_t rownr) const
 
double asdouble (rownr_t rownr) const
 
Complex asComplex (rownr_t rownr) const
 
DComplex asDComplex (rownr_t rownr) const
 
String asString (rownr_t rownr) const
 
void getScalarValue (rownr_t rownr, Bool *value, const String &) const
 Get the value of a scalar in the given row. More...
 
void getScalarValue (rownr_t rownr, uChar *value, const String &) const
 
void getScalarValue (rownr_t rownr, Short *value, const String &) const
 
void getScalarValue (rownr_t rownr, uShort *value, const String &) const
 
void getScalarValue (rownr_t rownr, Int *value, const String &) const
 
void getScalarValue (rownr_t rownr, uInt *value, const String &) const
 
void getScalarValue (rownr_t rownr, Int64 *value, const String &) const
 
void getScalarValue (rownr_t rownr, float *value, const String &) const
 
void getScalarValue (rownr_t rownr, double *value, const String &) const
 
void getScalarValue (rownr_t rownr, Complex *value, const String &) const
 
void getScalarValue (rownr_t rownr, DComplex *value, const String &) const
 
void getScalarValue (rownr_t rownr, String *value, const String &) const
 
void getScalarValue (rownr_t rownr, void *value, const String &dataTypeId) const
 
void put (rownr_t rownr, const TableColumn &that, Bool preserveTileShape=False)
 Copy the value of a cell of that column to a cell of this column. More...
 
virtual void put (rownr_t thisRownr, const TableColumn &that, rownr_t thatRownr, Bool preserveTileShape=False)
 Use possibly different row numbers for that (i.e. More...
 
void putColumn (const TableColumn &that)
 Copy the values of that column to this column. More...
 
void putScalar (rownr_t rownr, const Bool &value)
 Put the value of a scalar in the given row. More...
 
void putScalar (rownr_t rownr, const uChar &value)
 
void putScalar (rownr_t rownr, const Short &value)
 
void putScalar (rownr_t rownr, const uShort &value)
 
void putScalar (rownr_t rownr, const Int &value)
 
void putScalar (rownr_t rownr, const uInt &value)
 
void putScalar (rownr_t rownr, const Int64 &value)
 
void putScalar (rownr_t rownr, const float &value)
 
void putScalar (rownr_t rownr, const double &value)
 
void putScalar (rownr_t rownr, const Complex &value)
 
void putScalar (rownr_t rownr, const DComplex &value)
 
void putScalar (rownr_t rownr, const String &value)
 
void putScalar (rownr_t rownr, const Char *value)
 
void checkRowNumber (rownr_t rownr) const
 Check if the row number is valid. More...
 
void setMaximumCacheSize (uInt nbytes) const
 Set the maximum cache size (in bytes) to be used by a storage manager. More...
 

Protected Member Functions

BaseColumnbaseColPtr () const
 Get the baseColPtr_p of this TableColumn object. More...
 
BaseColumnbaseColPtr (const TableColumn &that) const
 Get the baseColPtr_p of another TableColumn object. More...
 

Protected Attributes

BaseTablebaseTabPtr_p
 
BaseColumnbaseColPtr_p
 
const ColumnCachecolCachePtr_p
 
Bool canChangeShape_p
 
Bool isColWritable_p
 

Private Member Functions

void throwNotWritable () const
 Throw the exception that the column is not writable. More...
 

Friends

class ForwardColumn
 

Detailed Description

Read/write access to a table column.

Intended use:

Public interface

Review Status

Reviewed By:
dschieb
Date Reviewed:
1994/08/10
Test programs:
none

Prerequisite

Synopsis

The class TableColumn gives read and write access to a column in a table. In particular access to the column description (for name, data type, etc.) and to the column keyword set can be obtained. Another important function is isDefined, which tests if a cell (i.e. table row) in a column contains a value.

The classes ScalarColumn<T> and ArrayColumn<T> have to be used to get/put the data in the column cells. However, TableColumn has get functions for the basic data types (Bool, uChar, Short, uSort, Int, uInt, Int64, float, double, Complex, DComplex and String). Opposite to the get functions in ScalarColumn<T>, the TableColumn get functions support data type promotion.

A default constructor is defined to allow construction of an array of TableColumn objects. However, this constructs an object not referencing a column. Functions like get, etc. will fail (i.e. result in a segmentation fault) when used on such objects. The functions isNull and throwIfNull can be used to test on this. The functions attach and reference can fill in the object.

Example

See module Tables.

Definition at line 98 of file TableColumn.h.

Constructor & Destructor Documentation

casacore::TableColumn::TableColumn ( )

The default constructor creates a null object, i.e.

it does not reference a table column. The sole purpose of this constructor is to allow construction of an array of TableColumn objects. The functions reference and attach can be used to make a null object reference a column. Note that get functions, etc. will cause a segmentation fault when operating on a null object. It was felt it was too expensive to test on null over and over again. The user should use the isNull or throwIfNull function in case of doubt.

casacore::TableColumn::TableColumn ( const Table ,
const String columnName 
)

Construct the object for a column in the table using its name.

casacore::TableColumn::TableColumn ( const Table ,
uInt  columnIndex 
)

Construct the object for a column in the table using its index.

This allows to loop through all columns in a table as:

for (uInt=0; i<tab.ncolumn(); i++) {
TableColumn tabcol(tab,i);
}
casacore::TableColumn::TableColumn ( const TableColumn )

Copy constructor (reference semantics).

virtual casacore::TableColumn::~TableColumn ( )
virtual

Member Function Documentation

Bool casacore::TableColumn::asBool ( rownr_t  rownr) const

Get the value from the row and convert it to the required type.

This can only be used for scalar columns with a standard data type.

Complex casacore::TableColumn::asComplex ( rownr_t  rownr) const
DComplex casacore::TableColumn::asDComplex ( rownr_t  rownr) const
double casacore::TableColumn::asdouble ( rownr_t  rownr) const
float casacore::TableColumn::asfloat ( rownr_t  rownr) const
Int casacore::TableColumn::asInt ( rownr_t  rownr) const
Int64 casacore::TableColumn::asInt64 ( rownr_t  rownr) const
Short casacore::TableColumn::asShort ( rownr_t  rownr) const
String casacore::TableColumn::asString ( rownr_t  rownr) const
uChar casacore::TableColumn::asuChar ( rownr_t  rownr) const
uInt casacore::TableColumn::asuInt ( rownr_t  rownr) const
uShort casacore::TableColumn::asuShort ( rownr_t  rownr) const
void casacore::TableColumn::attach ( const Table table,
const String columnName 
)
inline

Attach a column to the object.

This is in fact only a shorthand for <
reference (TableColumn (table, columnName));

Definition at line 153 of file TableColumn.h.

References reference().

void casacore::TableColumn::attach ( const Table table,
uInt  columnIndex 
)
inline

Definition at line 155 of file TableColumn.h.

References reference().

BaseColumn* casacore::TableColumn::baseColPtr ( ) const
inlineprotected

Get the baseColPtr_p of this TableColumn object.

Definition at line 395 of file TableColumn.h.

References baseColPtr_p.

BaseColumn* casacore::TableColumn::baseColPtr ( const TableColumn that) const
inlineprotected

Get the baseColPtr_p of another TableColumn object.

This is needed for function put, because baseColPtr_p is a protected member of TableColumn. Another TableColumn has no access to that.

Definition at line 402 of file TableColumn.h.

References baseColPtr_p.

Bool casacore::TableColumn::canChangeShape ( ) const
inline

Can the shape of an already existing non-FixedShape array be changed? This depends on the storage manager.

Most storage managers can handle it, but TiledDataStMan and TiledColumnStMan can not.

Definition at line 203 of file TableColumn.h.

References canChangeShape_p.

void casacore::TableColumn::checkRowNumber ( rownr_t  rownr) const
inline

Check if the row number is valid.

It throws an exception if out of range.

Definition at line 379 of file TableColumn.h.

References baseTabPtr_p, and casacore::BaseTable::checkRowNumber().

void casacore::TableColumn::checkWritable ( ) const
inline

Check if the column is writable and throw an exception if not.

Definition at line 178 of file TableColumn.h.

References isWritable(), and throwNotWritable().

Referenced by casacore::ScalarColumn< casacore::String >::put().

virtual TableColumn* casacore::TableColumn::clone ( ) const
virtual
const ColumnDesc& casacore::TableColumn::columnDesc ( ) const

Get const access to the column description.

ColumnDesc functions have to be used to get the data type, etc..

void casacore::TableColumn::getScalar ( rownr_t  rownr,
Bool value 
) const
inline

Get the value of a scalar in the given row.

Data type promotion is possible. These functions only work for the standard data types.

Definition at line 242 of file TableColumn.h.

References baseColPtr_p, casacore::BaseColumn::getScalar(), and TABLECOLUMNCHECKROW.

void casacore::TableColumn::getScalar ( rownr_t  rownr,
uChar value 
) const
inline
void casacore::TableColumn::getScalar ( rownr_t  rownr,
Short value 
) const
inline
void casacore::TableColumn::getScalar ( rownr_t  rownr,
uShort value 
) const
inline
void casacore::TableColumn::getScalar ( rownr_t  rownr,
Int value 
) const
inline
void casacore::TableColumn::getScalar ( rownr_t  rownr,
uInt value 
) const
inline
void casacore::TableColumn::getScalar ( rownr_t  rownr,
Int64 value 
) const
inline
void casacore::TableColumn::getScalar ( rownr_t  rownr,
float &  value 
) const
inline
void casacore::TableColumn::getScalar ( rownr_t  rownr,
double &  value 
) const
inline
void casacore::TableColumn::getScalar ( rownr_t  rownr,
Complex &  value 
) const
inline
void casacore::TableColumn::getScalar ( rownr_t  rownr,
DComplex &  value 
) const
inline
void casacore::TableColumn::getScalar ( rownr_t  rownr,
String value 
) const
inline
void casacore::TableColumn::getScalarValue ( rownr_t  rownr,
Bool value,
const String  
) const
inline

Get the value of a scalar in the given row.

These functions work for all data types. Data type promotion is possible for the standard data types. The functions are primarily meant for ScalarColumn<T>.

Definition at line 290 of file TableColumn.h.

References baseColPtr_p, casacore::BaseColumn::getScalar(), and TABLECOLUMNCHECKROW.

void casacore::TableColumn::getScalarValue ( rownr_t  rownr,
uChar value,
const String  
) const
inline
void casacore::TableColumn::getScalarValue ( rownr_t  rownr,
Short value,
const String  
) const
inline
void casacore::TableColumn::getScalarValue ( rownr_t  rownr,
uShort value,
const String  
) const
inline
void casacore::TableColumn::getScalarValue ( rownr_t  rownr,
Int value,
const String  
) const
inline
void casacore::TableColumn::getScalarValue ( rownr_t  rownr,
uInt value,
const String  
) const
inline
void casacore::TableColumn::getScalarValue ( rownr_t  rownr,
Int64 value,
const String  
) const
inline
void casacore::TableColumn::getScalarValue ( rownr_t  rownr,
float *  value,
const String  
) const
inline
void casacore::TableColumn::getScalarValue ( rownr_t  rownr,
double *  value,
const String  
) const
inline
void casacore::TableColumn::getScalarValue ( rownr_t  rownr,
Complex *  value,
const String  
) const
inline
void casacore::TableColumn::getScalarValue ( rownr_t  rownr,
DComplex *  value,
const String  
) const
inline
void casacore::TableColumn::getScalarValue ( rownr_t  rownr,
String value,
const String  
) const
inline
void casacore::TableColumn::getScalarValue ( rownr_t  rownr,
void *  value,
const String dataTypeId 
) const
inline
Bool casacore::TableColumn::hasContent ( rownr_t  rownr = 0) const

Does the column has content in the given row (default is the first row)? It has if it is defined and does not contain an empty array.

Bool casacore::TableColumn::isDefined ( rownr_t  rownr) const
inline

Test if the given cell contains a defined value.

Definition at line 219 of file TableColumn.h.

References baseColPtr_p, casacore::BaseColumn::isDefined(), and TABLECOLUMNCHECKROW.

Bool casacore::TableColumn::isNull ( ) const
inline

Test if the object is null, i.e.

does not reference a column.

Definition at line 160 of file TableColumn.h.

References baseColPtr_p, casacore::False, and casacore::True.

Bool casacore::TableColumn::isWritable ( ) const
inline

Test if the column can be written to, thus if the column and the underlying table can be written to.

Definition at line 169 of file TableColumn.h.

References baseTabPtr_p, isColWritable_p, and casacore::BaseTable::isWritable().

Referenced by checkWritable().

Bool casacore::TableColumn::isWritableAtAll ( ) const
inline

Test if the column is writable at all (virtual columns might not be).

Note that keywords can always be written, even for virtual columns.

Definition at line 174 of file TableColumn.h.

References isColWritable_p.

const TableRecord& casacore::TableColumn::keywordSet ( ) const
inline

Get readonly access to the column keyword set.

Definition at line 182 of file TableColumn.h.

References baseColPtr_p, and casacore::BaseColumn::keywordSet().

uInt casacore::TableColumn::ndim ( rownr_t  rownr) const
inline

Get the #dimensions of an array in a particular cell.

Definition at line 227 of file TableColumn.h.

References baseColPtr_p, casacore::BaseColumn::ndim(), and TABLECOLUMNCHECKROW.

uInt casacore::TableColumn::ndimColumn ( ) const
inline

Get the global #dimensions of an array (ie.

for all cells in column). This is always set for fixed shape arrays. Otherwise, 0 will be returned.

Definition at line 209 of file TableColumn.h.

References baseColPtr_p, and casacore::BaseColumn::ndimColumn().

rownr_t casacore::TableColumn::nrow ( ) const
inline
TableColumn& casacore::TableColumn::operator= ( const TableColumn )

Assignment has reference semantics.

It copies the object, not the data of that column to this column. Function putColumn can be used to copy the data of a column.
It does the same as the reference function.

void casacore::TableColumn::put ( rownr_t  rownr,
const TableColumn that,
Bool  preserveTileShape = False 
)
inline

Copy the value of a cell of that column to a cell of this column.

This function only works for the standard data types. Data type promotion will be done if needed. An exception is thrown if this column is not writable or if the data cannot be converted.

Use the same row numbers for both cells.

Definition at line 327 of file TableColumn.h.

virtual void casacore::TableColumn::put ( rownr_t  thisRownr,
const TableColumn that,
rownr_t  thatRownr,
Bool  preserveTileShape = False 
)
virtual
void casacore::TableColumn::putColumn ( const TableColumn that)

Copy the values of that column to this column.

The numbers of rows in both columns must be equal. Data type promotion is possible. An exception is thrown if the data cannot be converted. This function is useful to copy one column to another without knowing their data types. In fact, this function is an assignment operator with copy semantics.

void casacore::TableColumn::putScalar ( rownr_t  rownr,
const Bool value 
)
inline

Put the value of a scalar in the given row.

Data type promotion is possible. These functions only work for the standard data types.

Definition at line 349 of file TableColumn.h.

References baseColPtr_p, casacore::BaseColumn::putScalar(), and TABLECOLUMNCHECKROW.

Referenced by putScalar().

void casacore::TableColumn::putScalar ( rownr_t  rownr,
const uChar value 
)
inline
void casacore::TableColumn::putScalar ( rownr_t  rownr,
const Short value 
)
inline
void casacore::TableColumn::putScalar ( rownr_t  rownr,
const uShort value 
)
inline
void casacore::TableColumn::putScalar ( rownr_t  rownr,
const Int value 
)
inline
void casacore::TableColumn::putScalar ( rownr_t  rownr,
const uInt value 
)
inline
void casacore::TableColumn::putScalar ( rownr_t  rownr,
const Int64 value 
)
inline
void casacore::TableColumn::putScalar ( rownr_t  rownr,
const float &  value 
)
inline
void casacore::TableColumn::putScalar ( rownr_t  rownr,
const double &  value 
)
inline
void casacore::TableColumn::putScalar ( rownr_t  rownr,
const Complex &  value 
)
inline
void casacore::TableColumn::putScalar ( rownr_t  rownr,
const DComplex &  value 
)
inline
void casacore::TableColumn::putScalar ( rownr_t  rownr,
const String value 
)
inline
void casacore::TableColumn::putScalar ( rownr_t  rownr,
const Char value 
)
inline

Definition at line 373 of file TableColumn.h.

References putScalar().

void casacore::TableColumn::reference ( const TableColumn )

Change the reference to another column.

This is in fact an assignment operator with reference semantics. It removes the reference to the current column and creates a reference to the column referenced in the other object. It will handle null objects correctly.

Referenced by attach().

TableRecord& casacore::TableColumn::rwKeywordSet ( )

Get read/write access to the column keyword set.

An exception is thrown if the table is not writable.

void casacore::TableColumn::setMaximumCacheSize ( uInt  nbytes) const
inline

Set the maximum cache size (in bytes) to be used by a storage manager.

Definition at line 383 of file TableColumn.h.

References baseColPtr_p, and casacore::BaseColumn::setMaximumCacheSize().

IPosition casacore::TableColumn::shape ( rownr_t  rownr) const
inline

Get the shape of an array in a particular cell.

Definition at line 231 of file TableColumn.h.

References baseColPtr_p, casacore::BaseColumn::shape(), and TABLECOLUMNCHECKROW.

IPosition casacore::TableColumn::shapeColumn ( ) const
inline

Get the global shape of an array (ie.

for all cells in the column). This is always set for fixed shape arrays. Otherwise, a 0-dim shape will be returned.

Definition at line 215 of file TableColumn.h.

References baseColPtr_p, and casacore::BaseColumn::shapeColumn().

Table casacore::TableColumn::table ( ) const

Get the Table object this column belongs to.

void casacore::TableColumn::throwIfNull ( ) const

Throw an exception if the object is null, i.e.

if function isNull() is True.

void casacore::TableColumn::throwNotWritable ( ) const
private

Throw the exception that the column is not writable.

Referenced by checkWritable().

IPosition casacore::TableColumn::tileShape ( rownr_t  rownr) const
inline

Get the tile shape of an array in a particular cell.

Definition at line 235 of file TableColumn.h.

References baseColPtr_p, TABLECOLUMNCHECKROW, and casacore::BaseColumn::tileShape().

Friends And Related Function Documentation

friend class ForwardColumn
friend

Definition at line 100 of file TableColumn.h.

Member Data Documentation

BaseColumn* casacore::TableColumn::baseColPtr_p
protected
BaseTable* casacore::TableColumn::baseTabPtr_p
protected

Definition at line 387 of file TableColumn.h.

Referenced by checkRowNumber(), and isWritable().

Bool casacore::TableColumn::canChangeShape_p
protected

Definition at line 390 of file TableColumn.h.

Referenced by canChangeShape().

const ColumnCache* casacore::TableColumn::colCachePtr_p
protected

Definition at line 389 of file TableColumn.h.

Referenced by casacore::ScalarColumn< casacore::String >::get().

Bool casacore::TableColumn::isColWritable_p
protected

Definition at line 391 of file TableColumn.h.

Referenced by isWritable(), and isWritableAtAll().


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