Access to a scalar table column with arbitrary data type. More...
#include <ScalarColumn.h>
Public Member Functions | |
ScalarColumn () | |
The default constructor creates a null object, i.e. | |
ScalarColumn (const Table &, const String &columnName) | |
Construct for the given column in the given table. | |
ScalarColumn (const TableColumn &) | |
Construct from the given table column. | |
ScalarColumn (const ScalarColumn< T > &) | |
Copy constructor (reference semantics). | |
~ScalarColumn () | |
virtual TableColumn * | clone () const |
Clone the object. | |
ScalarColumn< T > & | operator= (const ScalarColumn< T > &) |
Assignment uses reference semantics, thus works the same as function reference. | |
void | reference (const ScalarColumn< T > &) |
Change the reference to another column. | |
void | attach (const Table &table, const String &columnName) |
Attach a column to the object. | |
void | get (uInt rownr, T &value) const |
Get the data from a particular cell (i.e. | |
T | get (uInt rownr) const |
T | operator() (uInt rownr) const |
void | getColumn (Vector< T > &vec, Bool resize=False) const |
Get the vector of all values in the column. | |
Vector< T > | getColumn () const |
Get the vector of all values in the column. | |
void | getColumnRange (const Slicer &rowRange, Vector< T > &vec, Bool resize=False) const |
Get the vector of a range of values in the column. | |
Vector< T > | getColumnRange (const Slicer &rowRange) const |
Get the vector of a range of values in the column. | |
void | getColumnCells (const RefRows &rownrs, Vector< T > &vec, Bool resize=False) const |
Get the vector of some values in the column. | |
Vector< T > | getColumnCells (const RefRows &rownrs) const |
Get the vector of some values in the column. | |
void | put (uInt rownr, const T &value) |
Put the value in a particular cell (i.e. | |
void | put (uInt rownr, const ScalarColumn< T > &that) |
Copy the value of a cell of that column to a cell of this column. | |
void | put (uInt thisRownr, const ScalarColumn< T > &that, uInt thatRownr) |
Use possibly different row numbers for that (i.e. | |
void | put (uInt rownr, const TableColumn &that, Bool=False) |
Copy the value of a cell of that column to a cell of this column. | |
void | put (uInt thisRownr, const TableColumn &that, uInt thatRownr, Bool=False) |
Use possibly different row numbers for that (i.e. | |
void | putColumn (const Vector< T > &vec) |
Put the vector of all values in the column. | |
void | putColumnRange (const Slicer &rowRange, const Vector< T > &vec) |
Put the vector of a range of values in the column. | |
void | putColumnCells (const RefRows &rownrs, const Vector< T > &vec) |
Put the vector of some values in the column. | |
void | fillColumn (const T &value) |
Put the same value in all cells of the column. | |
void | putColumn (const ScalarColumn< T > &that) |
Put the contents of a column with the same data type into this column. | |
Protected Attributes | |
Bool | canAccessColumn_p |
Keep a switch to determine if an entire column can be accessed. | |
Bool | reaskAccessColumn_p |
Keep a switch to know if access knowledge is permanent or has to be asked again the next time. | |
Private Member Functions | |
void | checkDataType () const |
Check if the data type matches the column data type. |
Access to a scalar table column with arbitrary data type.
Public interface
ScalarColumn<T> gives read and write access to a column in a table containing a scalar with data type T.
The class ScalarColumn allows read and write access to a column containing scalar values with an arbitrary data type. It is possible to get the data in an individual cell (i.e. table row) and to get the column as a whole.
A default constructor is defined to allow construction of an array of ScalarColumn 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.
See module Tables .
Definition at line 84 of file ScalarColumn.h.
casacore::ScalarColumn< T >::ScalarColumn | ( | ) |
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 ScalarColumn 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::ScalarColumn< T >::ScalarColumn | ( | const Table & | , | |
const String & | columnName | |||
) |
Construct for the given column in the given table.
casacore::ScalarColumn< T >::ScalarColumn | ( | const TableColumn & | ) | [explicit] |
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.
casacore::ScalarColumn< T >::ScalarColumn | ( | const ScalarColumn< T > & | ) |
Copy constructor (reference semantics).
casacore::ScalarColumn< T >::~ScalarColumn | ( | ) |
void casacore::ScalarColumn< T >::attach | ( | const Table & | table, | |
const String & | columnName | |||
) | [inline] |
Attach a column to the object.
This is in fact only a shorthand for
reference (ScalarColumn<T> (table, columnName));
Reimplemented from casacore::TableColumn.
Definition at line 131 of file ScalarColumn.h.
Referenced by casa::ScantableFrequenciesIterator::ScantableFrequenciesIterator().
void casacore::ScalarColumn< T >::checkDataType | ( | ) | const [private] |
Check if the data type matches the column data type.
virtual TableColumn* casacore::ScalarColumn< T >::clone | ( | ) | const [virtual] |
Clone the object.
Reimplemented from casacore::TableColumn.
void casacore::ScalarColumn< T >::fillColumn | ( | const T & | value | ) |
Put the same value in all cells of the column.
T casacore::ScalarColumn< T >::get | ( | uInt | rownr | ) | const [inline] |
Definition at line 147 of file ScalarColumn.h.
void casacore::ScalarColumn< T >::get | ( | uInt | rownr, | |
T & | value | |||
) | const [inline] |
Get the data from a particular cell (i.e.
table row). The row numbers count from 0 until #rows-1.
Definition at line 137 of file ScalarColumn.h.
Vector<T> casacore::ScalarColumn< T >::getColumn | ( | ) | const |
Get the vector of all values in the column.
void casacore::ScalarColumn< T >::getColumn | ( | Vector< T > & | vec, | |
Bool | resize = False | |||
) | const |
Get the vector of all values in the column.
According to the assignment rules of class Array, the destination vector must be empty or its length must be the number of cells in the column (i.e. the number of rows in the table).
Referenced by casa::ScantableFrequenciesIterator::ScantableFrequenciesIterator().
Vector<T> casacore::ScalarColumn< T >::getColumnCells | ( | const RefRows & | rownrs | ) | const |
Get the vector of some values in the column.
void casacore::ScalarColumn< T >::getColumnCells | ( | const RefRows & | rownrs, | |
Vector< T > & | vec, | |||
Bool | resize = False | |||
) | const |
Get the vector of some values in the column.
The Slicer object can be used to specify start, end (or length), and stride of the rows to get. According to the assignment rules of class Array, the destination vector must be empty or its length must be the number of cells in the column (i.e. the number of rows in the RefRows object).
Vector<T> casacore::ScalarColumn< T >::getColumnRange | ( | const Slicer & | rowRange | ) | const |
Get the vector of a range of values in the column.
The Slicer object can be used to specify start, end (or length), and stride of the rows to get.\.
void casacore::ScalarColumn< T >::getColumnRange | ( | const Slicer & | rowRange, | |
Vector< T > & | vec, | |||
Bool | resize = False | |||
) | const |
Get the vector of a range of values in the column.
The Slicer object can be used to specify start, end (or length), and stride of the rows to get. According to the assignment rules of class Array, the destination vector must be empty or its length must be the number of cells in the column (i.e. the number of rows in the slicer).
T casacore::ScalarColumn< T >::operator() | ( | uInt | rownr | ) | const [inline] |
Definition at line 153 of file ScalarColumn.h.
ScalarColumn<T>& casacore::ScalarColumn< T >::operator= | ( | const ScalarColumn< T > & | ) |
Assignment uses reference semantics, thus works the same as function reference.
Reimplemented from casacore::TableColumn.
void casacore::ScalarColumn< T >::put | ( | uInt | thisRownr, | |
const TableColumn & | that, | |||
uInt | thatRownr, | |||
Bool | = False | |||
) |
Use possibly different row numbers for that (i.e.
input) and and this (i.e. output) cell.
void casacore::ScalarColumn< T >::put | ( | uInt | rownr, | |
const TableColumn & | that, | |||
Bool | = False | |||
) | [inline] |
Copy the value of a cell of that column to a cell of this column.
This function uses a generic TableColumn object as input. If possible the data will be promoted to the data type of this column. Otherwise an exception is thrown.
Use the same row numbers for both cells.
Definition at line 219 of file ScalarColumn.h.
Referenced by casacore::ScalarColumn< uInt >::put().
void casacore::ScalarColumn< T >::put | ( | uInt | thisRownr, | |
const ScalarColumn< T > & | that, | |||
uInt | thatRownr | |||
) |
Use possibly different row numbers for that (i.e.
input) and and this (i.e. output) cell.
void casacore::ScalarColumn< T >::put | ( | uInt | rownr, | |
const ScalarColumn< T > & | that | |||
) | [inline] |
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.
Use the same row numbers for both cells.
Definition at line 206 of file ScalarColumn.h.
Referenced by casacore::ScalarColumn< uInt >::put().
void casacore::ScalarColumn< T >::put | ( | uInt | rownr, | |
const T & | value | |||
) | [inline] |
Put the value in a particular cell (i.e.
table row). The row numbers count from 0 until #rows-1.
Definition at line 198 of file ScalarColumn.h.
void casacore::ScalarColumn< T >::putColumn | ( | const ScalarColumn< 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.
Reimplemented from casacore::TableColumn.
void casacore::ScalarColumn< T >::putColumn | ( | const Vector< T > & | vec | ) |
Put the vector of all values in the column.
The length of the vector must be the number of cells in the column (i.e. the number of rows in the table).
void casacore::ScalarColumn< T >::putColumnCells | ( | const RefRows & | rownrs, | |
const Vector< T > & | vec | |||
) |
Put the vector of some values in the column.
The length of the vector must be the number of cells in the RefRows object.
void casacore::ScalarColumn< T >::putColumnRange | ( | const Slicer & | rowRange, | |
const Vector< T > & | vec | |||
) |
Put the vector of a range of values in the column.
The Slicer object can be used to specify start, end (or length), and stride of the rows to put. The length of the vector must be the number of cells in the slice.
void casacore::ScalarColumn< T >::reference | ( | const ScalarColumn< 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.
Reimplemented from casacore::TableColumn.
Referenced by casacore::ScalarColumn< uInt >::attach().
Bool casacore::ScalarColumn< T >::canAccessColumn_p [mutable, protected] |
Keep a switch to determine if an entire column can be accessed.
True = yes; False = no.
Definition at line 260 of file ScalarColumn.h.
Bool casacore::ScalarColumn< T >::reaskAccessColumn_p [mutable, protected] |
Keep a switch to know if access knowledge is permanent or has to be asked again the next time.
Definition at line 263 of file ScalarColumn.h.