The classes ROScalarColumn
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 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.
Construct the object for a column in the table using its name.
Construct the object for a column in the table using its index.
This allows to loop through all columns in a table as:
Copy constructor (reference semantics).
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.
Test if the object is null, i.e. does not reference a column.
Throw an exception if the object is null, i.e.
if function isNull() is True.
Get const access to the column keyword set.
Get const access to the column description.
ColumnDesc functions have to be used to get the data type, etc..
Get the number of rows in the column.
Get the global #dimensions of an array (ie. for all cells in the column).
This is always set for direct arrays and might be set for indirect
arrays. If not, 0 will be returned.
Get the global shape of an array (ie. for all cells in the column).
This is always set for direct arrays and might be set for indirect
arrays. If not, a 0-dim shape will be returned.
Test if the given cell contains a defined value.
Get the #dimensions of an array in a particular cell.
Get the shape of an array in a particular cell.
Get the value of a scalar in the given row.
Data type promotion is possible.
These functions only work for the standard data types.
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.
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.
The classes ScalarColumn
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 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.
Construct the object for a column in the table using its name.
Construct the object for a column in the table using its index.
This allows to loop through all columns in a table as:
Copy constructor (reference semantics).
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.
Get access to the column keyword set.
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.
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.
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.
Put the value of a scalar in the given row.
Data type promotion is possible.
These functions only work for the standard data types.
Copyright © 1995 Associated Universities Inc., Washington, D.C.Example
See module file Tables.h.
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 function reference 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)
ROTableColumn (const Table&, uInt columnIndex)
for (uInt=0; i<tab.ncolumn(); i++) {
ROTableColumn tabcol(tab,i);
}
ROTableColumn (const ROTableColumn&)
virtual ~ROTableColumn()
void reference (const ROTableColumn&)
Bool isNull() const
void throwIfNull() const
const TableKeywordSet& keywordSet() const
const ColumnDesc& columnDesc() const
uInt nrow() 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, 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
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
BaseColumn* baseColPtr (const ROTableColumn& that) const
pointer to real column object
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
Description
Review Status
Prerequisite
Synopsis
The class TableColumn augments the class ROTableColumn
with write access to a table column.
Example
see module file Tables.h
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 function reference 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)
TableColumn (const Table&, uInt columnIndex)
for (uInt=0; i<tab.ncolumn(); i++) {
TableColumn tabcol(tab,i);
}
TableColumn (const TableColumn&)
~TableColumn()
void reference (const TableColumn&)
TableKeywordSet& keywordSet()
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 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)
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.