casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Friends
casa::TableColumn Class Reference

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

#include <TableColumn.h>

Inheritance diagram for casa::TableColumn:
casa::ArrayColumn< Int > casa::ArrayColumn< Short > casa::ArrayColumn< StoredType > casa::ArrayColumn< T > casa::ScalarColumn< T >

List of all members.

Public Member Functions

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

Protected Member Functions

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

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.

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, 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

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.

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

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

casa::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);
           }

Copy constructor (reference semantics).

virtual casa::TableColumn::~TableColumn ( ) [virtual]

Member Function Documentation

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 casa::TableColumn::asComplex ( uInt  rownr) const
DComplex casa::TableColumn::asDComplex ( uInt  rownr) const
double casa::TableColumn::asdouble ( uInt  rownr) const
float casa::TableColumn::asfloat ( uInt  rownr) const
Int casa::TableColumn::asInt ( uInt  rownr) const
void casa::TableColumn::attach ( const Table table,
const String columnName 
) [inline]
void casa::TableColumn::attach ( const Table table,
uInt  columnIndex 
) [inline]

Definition at line 155 of file TableColumn.h.

References reference().

BaseColumn* casa::TableColumn::baseColPtr ( ) const [inline, protected]

Get the baseColPtr_p of this TableColumn object.

Definition at line 383 of file TableColumn.h.

References baseColPtr_p.

BaseColumn* casa::TableColumn::baseColPtr ( const TableColumn that) const [inline, protected]

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 390 of file TableColumn.h.

References baseColPtr_p.

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 205 of file TableColumn.h.

References canChangeShape_p.

void casa::TableColumn::checkRowNumber ( uInt  rownr) const [inline]

Check if the row number is valid.

It throws an exception if out of range.

Definition at line 367 of file TableColumn.h.

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

void casa::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 casa::ScalarColumn< Complex >::put().

virtual TableColumn* casa::TableColumn::clone ( ) const [virtual]

Get const access to the column description.

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

