ArrayColumn.h

Classes

ROArrayColumn -- Readonly access to an array table column with arbitrary data type (full description)
ArrayColumn -- Read/write access to an array table column with arbitrary data type (full description)

class ROArrayColumn : virtual public ROTableColumn

Interface

Public Members
ROArrayColumn()
ROArrayColumn (const Table&, const String& columnName)
ROArrayColumn (const ROTableColumn&)
ROArrayColumn (const ROArrayColumn<T>&)
~ROArrayColumn()
virtual ROTableColumn* clone() const
void reference (const ROArrayColumn<T>&)
void attach (const Table& table, const String& columnName)
uInt ndim (uInt rownr) const
IPosition shape (uInt rownr) const
void get (uInt rownr, Array<T>& array, Bool resize = False) const
Array<T> operator() (uInt rownr) const
void getSlice (uInt rownr, const Slicer& arraySection, Array<T>& array, Bool resize = False) const
Array<T> getSlice (uInt rownr, const Slicer& arraySection) const
void getColumn (Array<T>& array, Bool resize = False) const
Array<T> getColumn() const
void getColumn (const Slicer& arraySection, Array<T>& array, Bool resize = False) const
Array<T> getColumn (const Slicer& arraySection) const
void getColumnRange (const Slicer& rowRange, Array<T>& arr, Bool resize = False) const
Array<T> getColumnRange (const Slicer& rowRange) const
void getColumnCells (const RefRows& rownrs, Array<T>& arr, Bool resize = False) const
Array<T> getColumnCells (const RefRows& rownrs) const
void getColumnRange (const Slicer& rowRange, const Slicer& arraySection, Array<T>& arr, Bool resize = False) const
Array<T> getColumnRange (const Slicer& rowRange, const Slicer& arraySection) const
void getColumnCells (const RefRows& rownrs, const Slicer& arraySection, Array<T>& arr, Bool resize = False) const
Array<T> getColumnCells (const RefRows& rownrs, const RefRows& arraySection) const
void baseGet (uInt rownr, Array<T>& array) const
Private Members
ROArrayColumn<T>& operator= (const ROArrayColumn<T>&)
void reference (const ROTableColumn&)
void checkDataType() const

Description

Review Status

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

Prerequisite

Etymology

ROArrayColumn gives readonly access to an column in a table containing an array with data type T.

Synopsis

The class ROArrayColumn allows readonly access to a column containing arrays with an arbitrary data type. It can handle direct as well as indirect arrays. It is possible to get the data in an individual cell (i.e. table row); either the whole array or a slice of the array can be accessed. It is also possible to get the column as a whole if the arrays in all cells of the column have the same shape (which is always true for direct arrays). As in the case of individual cells it is possible to get the entire arrays or a slice of the arrays.

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

Template Type Argument Requirements (T)

Example

See module Tables.

Member Description

ROArrayColumn()

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

ROArrayColumn (const Table&, const String& columnName)

Construct for the given column in the given table.

ROArrayColumn (const ROTableColumn&)

Construct from the given table column. This constructor is useful if first a table column was constructed, its type is determined and thereafter used to construct the correct column object.

ROArrayColumn (const ROArrayColumn<T>&)

Copy constructor (reference semantics).

~ROArrayColumn()

virtual ROTableColumn* clone() const

Clone the object.

void reference (const ROArrayColumn<T>&)

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)

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

uInt ndim (uInt rownr) const

Get the #dimensions of an array in a particular cell. If the cell does not contain an array, 0 is returned. Use the function isDefined to test if the cell contains an array.

IPosition shape (uInt rownr) const

Get the shape of an array in a particular cell. If the cell does not contain an array, a 0-dim shape is returned. Use the function isDefined to test if the cell contains an array.

void get (uInt rownr, Array<T>& array, Bool resize = False) const

Get the array value in a particular cell (i.e. table row). The row numbers count from 0 until #rows-1.

According to the assignment rules of class Array, the destination array must be empty or its shape must conform the table array shape. However, if the resize flag is set the destination array will be resized if not conforming.

Array<T> operator() (uInt rownr) const

Get the array value in a particular cell (i.e. table row). The row numbers count from 0 until #rows-1.

void getSlice (uInt rownr, const Slicer& arraySection, Array<T>& array, Bool resize = False) const
Array<T> getSlice (uInt rownr, const Slicer& arraySection) const

Get a slice of an N-dimensional array in a particular cell (i.e. table row). The row numbers count from 0 until #rows-1. The dimensionality of the slice must match the dimensionality of the table array and the slice definition should not exceed the shape of the table array.

void getColumn (Array<T>& array, Bool resize = False) const
Array<T> getColumn() const

Get the array of all values in a column. If the column contains n-dim arrays, the resulting array is (n+1)-dim with the last dimension representing the number of rows. The arrays in the column must have the same shape in all cells.

