TableColumn.h

Classes

ROTableColumn -- Readonly access to a table column (full description)
TableColumn -- Non-const access to a table column (full description)

class ROTableColumn

Interface

Public Members
ROTableColumn()
ROTableColumn (const Table&, const String& columnName)
ROTableColumn (const Table&, uInt columnIndex)
ROTableColumn (const ROTableColumn&)
virtual ~ROTableColumn()
virtual ROTableColumn* clone() const
void reference (const ROTableColumn&)
void attach (const Table& table, const String& columnName)
void attach (const Table& table, uInt columnIndex)
Bool isNull() const
void throwIfNull() const
const TableRecord& keywordSet() const
const ColumnDesc& columnDesc() const
Table table() const
uInt nrow() const
Bool canChangeShape() const
uInt ndimColumn() const
IPosition shapeColumn() const
Bool isDefined (uInt rownr) const
uInt ndim (uInt rownr) const
IPosition shape (uInt rownr) const
void getScalar (uInt rownr, Bool& value) const
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, 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
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
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 checkRowNumber (uInt rownr) const
void setMaximumCacheSize (uInt nbytes) const
Protected Members
BaseColumn* baseColPtr () const
BaseColumn* baseColPtr (const ROTableColumn& that) const
Private Members
ROTableColumn& operator= (const ROTableColumn&)

Description

Review Status

Reviewed By:
dschieb
Date Reviewed:
1994/08/10
Programs:
Tests:

Prerequisite

Etymology

ROTableColumn gives readonly access to an arbitrary column in a table.

Synopsis

The class ROTableColumn gives readonly 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 ROScalarColumn and ROArrayColumn have to be used to get the data in the column cells. However, ROTableColumn 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 ROScalarColumn, the ROTableColumn get functions support data type promotion.

A default constructor is defined to allow construction of an array of ROTableColumn 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.

The assignment operator is not defined for this class, because it was felt it would be too confusing. Instead the function reference can be used to do assignment with reference semantics. An assignment with copy semantics makes no sense for a readonly column.

Example

See module Tables.

Member Description

ROTableColumn()

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 ROTableColumn 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.

ROTableColumn (const Table&, const String& columnName)

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

ROTableColumn (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++) {
        ROTableColumn tabcol(tab,i);
    }

ROTableColumn (const ROTableColumn&)

Copy constructor (reference semantics).

virtual ~ROTableColumn()

virtual ROTableColumn* clone() const

Clone the object.

void reference (const ROTableColumn&)

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.

void attach (const Table& table, const String& columnName)
void attach (const Table& table, uInt columnIndex)

Attach a column to the object. This is in fact only a shorthand for <
reference (ROTableColumn (table, columnName));

Bool isNull() const

Test if the object is null, i.e. does not reference a column.

void throwIfNull() const

Throw an exception if the object is null, i.e. if function isNull() is True.

const TableRecord& keywordSet() const

Get const access to the column keyword set.

const ColumnDesc& columnDesc() const

Get const access to the column description. ColumnDesc functions have to be used to get the data type, etc..

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. Most storage managers can handle it, but TiledDataStMan and TiledColumnStMan can not.

uInt ndimColumn() const

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.

IPosition shapeColumn() const

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.

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

Get the value of a scalar in the given row. Data type promotion is possible. These functions only work for the standard data types.

Bool asBool (uInt rownr) const
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

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.

void getScalarValue (uInt rownr, Bool* value, const String&) const
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

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.

void checkRowNumber (uInt rownr) const

Check if the row number is valid. It throws an exception if out of range.

void setMaximumCacheSize (uInt nbytes) const

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

BaseColumn* baseColPtr () const

Get the baseColPtr_p of this ROTableColumn object.

BaseColumn* baseColPtr (const ROTableColumn& that) const

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

ROTableColumn& operator= (const ROTableColumn&)

Assignment makes no sense for a readonly class. Declaring this operator private, makes it unusable.

class TableColumn : virtual public ROTableColumn

Interface

Public Members
TableColumn()
TableColumn (const Table&, const String& columnName)
TableColumn (const Table&, uInt columnIndex)
TableColumn (const TableColumn&)
~TableColumn()
virtual ROTableColumn* clone() const
void reference (const TableColumn&)
void attach (const Table& table, const String& columnName)
void attach (const Table& table, uInt columnIndex)
TableRecord& rwKeywordSet()
void put (uInt rownr, const ROTableColumn& that)
virtual void put (uInt thisRownr, const ROTableColumn& that, uInt thatRownr)
void putColumn (const ROTableColumn& that)
void putScalar (uInt rownr, const Bool& value)
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)
Private Members
TableColumn& operator= (const TableColumn&)

Description

Review Status

Reviewed By:
dschieb
Date Reviewed:
1994/08/10
Programs:
Tests:
  • none

Prerequisite

Synopsis

The class TableColumn augments the class ROTableColumn with write access to a table column.

The classes ScalarColumn and ArrayColumn can be used to put typed data in the column cells.

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

The assignment operator is not defined for this class, because it was felt it would be too confusing. Instead the function reference can be used to do assignment with reference semantics. An assignment with copy semantics can be done with a putColumn function.

Example

See module Tables.

Member Description

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 function in case of doubt.

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. This allows to loop through all columns in a table as:

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

TableColumn (const TableColumn&)

Copy constructor (reference semantics).

~TableColumn()

virtual ROTableColumn* clone() const

Clone the object.

void 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.

void attach (const Table& table, const String& columnName)
void attach (const Table& table, uInt columnIndex)

Attach a column to the object. This is in fact only a shorthand for
reference (TableColumn (table, columnName));

TableRecord& rwKeywordSet()

Get access to the column keyword set.

void put (uInt rownr, const ROTableColumn& that)

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 the data cannot be converted.

Use the same row numbers for both cells.

virtual void put (uInt thisRownr, const ROTableColumn& that, uInt thatRownr)

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 the data cannot be converted.

Use possibly different row numbers for that (i.e. input) and and this (i.e. output) cell.

void putColumn (const ROTableColumn& 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 putScalar (uInt rownr, const Bool& value)
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)

Put the value of a scalar in the given row. Data type promotion is possible. These functions only work for the standard data types.

TableColumn& operator= (const TableColumn&)

Assigning one column to another suggests a deep copy. Because the copy constructor has reference semantics, it was felt it would be too confusing to allow assignment. Instead the function reference (with reference semantics) and putColumn (with copy semantics) exist. Declaring this operator private, makes it unusable.