void casa::TableColumn::getScalar ( uInt  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 236 of file TableColumn.h.

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

void casa::TableColumn::getScalar ( uInt  rownr,
uChar value 
) const [inline]

Definition at line 238 of file TableColumn.h.

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

void casa::TableColumn::getScalar ( uInt  rownr,
Short value 
) const [inline]

Definition at line 240 of file TableColumn.h.

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

void casa::TableColumn::getScalar ( uInt  rownr,
uShort value 
) const [inline]

Definition at line 242 of file TableColumn.h.

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

void casa::TableColumn::getScalar ( uInt  rownr,
Int value 
) const [inline]

Definition at line 244 of file TableColumn.h.

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

void casa::TableColumn::getScalar ( uInt  rownr,
uInt value 
) const [inline]

Definition at line 246 of file TableColumn.h.

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

void casa::TableColumn::getScalar ( uInt  rownr,
Int64 value 
) const [inline]

Definition at line 248 of file TableColumn.h.

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

void casa::TableColumn::getScalar ( uInt  rownr,
float &  value 
) const [inline]

Definition at line 250 of file TableColumn.h.

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

void casa::TableColumn::getScalar ( uInt  rownr,
double &  value 
) const [inline]

Definition at line 252 of file TableColumn.h.

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

void casa::TableColumn::getScalar ( uInt  rownr,
Complex &  value 
) const [inline]

Definition at line 254 of file TableColumn.h.

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

void casa::TableColumn::getScalar ( uInt  rownr,
DComplex &  value 
) const [inline]

Definition at line 256 of file TableColumn.h.

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

void casa::TableColumn::getScalar ( uInt  rownr,
String value 
) const [inline]

Definition at line 258 of file TableColumn.h.

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

void casa::TableColumn::getScalarValue ( uInt  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 283 of file TableColumn.h.

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

void casa::TableColumn::getScalarValue ( uInt  rownr,
uChar value,
const String  
) const [inline]

Definition at line 285 of file TableColumn.h.

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

void casa::TableColumn::getScalarValue ( uInt  rownr,
Short value,
const String  
) const [inline]

Definition at line 287 of file TableColumn.h.

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

void casa::TableColumn::getScalarValue ( uInt  rownr,
uShort value,
const String  
) const [inline]

Definition at line 289 of file TableColumn.h.

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

void casa::TableColumn::getScalarValue ( uInt  rownr,
Int value,
const String  
) const [inline]

Definition at line 291 of file TableColumn.h.

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

void casa::TableColumn::getScalarValue ( uInt  rownr,
uInt value,
const String  
) const [inline]

Definition at line 293 of file TableColumn.h.

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

void casa::TableColumn::getScalarValue ( uInt  rownr,
float *  value,
const String  
) const [inline]

Definition at line 295 of file TableColumn.h.

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

void casa::TableColumn::getScalarValue ( uInt  rownr,
double *  value,
const String  
) const [inline]

Definition at line 297 of file TableColumn.h.

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

void casa::TableColumn::getScalarValue ( uInt  rownr,
Complex *  value,
const String  
) const [inline]

Definition at line 299 of file TableColumn.h.

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

void casa::TableColumn::getScalarValue ( uInt  rownr,
DComplex *  value,
const String  
) const [inline]

Definition at line 301 of file TableColumn.h.

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

void casa::TableColumn::getScalarValue ( uInt  rownr,
String value,
const String  
) const [inline]

Definition at line 303 of file TableColumn.h.

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

void casa::TableColumn::getScalarValue ( uInt  rownr,
void *  value,
const String dataTypeId 
) const [inline]

Definition at line 305 of file TableColumn.h.

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

Bool casa::TableColumn::isDefined ( uInt  rownr) const [inline]

Test if the given cell contains a defined value.

Definition at line 221 of file TableColumn.h.

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

Bool casa::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, casa::False, and casa::True.

Referenced by casa::TableLogSink::location(), casa::TableLogSink::message(), casa::TableLogSink::objectID(), casa::TableLogSink::priority(), and casa::TableLogSink::time().

Bool casa::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 casa::BaseTable::isWritable().

Referenced by checkWritable().

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& casa::TableColumn::keywordSet ( ) const [inline]

Get readonly access to the column keyword set.

Definition at line 184 of file TableColumn.h.

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

uInt casa::TableColumn::ndim ( uInt  rownr) const [inline]
uInt casa::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 211 of file TableColumn.h.

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

uInt casa::TableColumn::nrow ( ) const [inline]

Get the number of rows in the column.

Definition at line 199 of file TableColumn.h.

References baseColPtr_p, and casa::BaseColumn::nrow().

TableColumn& casa::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 casa::TableColumn::put ( uInt  rownr,
const TableColumn that 
) [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.

Reimplemented in casa::ArrayColumn< T >, casa::ArrayColumn< Float >, casa::ArrayColumn< Double >, casa::ArrayColumn< String >, casa::ArrayColumn< Short >, casa::ArrayColumn< Int >, casa::ArrayColumn< StoredType >, casa::ArrayColumn< Bool >, casa::ArrayColumn< Complex >, casa::ScalarColumn< T >, casa::ScalarColumn< Float >, casa::ScalarColumn< Double >, casa::ScalarColumn< String >, casa::ScalarColumn< Int >, casa::ScalarColumn< Bool >, casa::ScalarColumn< VirtualType >, casa::ScalarColumn< TableRecord >, and casa::ScalarColumn< Complex >.

Definition at line 318 of file TableColumn.h.

References put(), and TABLECOLUMNCHECKROW.

Referenced by put().

virtual void casa::TableColumn::put ( uInt  thisRownr,
const TableColumn that,
uInt  thatRownr 
) [virtual]
void casa::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 casa::TableColumn::putScalar ( uInt  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 339 of file TableColumn.h.

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

void casa::TableColumn::putScalar ( uInt  rownr,
const uChar value 
) [inline]

Definition at line 341 of file TableColumn.h.

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

void casa::TableColumn::putScalar ( uInt  rownr,
const Short value 
) [inline]

Definition at line 343 of file TableColumn.h.

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

void casa::TableColumn::putScalar ( uInt  rownr,
const uShort value 
) [inline]

Definition at line 345 of file TableColumn.h.

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

void casa::TableColumn::putScalar ( uInt  rownr,
const Int value 
) [inline]

Definition at line 347 of file TableColumn.h.

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

void casa::TableColumn::putScalar ( uInt  rownr,
const uInt value 
) [inline]

Definition at line 349 of file TableColumn.h.

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

void casa::TableColumn::putScalar ( uInt  rownr,
const float &  value 
) [inline]

Definition at line 351 of file TableColumn.h.

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

void casa::TableColumn::putScalar ( uInt  rownr,
const double &  value 
) [inline]

Definition at line 353 of file TableColumn.h.

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

void casa::TableColumn::putScalar ( uInt  rownr,
const Complex &  value 
) [inline]

Definition at line 355 of file TableColumn.h.

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

void casa::TableColumn::putScalar ( uInt  rownr,
const DComplex &  value 
) [inline]

Definition at line 357 of file TableColumn.h.

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

void casa::TableColumn::putScalar ( uInt  rownr,
const String value 
) [inline]

Definition at line 359 of file TableColumn.h.

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

void casa::TableColumn::putScalar ( uInt  rownr,
const Char value 
) [inline]

Definition at line 361 of file TableColumn.h.

References putScalar(), and String.

Referenced by putScalar().

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().

Get read/write access to the column keyword set.

An exception is thrown if the table is not writable.

void casa::TableColumn::setMaximumCacheSize ( uInt  nbytes) const [inline]

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

Definition at line 371 of file TableColumn.h.

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

IPosition casa::TableColumn::shape ( uInt  rownr) 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 217 of file TableColumn.h.

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

Get the Table object this column belongs to.

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

if function isNull() is True.

void casa::TableColumn::throwNotWritable ( ) const [private]

Throw the exception that the column is not writable.

Referenced by checkWritable().


Friends And Related Function Documentation

friend class ForwardColumn [friend]

Definition at line 100 of file TableColumn.h.


Member Data Documentation

Definition at line 375 of file TableColumn.h.

Referenced by checkRowNumber(), and isWritable().

Definition at line 378 of file TableColumn.h.

Referenced by canChangeShape().

Definition at line 377 of file TableColumn.h.

Referenced by casa::ScalarColumn< Complex >::get().

Definition at line 379 of file TableColumn.h.

Referenced by isWritable(), and isWritableAtAll().


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