void getColumn (const Slicer& arraySection, Array<T>& array, Bool resize = False) const
Array<T> getColumn (const Slicer& arraySection) const

Get slices from all arrays in the column. If the column contains n-dim arrays, the resulting array is (n+1)-dim. with the last dimension representing the number of rows and the other dimensions representing the shape of the slice. The arrays in the column must have the same shape in all cells.

void getColumnRange (const Slicer& rowRange, Array<T>& arr, Bool resize = False) const
Array<T> getColumnRange (const Slicer& rowRange) const
void getColumnCells (const RefRows& rownrs, Array<T>& arr, Bool resize = False) const
Array<T> getColumnCells (const RefRows& rownrs) const

Get the array of some values in a column. The Slicer object can be used to specify start, end (or length), and stride of the rows to get. If the column contains n-dim arrays, the resulting array is (n+1)-dim with the last dimension representing the number of rows in the slicer. The arrays in the column must have the same shape in all those cells. According to the assignment rules of class Array, the destination array must be empty or its shape must conform the resulting (n+1)-dim array. However, if the resize flag is set the destination array will be resized if not conforming.

void getColumnRange (const Slicer& rowRange, const Slicer& arraySection, Array<T>& arr, Bool resize = False) const
Array<T> getColumnRange (const Slicer& rowRange, const Slicer& arraySection) const
void getColumnCells (const RefRows& rownrs, const Slicer& arraySection, Array<T>& arr, Bool resize = False) const
Array<T> getColumnCells (const RefRows& rownrs, const RefRows& arraySection) const

Get slices from some arrays in a column. The first Slicer object can be used to specify start, end (or length), and stride of the rows to get. The second Slicer object can be used to specify the slice to take from each array. If the column contains n-dim arrays, the resulting array is (n+1)-dim with the last dimension representing the number of rows in the slicer. The arrays in the column must have the same shape in all those cells. According to the assignment rules of class Array, the destination array must be empty or its shape must conform the resulting (n+1)-dim array. However, if the resize flag is set the destination array will be resized if not conforming.

void baseGet (uInt rownr, Array<T>& array) const

The get() function like above which does not check shapes, etc.. It is faster and can be used for performance reasons if one knows for sure that the arguments are correct. E.g. it is used internally in virtual column engines.

ROArrayColumn<T>& operator= (const ROArrayColumn<T>&)

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

void reference (const ROTableColumn&)

Referencing any other typed column cannot be done. If we do not put this function here, the conversion constructor ROArrayColumn (const ROTableColumn&) will be used and no compile error is given.

void checkDataType() const

Check if the data type matches the column data type.


class ArrayColumn : public ROArrayColumn<T>, public TableColumn

Interface

Public Members
ArrayColumn()
ArrayColumn (const Table&, const String& columnName)
ArrayColumn (const TableColumn&)
ArrayColumn (const ArrayColumn<T>&)
~ArrayColumn()
virtual ROTableColumn* clone() const
void reference (const ArrayColumn<T>&)
void attach (const Table& table, const String& columnName)
void setShape (uInt rownr, const IPosition& shape)
void setShape (uInt rownr, const IPosition& shape, const IPosition& tileShape)
void put (uInt rownr, const Array<T>& array)
void put (uInt rownr, const ROArrayColumn<T>& that)
void put (uInt thisRownr, const ROArrayColumn<T>& that, uInt thatRownr)
void put (uInt rownr, const ROTableColumn& that)
void put (uInt thisRownr, const ROTableColumn& that, uInt thatRownr)
void putSlice (uInt rownr, const Slicer& arraySection, const Array<T>& array)
void putColumn (const Array<T>& array)
void putColumn (const Slicer& arraySection, const Array<T>& array)
void putColumnRange (const Slicer& rowRange, const Array<T>& arr)
void putColumnCells (const RefRows& rownrs, const Array<T>& arr)
void putColumnRange (const Slicer& rowRange, const Slicer& arraySection, const Array<T>& arr)
void putColumnCells (const RefRows& rownrs, const Slicer& arraySection, const Array<T>& arr)
void fillColumn (const Array<T>& value)
void putColumn (const ROArrayColumn<T>& that)
void basePut (uInt rownr, const Array<T>& array)
Private Members
ArrayColumn<T>& operator= (const ArrayColumn<T>&)
void reference (const TableColumn&)
void putColumn (const ROTableColumn&)

Description

Review Status

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

Prerequisite

Synopsis

The class ArrayColumn allows read/write access to a column containing arrays with an arbitrary data type. It augments the class ROArrayColumn with the possibility to put data into a column (cell). It is possible to put the data in an individual cell; either the whole array or a slice of the array can be accessed. It is also possible to put the column as a whole if the arrays in all cells of the column has the same shape, which is always true for direct arrays. As in the case of individual cells it is possible to put the whole arrays or a slice of the arrays. If slices are put, the array shape must be defined in advance.

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

Template Type Argument Requirements (T)

Example

See module Tables.

Member Description

ArrayColumn()

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

ArrayColumn (const Table&, const String& columnName)

Construct the array column object for the table column.

ArrayColumn (const TableColumn&)

Construct from the given table column. This constructor is useful if first a table column was constructed, its type is determined and thereafter used to construct the correct column object.

ArrayColumn (const ArrayColumn<T>&)

A const ArrayColumn can only be copied as a ROArrayColumn.

~ArrayColumn()

virtual ROTableColumn* clone() const

Clone the object.

void reference (const ArrayColumn<T>&)

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)

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

void setShape (uInt rownr, const IPosition& shape, const IPosition& tileShape)

Set the shape of the array in the given row. Setting the shape is needed if the array is put in slices, otherwise the table system would not know the shape.

Try to store the array in a tiled way using the given tile shape.

void setShape (uInt rownr, const IPosition& shape)

Set the shape of the array in the given row. Setting the shape is needed if the array is put in slices, otherwise the table system would not know the shape.

void put (uInt rownr, const Array<T>& array)

Put the array in a particular cell (i.e. table row). The row numbers count from 0 until #rows-1. If the shape of the table array in that cell has not already been defined, it will be defined implicitly.

void put (uInt rownr, const ROArrayColumn<T>& that)

Copy the value of a cell of that column to a cell of this column. The data types of both columns must be the same, otherwise an exception is thrown.

Use the same row numbers for both cells.

void put (uInt thisRownr, const ROArrayColumn<T>& that, uInt thatRownr)

Copy the value of a cell of that column to a cell of this column. The data types of both columns must be the same, otherwise an exception is thrown.

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

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 uses a generic ROTableColumn object as input. The data types of both columns must be the same, otherwise an exception is thrown.

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

void put (uInt rownr, const ROTableColumn& that)

Copy the value of a cell of that column to a cell of this column. This function uses a generic ROTableColumn object as input. The data types of both columns must be the same, otherwise an exception is thrown.

void putSlice (uInt rownr, const Slicer& arraySection, const Array<T>& array)

Put into a slice of an N-dimensional array in a particular cell. The row numbers count from 0 until #rows-1. The shape of the table array must have been defined. The dimensionality of the slice must match the dimensionality of the table array and the slice definition should not exceed the shape of the table array.

void putColumn (const Array<T>& array)

Put the array of all values in the column. If the column contains n-dim arrays, the source array must be (n+1)-dim with the last dimension representing the number of rows.

void putColumn (const Slicer& arraySection, const Array<T>& array)

Put into subsections of the table arrays in the entire column. If the column contains n-dim arrays, the source array is (n+1)-dim with the last dimension representing the number of rows and other dimensions representing the shape of the slice. The dimensionality of the slice must match the dimensionality of the table array, thus must be n-dim. Also the slice definition should not exceed the shape of the table arrays.

void putColumnRange (const Slicer& rowRange, const Array<T>& arr)
void putColumnCells (const RefRows& rownrs, const Array<T>& arr)

Put the array of some values in the column. The Slicer object can be used to specify start, end (or length), and stride of the rows to put. If the column contains n-dim arrays, the source array must be (n+1)-dim with the last dimension representing the number of rows in the slicer.

void putColumnRange (const Slicer& rowRange, const Slicer& arraySection, const Array<T>& arr)
void putColumnCells (const RefRows& rownrs, const Slicer& arraySection, const Array<T>& arr)

Put into subsection of the table arrays in some rows of the column. The first Slicer object can be used to specify start, end (or length), and stride of the rows to put. The second Slicer object can be used to specify the slice to take from each array. If the column contains n-dim arrays, the source array must be (n+1)-dim with the last dimension representing the number of rows in the slicer.

void fillColumn (const Array<T>& value)

Put the same value in all cells of the column.

void putColumn (const ROArrayColumn<T>& that)

Put the contents of a column with the same data type into this column. To put the contents of a column with a different data type into this column, the function TableColumn::putColumn can be used (provided the data type promotion is possible). In fact, this function is an assignment operator with copy semantics.

void basePut (uInt rownr, const Array<T>& array)

The put() function like above which does not check shapes, etc.. It is faster and can be used for performance reasons if one knows for sure that the arguments are correct. E.g. it is used internally in virtual column engines.

ArrayColumn<T>& operator= (const ArrayColumn<T>&)

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.

void reference (const TableColumn&)
void putColumn (const ROTableColumn&)

Referencing any other typed column cannot be done. If we do not put this function here, the conversion constructor ROArrayColumn (const ROTableColumn&) will be used and no compile error is given.